Commit b0720b918c4a41f9653ddd9c5bb692a47c83d86a

Authored by Benjamin Renard
1 parent 738e0997

Finalize catalog histogram visualization + cleanup code (#6899)

js/app/controllers/CatalogModule.js
... ... @@ -3,27 +3,27 @@
3 3 * Name CatalogModule.js
4 4 * @class amdaDesktop.CatalogModule
5 5 * @extends amdaDesktop.InteractiveModule
6   - * @brief Catalog Module controller definition
  6 + * @brief Catalog Module controller definition
7 7 * @author elena
8 8 */
9 9  
10 10 Ext.define('amdaDesktop.CatalogModule', {
11 11 extend: 'amdaDesktop.InteractiveModule',
12   -
  12 +
13 13 requires: [
14 14 'amdaUI.CatalogUI',
15 15 'amdaUI.ShareObjectUI'
16 16 ],
17   -
  17 +
18 18 contentId : 'catalogUI',
19 19 isOperationOnShow : true,
20   -
  20 +
21 21 /**
22 22 * @cfg {String} data models
23 23 * @required
24 24 */
25 25 nodeDataModel : 'amdaModel.CatalogNode',
26   -
  26 +
27 27 /**
28 28 * @cfg {String} window definitions
29 29 * @required
... ... @@ -33,9 +33,9 @@ Ext.define('amdaDesktop.CatalogModule', {
33 33 uiType : 'panelCatalog',
34 34 helpTitle : 'Help on Catalog Module',
35 35 helpFile : 'catalogHelp',
36   -
  36 +
37 37 shareCatalog : function(catObj) {
38   - var win = myDesktopApp.desktop.getWindow('sharecat-win');
  38 + var win = myDesktopApp.desktop.getWindow('sharecat-win');
39 39 if(!win)
40 40 {
41 41 var me = this;
... ... @@ -54,7 +54,7 @@ Ext.define('amdaDesktop.CatalogModule', {
54 54 id : 'shareCatUI',
55 55 onAfterShareObject : function(folder_id, object_id) {
56 56 win.close();
57   - var explorerTree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID);
  57 + var explorerTree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID);
58 58 var sharedCatRootNode = explorerTree.getRootNode().findChild('id','sharedcatalog-treeRootNode',true);
59 59 amdaModel.InteractiveNode.preloadNodes(sharedCatRootNode, function() {
60 60 sharedCatRootNode.expand();
... ... @@ -72,20 +72,20 @@ Ext.define('amdaDesktop.CatalogModule', {
72 72 }
73 73 }
74 74 ]
75   - });
  75 + });
76 76 }
77   -
  77 +
78 78 var sharePanel = win.down('#shareCatUI');
79 79 if (sharePanel)
80 80 sharePanel.setProperties('catalog', catObj);
81   -
  81 +
82 82 AmdaAction.getObject(catObj.id, 'catalog', function(result,remoteEvent) {
83 83 if (result) {
84 84 if (result.description)
85 85 sharePanel.setDescription(result.description);
86   - }
  86 + }
87 87 }, this.getObjectCallback, this);
88   -
  88 +
89 89 win.show();
90 90 }
91 91  
... ...
js/app/controllers/VisuModule.js
... ... @@ -3,25 +3,25 @@
3 3 * Name VisuModule.js
4 4 * @class amdaDesktop.VisuModule
5 5 * @extends amdaDesktop.InteractiveModule
6   - * @brief Visualization Module controller definition
  6 + * @brief Visualization Module controller definition
7 7 * @author elena
8 8 */
9 9  
10 10 Ext.define('amdaDesktop.VisuModule', {
11 11 extend: 'amdaDesktop.InteractiveModule',
12   -
  12 +
13 13 requires: [
14 14 'amdaUI.VisuUI'
15 15 ],
16   -
  16 +
17 17 contentId : 'visuUI',
18   -
  18 +
19 19 /**
20 20 * @cfg {String} data models
21 21 * @required
22 22 */
23 23 nodeDataModel : 'amdaModel.CatalogNode', // 'amdaModel.MyDataNode'
24   -
  24 +
25 25 /**
26 26 * @cfg {String} window definitions
27 27 * @required
... ... @@ -30,6 +30,15 @@ Ext.define('amdaDesktop.VisuModule', {
30 30 height: 700,
31 31 uiType : 'panelVisu',
32 32 helpTitle : 'Help on Visualization Module',
33   - helpFile : 'visuHelp'
34   -
  33 + helpFile : 'visuHelp',
  34 +
  35 + visualize : function(catObj) {
  36 + var temporaryNode = Ext.create('amdaModel.CatalogNode', {leaf: true});
  37 + if (temporaryNode)
  38 + temporaryNode.set('object', catObj);
  39 + this.setLinkedNode(temporaryNode);
  40 +
  41 + this.createWindow();
  42 + }
  43 +
35 44 });
... ...
js/app/models/CatalogNode.js
... ... @@ -68,16 +68,52 @@ Ext.define('amdaModel.CatalogNode', {
68 68 });
69 69 },
70 70  
71   - visu : function(contextNode) {
72   - var me = this;
73   - myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.visu.id, true, function (module) {
  71 + visu : function(node) {
  72 + var me = this;
  73 +
  74 + var visuWinFunc = function(object) {
  75 + myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.visu.id, true, function (module) {
  76 + module.visualize(object);
  77 + });
  78 + };
  79 +
  80 + amdaModel.InteractiveNode.preloadNodes(this.getRootNode(),
  81 + function()
  82 + {
  83 + if (me.get('object')) {
  84 + visuWinFunc(me.get('object'));
  85 + }
  86 + else
  87 + {
  88 + AmdaAction.getObject(me.get('id'), me.get('nodeType'), function (result,remoteEvent) {
  89 + var t = remoteEvent.getTransaction();
  90 +
  91 + if (result) {
  92 + var paramObj = Ext.create(me.get('objectDataModel'), result);
  93 + // set parameter into node
  94 + me.set('object',paramObj);
  95 + // Edition of parameter into parameter Module
  96 + visuWinFunc(me.get('object'));
  97 + }
  98 + else {
  99 + myDesktopApp.errorMsg(t.action + "." + t.method + " : No catalog '"
  100 + + this.get('name') + "' found!");
  101 + }
  102 + }, me);
  103 + }
  104 + });
  105 +
  106 +
  107 + //var me = this;
  108 + //myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.visu.id, true, function (module) {
  109 + // module.visualize(me);
74 110 // Catalog & TimeTable nodes normally use no objects in the tree
75   - var obj = {'id' : me.get('id'), 'name' : me.get('text') };
  111 +/* var obj = {'id' : me.get('id'), 'name' : me.get('text') };
76 112 object = Ext.create(me.get('objectDataModel'), obj);
77 113 me.set('object',object);
78 114 module.setLinkedNode(me);
79   - module.createWindow();
80   - });
  115 + module.createWindow();*/
  116 + //});
81 117 },
82 118 generateTT: function(node){
83 119 var catObj = Ext.create('amdaModel.TimeTable');
... ...
js/app/views/CatalogUI.js
... ... @@ -93,7 +93,7 @@ Ext.define('amdaUI.CatalogUI', {
93 93 if (updateStatus) {
94 94 /// real object update
95 95 // update TimeTable object with the content of form
96   - basicForm.updateRecord(this.object.get('name'));
  96 + basicForm.updateRecord(this.object);
97 97 }
98 98 // return the update status
99 99 return updateStatus;
... ... @@ -1000,13 +1000,7 @@ Ext.define('amdaUI.CatalogUI', {
1000 1000 handler: function () {
1001 1001 var me = this;
1002 1002 myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.visu.id, true, function (module) {
1003   - //temporary linked node - as Visu module is 'pseudo' interactive - no 'save', no 'execute'
1004   - var temporaryNode = Ext.create('amdaModel.CatalogNode', {leaf: true});
1005   - if (temporaryNode)
1006   - temporaryNode.set('object', me.object);
1007   - module.setLinkedNode(temporaryNode);
1008   -
1009   - module.createWindow();
  1003 + module.visualize(me.object);
1010 1004 });
1011 1005 }
1012 1006 }
... ...
js/app/views/CatalogVisuHistogram.js
... ... @@ -17,10 +17,9 @@ Ext.define('amdaUI.CatalogVisuHistogram', {
17 17 this.callParent(arguments);
18 18 },
19 19  
20   - getChart: function(catalogStore) {
  20 + getChartConfig: function(catalogStore) {
21 21 var paramOpt = {
22 22 paramId: '',
23   - index: 0,
24 23 title: 'Parameter'
25 24 };
26 25  
... ... @@ -29,15 +28,14 @@ Ext.define('amdaUI.CatalogVisuHistogram', {
29 28 if (paramFieldId && (paramFieldId != "")) {
30 29 var paramField = paramField.getStore().getById(paramFieldId);
31 30 if (paramField) {
32   - paramOpt.paramId = paramField.get('paramId');
33   - paramOpt.index = paramField.get('index');
  31 + paramOpt.paramId = paramField.get('id');
34 32 paramOpt.title = paramField.get('name');
35   - if (paramField.get('size') > 1) {
36   - paramOpt.title += '['+opt.index+']';
37   - paramOpt.paramId += '_COMPONENT_'+opt.index;
38   - }
39 33 }
40 34 }
  35 + else {
  36 + myDesktopApp.errorMsg('Missing parameter selection');
  37 + return null;
  38 + }
41 39  
42 40 var paramTitleField = Ext.getCmp('visu-histo-title');
43 41 var paramTitle = paramTitleField.getValue();
... ... @@ -62,12 +60,20 @@ Ext.define('amdaUI.CatalogVisuHistogram', {
62 60 maxValue = (maxValue == null) ? item.get(paramOpt.paramId) : Math.max(maxValue, item.get(paramOpt.paramId));
63 61 });
64 62  
  63 + if (!minValue || !maxValue || (minValue == maxValue)) {
  64 + myDesktopApp.errorMsg('Not enought data or constant data');
  65 + return null;
  66 + }
  67 +
65 68 var binSize = (maxValue-minValue) / (nbBinsValue-1);
66 69 var data = [];
67 70 for (i = 0; i < nbBinsValue; ++i) {
  71 + var center = minValue + i * binSize;
68 72 data.push({
69   - center: minValue + i * binSize,
70   - count: 0
  73 + center: center,
  74 + min: center - binSize/2,
  75 + max: center + binSize/2,
  76 + count: 0
71 77 });
72 78 }
73 79  
... ... @@ -78,7 +84,7 @@ Ext.define(&#39;amdaUI.CatalogVisuHistogram&#39;, {
78 84  
79 85  
80 86 this.histogramStore = Ext.create('Ext.data.Store', {
81   - fields: ['center', 'count']
  87 + fields: ['center', 'min', 'max', 'count']
82 88 });
83 89 this.histogramStore.loadData(data);
84 90  
... ... @@ -99,7 +105,12 @@ Ext.define(&#39;amdaUI.CatalogVisuHistogram&#39;, {
99 105 type: 'Category',
100 106 position: 'bottom',
101 107 fields: ['center'],
102   - title: paramOpt.title
  108 + title: paramOpt.title,
  109 + label: {
  110 + renderer: function(value, label, storeItem, item, i, display, animate, index) {
  111 + return value.toFixed(2);
  112 + }
  113 + }
103 114 }],
104 115 series: [{
105 116 type: 'column',
... ... @@ -107,20 +118,19 @@ Ext.define(&#39;amdaUI.CatalogVisuHistogram&#39;, {
107 118 highlight: true,
108 119 gutter: 5,
109 120 xField: 'center',
110   - yField: 'count'/*,
  121 + yField: 'count',
111 122 tips: {
112   - width: 10,
113 123 height: 20,
114   - hideDelay: 100, //200 ms
  124 + hideDelay: 200,
115 125 mouseOffset: [0,0], //[15,18]
116 126 renderer: function(storeItem, item) {
117   - //this.setTitle(storeItem.index + 1);
  127 + this.setTitle('['+storeItem.get('min').toFixed(2)+', '+storeItem.get('max').toFixed(2)+']');
118 128 }
119   - }*/
  129 + }
120 130 }]
121 131 };
122 132  
123   - return Ext.create('Ext.chart.Chart', chartConfig);
  133 + return chartConfig;
124 134 },
125 135  
126 136 getHistoConfig: function(parametersStore) {
... ... @@ -130,19 +140,9 @@ Ext.define(&#39;amdaUI.CatalogVisuHistogram&#39;, {
130 140 editable: false,
131 141 store: parametersStore,
132 142 queryMode: 'local',
133   - displayField: 'text',
  143 + displayField: 'name',
134 144 valueField: 'id',
135   - id: 'visu-histo-param',
136   - tpl: Ext.create('Ext.XTemplate',
137   - '<tpl for=".">',
138   - '<div class="x-boundlist-item">{name}<tpl if="size &gt; 1">[{index}]</tpl></div>',
139   - '</tpl>'
140   - ),
141   - displayTpl: Ext.create('Ext.XTemplate',
142   - '<tpl for=".">',
143   - '{name}<tpl if="size &gt; 1">[{index}]</tpl>',
144   - '</tpl>'
145   - )
  145 + id: 'visu-histo-param'
146 146 };
147 147  
148 148 var sliderConfig = {
... ... @@ -162,7 +162,14 @@ Ext.define(&#39;amdaUI.CatalogVisuHistogram&#39;, {
162 162 increment: 1,
163 163 minValue: 2,
164 164 maxValue: 100,
165   - id: 'visu-histo-bin-slider'
  165 + id: 'visu-histo-bin-slider',
  166 + listeners: {
  167 + change: function ( slider, newValue, thumb, eOpts ) {
  168 + var binValueField = Ext.getCmp('visu-histo-bin-value');
  169 + binValueField.setValue(newValue);
  170 + },
  171 + scope: this
  172 + }
166 173 },
167 174 {
168 175 xtype: 'splitter'
... ... @@ -172,6 +179,7 @@ Ext.define(&#39;amdaUI.CatalogVisuHistogram&#39;, {
172 179 hideTrigger: true,
173 180 width: 50,
174 181 disabled: true,
  182 + value: 10,
175 183 id: 'visu-histo-bin-value'
176 184 }
177 185 ]
... ...
js/app/views/CatalogVisuScatter.js
... ... @@ -16,7 +16,7 @@ Ext.define(&#39;amdaUI.CatalogVisuScatter&#39;, {
16 16 this.callParent(arguments);
17 17 },
18 18  
19   - getChart: function(catalogStore) {
  19 + getChartConfig: function(catalogStore) {
20 20 var plotTypeField = Ext.getCmp('visu-scatter-type');
21 21 var plotType = plotTypeField.getValue();
22 22  
... ... @@ -26,6 +26,16 @@ Ext.define(&#39;amdaUI.CatalogVisuScatter&#39;, {
26 26 var xAxisOpt = this.getAxisOptions('X');
27 27 var yAxisOpt = this.getAxisOptions('Y');
28 28  
  29 + if ((!xAxisOpt.paramId) || (xAxisOpt.paramId == '')) {
  30 + myDesktopApp.errorMsg('Missing parameter selection for X axis');
  31 + return null;
  32 + }
  33 +
  34 + if ((!yAxisOpt.paramId) || (yAxisOpt.paramId == '')) {
  35 + myDesktopApp.errorMsg('Missing parameter selection for Y axis');
  36 + return null;
  37 + }
  38 +
29 39 var chartConfig = {
30 40 animate: false,
31 41 mask: false,
... ... @@ -55,12 +65,11 @@ Ext.define(&#39;amdaUI.CatalogVisuScatter&#39;, {
55 65 yField: yAxisOpt.paramId,
56 66 type: plotType,
57 67 tips: {
58   - width: 10,
59 68 height: 20,
60   - hideDelay: 100, //200 ms
61   - mouseOffset: [0,0], //[15,18]
  69 + hideDelay: 200,
  70 + mouseOffset: [0,0],
62 71 renderer: function(storeItem, item) {
63   - this.setTitle(storeItem.index + 1);
  72 + this.setTitle('['+storeItem.get('start').toISOString() + ', ' + storeItem.get('stop').toISOString() + ']');
64 73 }
65 74 }
66 75 }]
... ... @@ -76,13 +85,12 @@ Ext.define(&#39;amdaUI.CatalogVisuScatter&#39;, {
76 85 chartConfig.axes[1].maximum = yAxisOpt.range.max;
77 86 }
78 87  
79   - return Ext.create('Ext.chart.Chart', chartConfig);
  88 + return chartConfig;
80 89 },
81 90  
82 91 getAxisOptions: function(axisName) {
83 92 var opt = {
84 93 paramId: '',
85   - index: 0,
86 94 title: axisName+' axis'
87 95 };
88 96  
... ... @@ -91,13 +99,8 @@ Ext.define(&#39;amdaUI.CatalogVisuScatter&#39;, {
91 99 if (paramFieldId && (paramFieldId != "")) {
92 100 var paramField = axisParamField.getStore().getById(axisParamField.getValue());
93 101 if (paramField) {
94   - opt.paramId = paramField.get('paramId');
95   - opt.index = paramField.get('index');
  102 + opt.paramId = paramField.get('id');
96 103 opt.title = paramField.get('name');
97   - if (paramField.get('size') > 1) {
98   - opt.title += '['+opt.index+']';
99   - opt.paramId += '_COMPONENT_'+opt.index;
100   - }
101 104 }
102 105 }
103 106  
... ... @@ -129,20 +132,10 @@ Ext.define(&#39;amdaUI.CatalogVisuScatter&#39;, {
129 132 editable: false,
130 133 store: parametersStore,
131 134 queryMode: 'local',
132   - displayField: 'text',
  135 + displayField: 'name',
133 136 valueField: 'id',
134 137 axisIndex: axisIndex,
135   - id: 'visu-scatter-' + axisName + '-param',
136   - tpl: Ext.create('Ext.XTemplate',
137   - '<tpl for=".">',
138   - '<div class="x-boundlist-item">{name}<tpl if="size &gt; 1">[{index}]</tpl></div>',
139   - '</tpl>'
140   - ),
141   - displayTpl: Ext.create('Ext.XTemplate',
142   - '<tpl for=".">',
143   - '{name}<tpl if="size &gt; 1">[{index}]</tpl>',
144   - '</tpl>'
145   - )
  138 + id: 'visu-scatter-' + axisName + '-param'
146 139 };
147 140  
148 141 var comboRangeConfig = {
... ...
js/app/views/VisuUI.js
... ... @@ -20,47 +20,32 @@ Ext.define(&#39;amdaUI.VisuUI&#39;, {
20 20  
21 21 parametersStore: null,
22 22 catalogStore: null,
  23 + emptyChartConfig: null,
23 24  
24 25 constructor: function(config) {
25 26 this.init(config);
26 27 this.callParent(arguments);
27   - if (this.object) this.reformObject();
  28 + if (this.object)
  29 + this.loadObject();
28 30 },
29 31  
30 32 setObject : function (obj) {
31 33 this.object = obj;
32   - this.reformObject();
  34 + this.loadObject();
33 35 },
34 36  
35 37 updateObject : function () {
36 38 return true;
37 39 },
38 40  
39   - reformObject : function () {
40   - this.fromPlugin = this.object.get('fromPlugin');
41   -
42   - if (this.fromPlugin) {
43   - if (this.object.get('folderId') == '')
44   - this.object.set('id','cacheCat');
45   - else
46   - this.object.set('id',this.object.get('folderId'));
47   -
48   - this.object.set('objName',this.object.get('objName'));
49   - }
50   - else {
51   - this.object.set('id',this.object.get('id'));
52   - this.object.set('name',this.object.get('name'));
53   - }
54   - // load object into view
55   - if (this.object.get('id') != '')
56   - this.loadObject();
57   - },
58   -
59 41 reset : function() {
60 42 var tabPanel = Ext.getCmp('visu-tabpanel');
61   - Ext.each(tabPanel.activeTab.items.items[0].query('field'), function(field) {
62   - field.reset();
63   - });
  43 + Ext.Array.each(tabPanel.items.items, function(item) {
  44 + Ext.each(item.query('field'), function(field) {
  45 + field.reset();
  46 + });
  47 + });
  48 + this.replaceChart(null);
64 49 },
65 50  
66 51 /**
... ... @@ -70,14 +55,7 @@ Ext.define(&#39;amdaUI.VisuUI&#39;, {
70 55 {
71 56 var me = this;
72 57  
73   - this.parametersStore.removeAll();
74   - Ext.Array.each(this.object.get('parameters'), function(param) {
75   - for (index = 0; index < param.size; ++index) {
76   - me.parametersStore.add({'id': param.id + (param.size > 1 ? '_COMPONENT_'+index : ''), 'paramId': param.id, 'name' : param.name, 'index': index, 'size': param.size, 'type': param.type});
77   - }
78   - });
79   -
80   - var onAfterInit = function(result, e)
  58 + var onAfterInit = function(result, e)
81 59 {
82 60 if (!result) {
83 61 myDesktopApp.errorMsg(e.message);
... ... @@ -97,17 +75,24 @@ Ext.define(&#39;amdaUI.VisuUI&#39;, {
97 75 return;
98 76 }
99 77  
  78 + me.parametersStore.removeAll();
  79 + Ext.Array.each(result.parameters, function(param) {
  80 + if ((param.type == 0) || (param.type == 1) || (param.type == 3)) {
  81 + me.parametersStore.add(param);
  82 + }
  83 + });
  84 +
100 85 var dateConvert = function (value, rec) {
101 86 if (!Ext.isDate(value)) {
102 87 var valueString = new String(value);
103   - return new Date(valueString.replace(/\-/g, '\/').replace(/[T|Z]/g, ' '));
  88 + return new Date(valueString+'Z');
104 89 }
105 90 return value;
106 91 };
107 92  
108 93 var fieldsConfig = [];
109   - fieldsConfig.push({type: 'date', id: 'start', name : 'start', convert: dateConvert});
110   - fieldsConfig.push({type: 'date', id: 'stop', name : 'stop', convert: dateConvert});
  94 + fieldsConfig.push({type: 'date', id: 'start', name : 'start', dateFormat: 'Y-m-d\\TH:i:s', convert: dateConvert});
  95 + fieldsConfig.push({type: 'date', id: 'stop', name : 'stop', dateFormat: 'Y-m-d\\TH:i:s', convert: dateConvert});
111 96 me.parametersStore.each(function (param) {
112 97 switch (param.get('type')) {
113 98 case 0: //double
... ... @@ -125,8 +110,6 @@ Ext.define(&#39;amdaUI.VisuUI&#39;, {
125 110 convert: dateConvert
126 111 });
127 112 break;
128   - case 2: //string
129   - break;
130 113 case 3: //int
131 114 fieldsConfig.push({
132 115 type: 'int',
... ... @@ -141,14 +124,17 @@ Ext.define(&#39;amdaUI.VisuUI&#39;, {
141 124 fields : fieldsConfig
142 125 });
143 126 me.catalogStore.loadData(result.intervals);
  127 +
  128 + me.reset();
144 129 }
145 130  
146 131 var opt = {
147 132 'typeTT' : 'catalog', 'id' : this.object.get('id'),
148   - 'name' : this.object.get('objName')
  133 + 'name' : this.object.get('name')
149 134 };
150   - AmdaAction.readIntervalsForChart(opt, onAfterInit);
  135 +
151 136 this.formPanel.getForm().loadRecord(this.object);
  137 + AmdaAction.readIntervalsForChart(opt, onAfterInit);
152 138 },
153 139  
154 140 /**
... ... @@ -161,20 +147,29 @@ Ext.define(&#39;amdaUI.VisuUI&#39;, {
161 147 },
162 148  
163 149 plotChart : function () {
164   - var chart = Ext.getCmp('visu-chart');
165 150 var tabPanel = Ext.getCmp('visu-tabpanel');
  151 + var newChartConfig = tabPanel.activeTab.items.items[0].getChartConfig(this.catalogStore);
  152 + this.replaceChart(newChartConfig);
  153 + },
166 154  
  155 + replaceChart: function(newChartConfig) {
  156 + if (!newChartConfig) {
  157 + newChartConfig = this.emptyChartConfig;
  158 + }
  159 + var chart = Ext.getCmp('visu-chart');
167 160 var chartPanel = chart.up();
168 161 chartPanel.remove(chart);
169   - chartPanel.insert(tabPanel.activeTab.items.items[0].getChart(this.catalogStore));
170   - },
  162 + chartPanel.insert(Ext.create('Ext.chart.Chart', newChartConfig));
  163 + },
171 164  
172 165 saveChart : function() {
173 166 var chart = Ext.getCmp('visu-chart');
174   - chart.save({
175   - type: 'image/png',
176   - defaultUrl : window.location
177   - });
  167 + if (chart) {
  168 + chart.save({
  169 + type: 'image/png',
  170 + defaultUrl : window.location
  171 + });
  172 + }
178 173 },
179 174  
180 175 initChartTypes: function() {
... ... @@ -222,15 +217,24 @@ Ext.define(&#39;amdaUI.VisuUI&#39;, {
222 217 this.parametersStore = Ext.create('Ext.data.Store', {
223 218 fields: [
224 219 {name: 'id', type: 'string'},
225   - {name: 'paramId', type: 'string'},
226 220 {name: 'name', type: 'string'},
227   - {name: 'index', type: 'int'},
228   - {name: 'size', type: 'int'},
229 221 {name: 'type', type: 'int'}
230 222 ],
231 223 data: []
232 224 });
233 225  
  226 + this.emptyChartConfig = {
  227 + xtype: 'chart',
  228 + region: 'center',
  229 + store: this.catalogStore,
  230 + id: 'visu-chart',
  231 + animate: false,
  232 + mask: false,
  233 + shadow: false,
  234 + theme:'Blue',
  235 + background: { fill : "#fff" }
  236 + };
  237 +
234 238 this.formPanel = Ext.create('Ext.form.Panel', {
235 239 region: 'center',
236 240 layout: 'border',
... ... @@ -265,17 +269,7 @@ Ext.define(&#39;amdaUI.VisuUI&#39;, {
265 269 // height: 400,
266 270 id: 'visu-tabpanel'
267 271 },
268   - {
269   - xtype: 'chart',
270   - region: 'center',
271   - store: this.catalogStore,
272   - id: 'visu-chart',
273   - animate: false,
274   - mask: false,
275   - shadow: false,
276   - theme:'Blue',
277   - background: { fill : "#fff" }
278   - }
  272 + this.emptyChartConfig
279 273 ]
280 274 }
281 275 ],
... ...
php/classes/AmdaAction.php
... ... @@ -1132,17 +1132,6 @@ class AmdaAction
1132 1132 return $cacheMgr->initFromTimeTable($id, $nparams);
1133 1133 }
1134 1134  
1135   -
1136   - public function initForChart($id, $folderId, $name, $isTmpObject, $type)
1137   - {
1138   - if ($isTmpObject && $type == 'catalog' && $id == 'cacheCat')
1139   - return array('success' => true, 'cache' => $id);
1140   -
1141   - if ($type == 'catalog' || $type == 'sharedcatalog') $objMgr = new CatalogMgr();
1142   -
1143   - return $objMgr->initForChart($id, $folderId, $name, $isTmpObject, $type);
1144   - }
1145   -
1146 1135 public function initObjectCacheFromTmpObject($folderId, $name, $isCatalog = false)
1147 1136 {
1148 1137 if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr();
... ... @@ -1169,6 +1158,7 @@ class AmdaAction
1169 1158 public function readIntervalsForChart($o)
1170 1159 {
1171 1160 $objMgr = new CatalogCacheMgr(TRUE);
  1161 + $objMgr->initFromObject($o->id, $o->type);
1172 1162 return $objMgr->getIntervalsForChart();
1173 1163 }
1174 1164  
... ...
php/classes/CatalogCacheIntervalObject.php
... ... @@ -19,7 +19,6 @@ class CatalogCacheIntervalObject extends TimeTableCacheIntervalObject
19 19 // for catalog
20 20 public function setParamValue($param_id, $param_value)
21 21 {
22   - error_log($param_value);
23 22 $this->params[$param_id] = $param_value;
24 23 }
25 24  
... ...
php/classes/CatalogCacheMgr.php
... ... @@ -103,14 +103,27 @@ class CatalogCacheMgr extends TimeTableCacheMgr
103 103  
104 104 $parameters = $this->cache->getParametersInfo();
105 105 $parameters_to_split = array();
  106 + $parameters_chart = array();
106 107 foreach ($parameters as $parameter) {
107 108 if ($parameter['size'] > 1) {
108 109 $parameters_to_split[] = $parameter;
  110 + for ($i = 0; $i < $parameter['size']; ++$i) {
  111 + $comp_param = $parameter;
  112 + $comp_param['id'] = $parameter['id'].'_COMPONENT_'.$i;
  113 + $comp_param['name'] = $parameter['name'].'['.$i.']';
  114 + unset ($comp_param['size']);
  115 + $parameters_chart[] = $comp_param;
  116 + }
  117 + }
  118 + else {
  119 + $comp_param = $parameter;
  120 + unset ($comp_param['size']);
  121 + $parameters_chart[] = $comp_param;
109 122 }
110 123 }
111 124  
112 125 if (empty($parameters_to_split)) {
113   - return $result;
  126 + return $result + array('parameters' => $parameters_chart);
114 127 }
115 128  
116 129 //split parameters
... ... @@ -124,7 +137,7 @@ class CatalogCacheMgr extends TimeTableCacheMgr
124 137 }
125 138 }
126 139  
127   - return $result;
  140 + return $result + array('parameters' => $parameters_chart);
128 141 }
129 142 }
130 143 ?>
... ...
php/classes/CatalogMgr.php
... ... @@ -101,93 +101,6 @@ class CatalogMgr extends TimeTableMgr
101 101  
102 102 }
103 103  
104   - public function initForChart($id, $folderId, $name, $isTmpObject, $type)
105   - {
106   - if ($isTmpObject)
107   - $options = array(
108   - 'name' => $name,
109   - 'folder' => empty($folderId) ? USERTEMPDIR : USERWORKINGDIR.$folderId,
110   - 'type' => $type,
111   - );
112   - else
113   - $options = array(
114   - 'id' => $id,
115   - 'type' => $type,
116   - );
117   -
118   - $intervals_res = $this->getCatalogParamDescription($options);
119   -
120   - if (!$intervals_res['success'])
121   - return $intervals_res;
122   -
123   - $paramHeaders = array();
124   -
125   - foreach ( $intervals_res['parameters'] as $param ) {
126   -
127   - if ($param['size'] > 1) {
128   -
129   - for ($i = 0; $i < $param['size']; $i++) {
130   - $paramComp = array();
131   - $paramComp['id'] = $param['id'].'_'.$i;
132   - $paramComp['name'] = $param['name'].'_'.$i;
133   - // $paramComp['size'] = 1;
134   -
135   - $paramHeaders[] = $paramComp;
136   - }
137   - }
138   - else {
139   - $paramHeaders[] = $param;
140   - }
141   - }
142   -
143   - // unset($intervals_res);
144   -
145   - return array('success' => true, 'parameters' => $paramHeaders,
146   - 'totalCount' => $intervals_res['totalCount'], 'name' => $intervals_res['name']);
147   - }
148   -
149   -
150   - public function getIntervalsForChart($id, $name, $isTmpObject, $type) {
151   -
152   - if ($isTmpObject)
153   - $intervals_res = $this->getTmpObject($id, $name);
154   - else
155   - $intervals_res = $this->loadIntervalsFromObject($id,$type);
156   -
157   - if (!$intervals_res['success'])
158   - return $intervals_res;
159   -
160   -
161   - $newIntervals = array();
162   -
163   - foreach ($intervals_res['intervals'] as $interval)
164   - {
165   - $newIntervalComp = array();
166   - $k = 0;
167   -
168   - for ( $j = 0; $j < count($interval['paramTable']); $j++ ) {
169   -
170   - $param = $interval['paramTable'][$j];
171   - $tempArr = explode(',',$param);
172   -
173   - if (count($tempArr) > 1) {
174   - for ($i = 0; $i < count($tempArr); $i++) {
175   - $newIntervalComp['param'.$k] = $tempArr[$i];
176   - $k++;
177   - }
178   - }
179   - else {
180   - $newIntervalComp['param'.$k] = $param;
181   - $k++;
182   - }
183   - }
184   - $newIntervals[] = $newIntervalComp;
185   - }
186   -
187   - return array('success' => true, 'intervals' => $newIntervals);
188   -
189   - }
190   -
191 104 public function getCatalogParamDescription($options)
192 105 {
193 106 if (!empty($options['id'])) {
... ...