Radar.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. var chart = Ext.create('Ext.chart.Chart', {
  5. id: 'chartCmp',
  6. xtype: 'chart',
  7. style: 'background:#fff',
  8. theme: 'Category2',
  9. animate: true,
  10. store: store1,
  11. insetPadding: 20,
  12. legend: {
  13. position: 'right'
  14. },
  15. axes: [{
  16. type: 'Radial',
  17. position: 'radial',
  18. label: {
  19. display: true
  20. }
  21. }],
  22. series: [{
  23. type: 'radar',
  24. xField: 'name',
  25. yField: 'data1',
  26. showInLegend: true,
  27. showMarkers: true,
  28. markerConfig: {
  29. radius: 5,
  30. size: 5
  31. },
  32. style: {
  33. 'stroke-width': 2,
  34. fill: 'none'
  35. }
  36. },{
  37. type: 'radar',
  38. xField: 'name',
  39. yField: 'data2',
  40. showInLegend: true,
  41. showMarkers: true,
  42. markerConfig: {
  43. radius: 5,
  44. size: 5
  45. },
  46. style: {
  47. 'stroke-width': 2,
  48. fill: 'none'
  49. }
  50. },{
  51. type: 'radar',
  52. xField: 'name',
  53. yField: 'data3',
  54. showMarkers: true,
  55. showInLegend: true,
  56. markerConfig: {
  57. radius: 5,
  58. size: 5
  59. },
  60. style: {
  61. 'stroke-width': 2,
  62. fill: 'none'
  63. }
  64. }]
  65. });
  66. var win = Ext.create('Ext.Window', {
  67. width: 800,
  68. height: 600,
  69. minHeight: 400,
  70. minWidth: 550,
  71. hidden: false,
  72. shadow: false,
  73. maximizable: true,
  74. style: 'overflow: hidden;',
  75. title: 'Radar Chart',
  76. renderTo: Ext.getBody(),
  77. layout: 'fit',
  78. tbar: [{
  79. text: 'Save Chart',
  80. handler: function() {
  81. Ext.MessageBox.confirm('Confirm Download', 'Would you like to download the chart as an image?', function(choice){
  82. if(choice == 'yes'){
  83. chart.save({
  84. type: 'image/png'
  85. });
  86. }
  87. });
  88. }
  89. }, {
  90. text: 'Reload Data',
  91. handler: function() {
  92. store1.loadData(generateData());
  93. }
  94. }, {
  95. enableToggle: true,
  96. pressed: true,
  97. text: 'Animate',
  98. toggleHandler: function(btn, pressed) {
  99. var chart = Ext.getCmp('chartCmp');
  100. chart.animate = pressed ? { easing: 'ease', duration: 500 } : false;
  101. }
  102. }],
  103. items: chart
  104. });
  105. });