Legend.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* global Ext, expect */
  2. topSuite("Ext.chart.legend.Legend", ['Ext.chart.*', 'Ext.data.ArrayStore'], function() {
  3. describe('resize', function () {
  4. var chart;
  5. afterEach(function () {
  6. Ext.destroy(chart);
  7. });
  8. it('should schedule chart layout when the legend size changes', function () {
  9. var layoutDone;
  10. runs(function () {
  11. chart = Ext.create({
  12. xtype: 'polar',
  13. renderTo: document.body,
  14. width: 400,
  15. height: 400,
  16. innerPadding: 10,
  17. // Create a polar chart with no data.
  18. store: {
  19. fields: ['name', 'data1'],
  20. data: []
  21. },
  22. legend: {
  23. type: 'dom',
  24. docked: 'right'
  25. },
  26. series: {
  27. type: 'pie',
  28. highlight: true,
  29. angleField: 'data1',
  30. donut: 30
  31. },
  32. listeners: {
  33. layout: function () {
  34. layoutDone = true;
  35. }
  36. }
  37. });
  38. });
  39. waitsFor(function () {
  40. return layoutDone;
  41. });
  42. runs(function () {
  43. layoutDone = false;
  44. // Add data to the chart.
  45. // That should populate the legend, which will change its size,
  46. // which should trigger another chart layout.
  47. chart.getStore().add({
  48. name: 'metric one',
  49. data1: 14
  50. }, {
  51. name: 'metric two',
  52. data1: 16
  53. }, {
  54. name: 'metric three',
  55. data1: 14
  56. }, {
  57. name: 'metric four',
  58. data1: 6
  59. }, {
  60. name: 'metric five',
  61. data1: 36
  62. });
  63. //
  64. });
  65. waitsFor(function () {
  66. // If the layout is not done, we will wait forever
  67. // or until the test times out.
  68. return layoutDone;
  69. });
  70. });
  71. });
  72. });