PanZoom.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. topSuite("Ext.chart.interactions.PanZoom",
  2. ['Ext.Panel', 'Ext.toolbar.Toolbar', 'Ext.chart.*', 'Ext.data.ArrayStore',
  3. 'Ext.Button'],
  4. function() {
  5. describe('modeToggleButton', function () {
  6. it('should have its value set based on the value of zoomOnPanGesture config', function () {
  7. var panel, toolbar, isAfterRender;
  8. runs(function () {
  9. toolbar = Ext.create({
  10. xtype: 'toolbar',
  11. renderTo: document.body,
  12. width: 400,
  13. height: 50
  14. });
  15. panel = Ext.create({
  16. xtype: 'panel',
  17. renderTo: document.body,
  18. items: {
  19. xtype: 'cartesian',
  20. width: 400,
  21. height: 400,
  22. store: {
  23. data: [
  24. {x: 0, y: 0},
  25. {x: 1, y: 2},
  26. {x: 2, y: 1},
  27. {x: 3, y: 3},
  28. {x: 4, y: 1}
  29. ]
  30. },
  31. interactions: {
  32. type: 'panzoom',
  33. zoomOnPanGesture: true
  34. },
  35. series: {
  36. type: 'line',
  37. xField: 'x',
  38. yField: 'y'
  39. },
  40. axes: [
  41. {
  42. type: 'numeric',
  43. position: 'bottom'
  44. },
  45. {
  46. type: 'numeric',
  47. position: 'left'
  48. }
  49. ]
  50. },
  51. listeners: {
  52. afterrender: function () {
  53. isAfterRender = true;
  54. }
  55. }
  56. });
  57. });
  58. waitsFor(function () {
  59. return isAfterRender;
  60. });
  61. runs(function () {
  62. var chart = Ext.first('cartesian');
  63. var panzoom = chart.getInteractions()[0];
  64. var button = panzoom.getModeToggleButton();
  65. toolbar.add(button);
  66. expect(button.getValue()).toBe('zoom');
  67. panzoom.setZoomOnPanGesture(false);
  68. expect(button.getValue()).toBe('pan');
  69. Ext.destroy(toolbar, panel);
  70. });
  71. });
  72. });
  73. });