Line.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. xtype: 'chart',
  7. style: 'background:#fff',
  8. animate: true,
  9. store: store1,
  10. shadow: true,
  11. theme: 'Category1',
  12. legend: {
  13. position: 'right'
  14. },
  15. axes: [{
  16. type: 'Numeric',
  17. minimum: 0,
  18. position: 'left',
  19. fields: ['data1', 'data2', 'data3'],
  20. title: 'Number of Hits',
  21. minorTickSteps: 1,
  22. grid: {
  23. odd: {
  24. opacity: 1,
  25. fill: '#ddd',
  26. stroke: '#bbb',
  27. 'stroke-width': 0.5
  28. }
  29. }
  30. }, {
  31. type: 'Category',
  32. position: 'bottom',
  33. fields: ['name'],
  34. title: 'Month of the Year'
  35. }],
  36. series: [{
  37. type: 'line',
  38. highlight: {
  39. size: 7,
  40. radius: 7
  41. },
  42. axis: 'left',
  43. xField: 'name',
  44. yField: 'data1',
  45. markerConfig: {
  46. type: 'cross',
  47. size: 4,
  48. radius: 4,
  49. 'stroke-width': 0
  50. }
  51. }, {
  52. type: 'line',
  53. highlight: {
  54. size: 7,
  55. radius: 7
  56. },
  57. axis: 'left',
  58. smooth: true,
  59. xField: 'name',
  60. yField: 'data2',
  61. markerConfig: {
  62. type: 'circle',
  63. size: 4,
  64. radius: 4,
  65. 'stroke-width': 0
  66. }
  67. }, {
  68. type: 'line',
  69. highlight: {
  70. size: 7,
  71. radius: 7
  72. },
  73. axis: 'left',
  74. smooth: true,
  75. fill: true,
  76. xField: 'name',
  77. yField: 'data3',
  78. markerConfig: {
  79. type: 'circle',
  80. size: 4,
  81. radius: 4,
  82. 'stroke-width': 0
  83. }
  84. }]
  85. });
  86. var win = Ext.create('Ext.Window', {
  87. width: 800,
  88. height: 600,
  89. minHeight: 400,
  90. minWidth: 550,
  91. hidden: false,
  92. maximizable: true,
  93. title: 'Line Chart',
  94. renderTo: Ext.getBody(),
  95. layout: 'fit',
  96. tbar: [{
  97. text: 'Save Chart',
  98. handler: function() {
  99. Ext.MessageBox.confirm('Confirm Download', 'Would you like to download the chart as an image?', function(choice){
  100. if(choice == 'yes'){
  101. chart.save({
  102. type: 'image/png'
  103. });
  104. }
  105. });
  106. }
  107. }, {
  108. text: 'Reload Data',
  109. handler: function() {
  110. store1.loadData(generateData(8));
  111. }
  112. }],
  113. items: chart
  114. });
  115. });