AbstractChart.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. topSuite("Ext.chart.AbstractChart.classic",
  2. [false, 'Ext.chart.*', 'Ext.data.ArrayStore'],
  3. function() {
  4. var chart, store;
  5. var Model = Ext.define(null, {
  6. extend: 'Ext.data.Model',
  7. fields: ['label', 'value']
  8. });
  9. function makeStore(rows) {
  10. var data = [],
  11. i;
  12. for (i = 1; i <= rows; ++i) {
  13. data.push({
  14. label: 'Item' + i,
  15. value: i
  16. });
  17. }
  18. store = new Ext.data.Store({
  19. model: Model,
  20. data: data
  21. });
  22. }
  23. afterEach(function() {
  24. store = chart = Ext.destroy(chart, store);
  25. });
  26. describe('interactions', function () {
  27. it("should not be created, unless configured", function () {
  28. makeStore(2);
  29. chart = new Ext.chart.PolarChart({
  30. width: 400,
  31. height: 400,
  32. store: store,
  33. series: {
  34. type: 'pie',
  35. angleField: 'value'
  36. }
  37. });
  38. expect(chart.getInteractions().length).toEqual(0);
  39. });
  40. });
  41. describe('layout', function () {
  42. it("should size chart's body to the size of the parent element", function () {
  43. var value = 400,
  44. bodySize;
  45. makeStore(2);
  46. new Ext.chart.PolarChart({
  47. width: value,
  48. height: value,
  49. store: store,
  50. renderTo: document.body,
  51. series: {
  52. type: 'pie',
  53. angleField: 'value'
  54. },
  55. listeners: {
  56. afterLayout: function () {
  57. bodySize = this.body.getSize();
  58. }
  59. }
  60. }).destroy();
  61. expect(bodySize).toBeDefined();
  62. expect(bodySize.width).toEqual(value);
  63. expect(bodySize.height).toEqual(value);
  64. });
  65. });
  66. });