Web Interface For Lite Argus Control modules
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
2.6 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*!
  2. * Ext JS Library 3.3.1
  3. * Copyright(c) 2006-2010 Sencha Inc.
  4. * licensing@sencha.com
  5. * http://www.sencha.com/license
  6. */
  7. Ext.ns('pivot');
  8. Ext.onReady(function() {
  9. var SaleRecord = Ext.data.Record.create([
  10. {name: 'person', type: 'string'},
  11. {name: 'product', type: 'string'},
  12. {name: 'city', type: 'string'},
  13. {name: 'state', type: 'string'},
  14. {name: 'month', type: 'int'},
  15. {name: 'quarter', type: 'int'},
  16. {name: 'year', type: 'int'},
  17. {name: 'quantity', type: 'int'},
  18. {name: 'value', type: 'int'}
  19. ]);
  20. var myStore = new Ext.data.Store({
  21. url: 'data.json',
  22. autoLoad: true,
  23. reader: new Ext.data.JsonReader({
  24. root: 'rows',
  25. idProperty: 'id'
  26. }, SaleRecord)
  27. });
  28. var pivotGrid = new Ext.grid.PivotGrid({
  29. store : myStore,
  30. aggregator: 'sum',
  31. measure : 'value',
  32. leftAxis: [{
  33. width: 60,
  34. dataIndex: 'product'
  35. }, {
  36. width: 80,
  37. dataIndex: 'city'
  38. }, {
  39. width: 120,
  40. dataIndex: 'person'
  41. }],
  42. topAxis: [{
  43. dataIndex: 'year'
  44. }, {
  45. dataIndex: 'quarter'
  46. }],
  47. region: 'center',
  48. margins: '5 5 5 0',
  49. });
  50. var configPanel = new pivot.ConfigPanel({
  51. width : 300,
  52. margins: '5 5 5 5',
  53. region: 'west',
  54. record: SaleRecord,
  55. measures: ['value', 'quantity'],
  56. aggregator: 'sum',
  57. leftAxisDimensions: [
  58. {field: 'product', width: 60, direction: 'ASC'},
  59. {field: 'city', width: 80, direction: 'ASC'},
  60. {field: 'person', width: 120, direction: 'ASC'}
  61. ],
  62. topAxisDimensions: [
  63. {field: 'year', direction: 'ASC'},
  64. {field: 'quarter', direction: 'ASC'}
  65. ],
  66. listeners: {
  67. update: function(config) {
  68. pivotGrid.leftAxis.setDimensions(config.leftDimensions);
  69. pivotGrid.topAxis.setDimensions(config.topDimensions);
  70. pivotGrid.setMeasure(config.measure);
  71. pivotGrid.setAggregator(config.aggregator);
  72. pivotGrid.view.refresh(true);
  73. }
  74. }
  75. });
  76. var viewport = new Ext.Viewport({
  77. layout: 'fit',
  78. items: {
  79. border: false,
  80. title : 'Ext JS Pivot Grid',
  81. layout: 'border',
  82. items : [
  83. configPanel,
  84. pivotGrid
  85. ]
  86. }
  87. });
  88. });