Mixed.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. Ext.require('Ext.chart.*');
  2. Ext.require(['Ext.Window', 'Ext.fx.target.Sprite', 'Ext.layout.container.Fit', 'Ext.window.MessageBox']);
  3. Ext.onReady(function () {
  4. store1.loadData(generateData(8));
  5. var chart = Ext.create('Ext.chart.Chart', {
  6. id: 'chartCmp',
  7. xtype: 'chart',
  8. style: 'background:#fff',
  9. animate: true,
  10. theme: 'Category1',
  11. store: store1,
  12. axes: [{
  13. type: 'Numeric',
  14. position: 'left',
  15. fields: ['data1', 'data2', 'data3'],
  16. title: 'Number of Hits',
  17. grid: true
  18. }, {
  19. type: 'Category',
  20. position: 'bottom',
  21. fields: ['name'],
  22. title: 'Month of the Year'
  23. }],
  24. series: [{
  25. type: 'column',
  26. axis: 'left',
  27. xField: 'name',
  28. yField: 'data1',
  29. markerConfig: {
  30. type: 'cross',
  31. size: 3
  32. }
  33. }, {
  34. type: 'scatter',
  35. axis: 'left',
  36. xField: 'name',
  37. yField: 'data2',
  38. markerConfig: {
  39. type: 'circle',
  40. size: 5
  41. }
  42. }, {
  43. type: 'line',
  44. axis: 'left',
  45. smooth: true,
  46. fill: true,
  47. fillOpacity: 0.5,
  48. xField: 'name',
  49. yField: 'data3'
  50. }]
  51. });
  52. var win = Ext.create('Ext.Window', {
  53. width: 800,
  54. height: 600,
  55. minHeight: 400,
  56. minWidth: 550,
  57. hidden: false,
  58. maximizable: true,
  59. title: 'Mixed Charts',
  60. renderTo: Ext.getBody(),
  61. layout: 'fit',
  62. tbar: [{
  63. text: 'Save Chart',
  64. handler: function() {
  65. Ext.MessageBox.confirm('Confirm Download', 'Would you like to download the chart as an image?', function(choice){
  66. if(choice == 'yes'){
  67. chart.save({
  68. type: 'image/png'
  69. });
  70. }
  71. });
  72. }
  73. }, {
  74. text: 'Reload Data',
  75. handler: function() {
  76. store1.loadData(generateData(8));
  77. }
  78. }, {
  79. enableToggle: true,
  80. pressed: true,
  81. text: 'Animate',
  82. toggleHandler: function(btn, pressed) {
  83. var chart = Ext.getCmp('chartCmp');
  84. chart.animate = pressed ? { easing: 'ease', duration: 500 } : false;
  85. }
  86. }],
  87. items: chart
  88. });
  89. });