Commit 5bc002a2689f6f7fd9e937cad0dd94e4565c8860
1 parent
8afea66c
datalet refactoring
Showing
10 changed files
with
27 additions
and
12 deletions
datalets/barchart-datalet/barchart-datalet.html
| @@ -49,7 +49,7 @@ Example: | @@ -49,7 +49,7 @@ Example: | ||
| 49 | * | 49 | * |
| 50 | * @method transformData | 50 | * @method transformData |
| 51 | */ | 51 | */ |
| 52 | - transformData: function(){ | 52 | + presentData: function(){ |
| 53 | 53 | ||
| 54 | $(this._component.$.charts.$.container).highcharts({ | 54 | $(this._component.$.charts.$.container).highcharts({ |
| 55 | chart: { | 55 | chart: { |
datalets/base-ajax-json-jsonpath-datalet/static/js/AjaxJsonJsonPathBehavior.js
| @@ -62,11 +62,10 @@ var AjaxJsonJsonPathBehavior = { | @@ -62,11 +62,10 @@ var AjaxJsonJsonPathBehavior = { | ||
| 62 | */ | 62 | */ |
| 63 | handleResponse: function(e) { | 63 | handleResponse: function(e) { |
| 64 | this.properties.json_results.value = e; | 64 | this.properties.json_results.value = e; |
| 65 | - this.createDataObject(); | ||
| 66 | this.runWorkcycle(); | 65 | this.runWorkcycle(); |
| 67 | }, | 66 | }, |
| 68 | 67 | ||
| 69 | - createDataObject : function(){ | 68 | + selectData : function(){ |
| 70 | 69 | ||
| 71 | this.data = []; | 70 | this.data = []; |
| 72 | this._component.fields = JSON.parse(this._component.fields); | 71 | this._component.fields = JSON.parse(this._component.fields); |
datalets/base-datalet/static/js/BaseDataletBehaviors.js
| @@ -80,7 +80,6 @@ var WorkcycleBehavior = { | @@ -80,7 +80,6 @@ var WorkcycleBehavior = { | ||
| 80 | * @method requestData | 80 | * @method requestData |
| 81 | */ | 81 | */ |
| 82 | requestData: function(){ | 82 | requestData: function(){ |
| 83 | - | ||
| 84 | }, | 83 | }, |
| 85 | 84 | ||
| 86 | /** | 85 | /** |
| @@ -110,6 +109,15 @@ var WorkcycleBehavior = { | @@ -110,6 +109,15 @@ var WorkcycleBehavior = { | ||
| 110 | }, | 109 | }, |
| 111 | 110 | ||
| 112 | /** | 111 | /** |
| 112 | + * Build the object/s for presentation layer. | ||
| 113 | + * | ||
| 114 | + * @method presentData | ||
| 115 | + */ | ||
| 116 | + presentData: function(){ | ||
| 117 | + | ||
| 118 | + }, | ||
| 119 | + | ||
| 120 | + /** | ||
| 113 | * Called when iron-ajax component receive the json data from called url. It is responsible to | 121 | * Called when iron-ajax component receive the json data from called url. It is responsible to |
| 114 | * extract data from response, coded in json, and refine it by using JsonPath queries in the query attribute. | 122 | * extract data from response, coded in json, and refine it by using JsonPath queries in the query attribute. |
| 115 | * After this phase it parses the resulting object to populate the structure(keys,values) to fill the final table by using | 123 | * After this phase it parses the resulting object to populate the structure(keys,values) to fill the final table by using |
| @@ -121,6 +129,7 @@ var WorkcycleBehavior = { | @@ -121,6 +129,7 @@ var WorkcycleBehavior = { | ||
| 121 | this.selectData(); | 129 | this.selectData(); |
| 122 | this.filterData(); | 130 | this.filterData(); |
| 123 | this.transformData(); | 131 | this.transformData(); |
| 132 | + this.presentData(); | ||
| 124 | }, | 133 | }, |
| 125 | 134 | ||
| 126 | init: function(component){ | 135 | init: function(component){ |
datalets/column3Dchart-datalet/column3Dchart-datalet.html
| @@ -61,7 +61,7 @@ Example: | @@ -61,7 +61,7 @@ Example: | ||
| 61 | * | 61 | * |
| 62 | * @method transformData | 62 | * @method transformData |
| 63 | */ | 63 | */ |
| 64 | - transformData: function(){ | 64 | + presentData: function(){ |
| 65 | chart = new Highcharts.Chart({ | 65 | chart = new Highcharts.Chart({ |
| 66 | chart: { | 66 | chart: { |
| 67 | renderTo: this._component.$.charts.$.container, | 67 | renderTo: this._component.$.charts.$.container, |
datalets/columnchart-datalet/columnchart-datalet.html
| @@ -49,7 +49,7 @@ Example: | @@ -49,7 +49,7 @@ Example: | ||
| 49 | * | 49 | * |
| 50 | * @method transformData | 50 | * @method transformData |
| 51 | */ | 51 | */ |
| 52 | - transformData: function(){ | 52 | + presentData: function(){ |
| 53 | $(this._component.$.charts.$.container).highcharts({ | 53 | $(this._component.$.charts.$.container).highcharts({ |
| 54 | chart: { | 54 | chart: { |
| 55 | type: 'column', | 55 | type: 'column', |
datalets/datatable-datalet/datatable-datalet.html
| @@ -32,7 +32,7 @@ Example | @@ -32,7 +32,7 @@ Example | ||
| 32 | <script> | 32 | <script> |
| 33 | var DatatableBehavior = { | 33 | var DatatableBehavior = { |
| 34 | 34 | ||
| 35 | - transformData: function(){ | 35 | + presentData: function(){ |
| 36 | if(!this.data || this.data == undefined) return; | 36 | if(!this.data || this.data == undefined) return; |
| 37 | html = ""; | 37 | html = ""; |
| 38 | html += '<thead>'+ | 38 | html += '<thead>'+ |
datalets/highcharts-datalet/highcharts-datalet.html
datalets/leafletjs-datalet/leafletjs-datalet.html
| @@ -60,7 +60,7 @@ Example: | @@ -60,7 +60,7 @@ Example: | ||
| 60 | * | 60 | * |
| 61 | * @method transformData | 61 | * @method transformData |
| 62 | */ | 62 | */ |
| 63 | - transformData: function(){ | 63 | + presentData: function(){ |
| 64 | 64 | ||
| 65 | var coordinates = []; | 65 | var coordinates = []; |
| 66 | //var keys = Object.keys(this.properties.data.value[0]); | 66 | //var keys = Object.keys(this.properties.data.value[0]); |
datalets/linechart-datalet/linechart-datalet.html
| @@ -49,7 +49,7 @@ Example: | @@ -49,7 +49,7 @@ Example: | ||
| 49 | * | 49 | * |
| 50 | * @method transformData | 50 | * @method transformData |
| 51 | */ | 51 | */ |
| 52 | - transformData: function(){ | 52 | + presentData: function(){ |
| 53 | 53 | ||
| 54 | $(this._component.$.charts.$.container).highcharts({ | 54 | $(this._component.$.charts.$.container).highcharts({ |
| 55 | title: { | 55 | title: { |
datalets/treemap-datalet/treemap-datalet.html
| @@ -88,11 +88,13 @@ THE SOFTWARE. | @@ -88,11 +88,13 @@ THE SOFTWARE. | ||
| 88 | <script> | 88 | <script> |
| 89 | 89 | ||
| 90 | var TreemapBehavior = { | 90 | var TreemapBehavior = { |
| 91 | + | ||
| 91 | map : { | 92 | map : { |
| 92 | name : "Expenses", | 93 | name : "Expenses", |
| 93 | children : [] | 94 | children : [] |
| 94 | }, | 95 | }, |
| 95 | - selectData: function(e) | 96 | + |
| 97 | + transformData: function(e) | ||
| 96 | { | 98 | { |
| 97 | var treemapData = []; | 99 | var treemapData = []; |
| 98 | 100 | ||
| @@ -117,8 +119,11 @@ THE SOFTWARE. | @@ -117,8 +119,11 @@ THE SOFTWARE. | ||
| 117 | for(var i = 0; i < treemapData.length; i++){ | 119 | for(var i = 0; i < treemapData.length; i++){ |
| 118 | this.checkAggragationField(treemapData[i], this._component.fields.length , this._component.fields.length - 1); | 120 | this.checkAggragationField(treemapData[i], this._component.fields.length , this._component.fields.length - 1); |
| 119 | } | 121 | } |
| 122 | + | ||
| 120 | var json = JSON.stringify(this.map); | 123 | var json = JSON.stringify(this.map); |
| 124 | + | ||
| 121 | }, | 125 | }, |
| 126 | + | ||
| 122 | findChild: function(child, category){ | 127 | findChild: function(child, category){ |
| 123 | var children = child.children; | 128 | var children = child.children; |
| 124 | for (var i=0; i<children.length; i++) { | 129 | for (var i=0; i<children.length; i++) { |
| @@ -129,6 +134,7 @@ THE SOFTWARE. | @@ -129,6 +134,7 @@ THE SOFTWARE. | ||
| 129 | children.push(nchild); | 134 | children.push(nchild); |
| 130 | return nchild; | 135 | return nchild; |
| 131 | }, | 136 | }, |
| 137 | + | ||
| 132 | checkAggragationField: function(object, levels, value_index){ | 138 | checkAggragationField: function(object, levels, value_index){ |
| 133 | var curchild = this.map; | 139 | var curchild = this.map; |
| 134 | var keys = Object.keys(object); | 140 | var keys = Object.keys(object); |
| @@ -145,7 +151,8 @@ THE SOFTWARE. | @@ -145,7 +151,8 @@ THE SOFTWARE. | ||
| 145 | curchild.children = null; | 151 | curchild.children = null; |
| 146 | curchild.value = value; | 152 | curchild.value = value; |
| 147 | }, | 153 | }, |
| 148 | - transformData: function(){ | 154 | + |
| 155 | + presentData: function(){ | ||
| 149 | build(this.map, "treemap_placeholder"); | 156 | build(this.map, "treemap_placeholder"); |
| 150 | } | 157 | } |
| 151 | }; | 158 | }; |