diff --git a/datalets/bar-chart-datalet/bar-chart-datalet.html b/datalets/bar-chart-datalet/bar-chart-datalet.html index 43a43c8..0d34c48 100755 --- a/datalets/bar-chart-datalet/bar-chart-datalet.html +++ b/datalets/bar-chart-datalet/bar-chart-datalet.html @@ -79,8 +79,8 @@ Example: text: this._component.title }, xAxis: { -// categories: this.properties.categories.value, - categories: ['Cinesi', 'Albanesi', 'Rumeni', 'Pakistani', 'Marocchini', 'Altri stranieri'], + categories: this.properties.categories.value, +// categories: ['Cinesi', 'Albanesi', 'Rumeni', 'Pakistani', 'Marocchini', 'Altri stranieri'], title: { text: this._component.xAxisLabel } @@ -104,6 +104,10 @@ Example: enabled: true } } +// +// series: { +// stacking: 'normal' +// } }, legend: { layout: 'vertical', @@ -119,23 +123,24 @@ Example: credits: { enabled: false }, -// series: this.properties.series.value - series: [{ - name: '2010', - data: [107, 31, 635, 203, 2] - }, { - name: '2011', - data: [1353, 156, 947, 408, 6] - }, { - name: '2012', - data: [133, 156, 947, 408, 64] - }, { - name: '2013', - data: [133, 156, 947, 48, 6] - }, { - name: '2014', - data: [1052, 954, 4250, 740, 38] - }] + + series: this.properties.series.value +// series: [{ +// name: '2010', +// data: [107, 31, 635, 203, 2] +// }, { +// name: '2011', +// data: [1353, 156, 947, 408, 6] +// }, { +// name: '2012', +// data: [133, 156, 947, 408, 64] +// }, { +// name: '2013', +// data: [133, 156, 947, 48, 6] +// }, { +// name: '2014', +// data: [1052, 954, 4250, 740, 38] +// }] }); diff --git a/datalets/base-ajax-json-alasql-datalet/static/js/AjaxJsonAlasqlBehavior.js b/datalets/base-ajax-json-alasql-datalet/static/js/AjaxJsonAlasqlBehavior.js index 3ef89c8..c8683ee 100755 --- a/datalets/base-ajax-json-alasql-datalet/static/js/AjaxJsonAlasqlBehavior.js +++ b/datalets/base-ajax-json-alasql-datalet/static/js/AjaxJsonAlasqlBehavior.js @@ -137,15 +137,34 @@ var AjaxJsonAlasqlBehavior = { orderBy = orderBy.slice(0, -2); } - //SELECT; + //SELECT var select = "SELECT "; for (var i = 0; i < fields.length; i++) - //select += fields[i] + ", "; select += fields[i] + " as " + this._fieldName(this._component.fields[i], "") + ", "; select = select.slice(0, -2); var pureSelect = select; + /**/ + var res = alasql("SELECT "+ path +" FROM ?", [jsonData]); + var records = res[0][path]; + var obj = alasql(pureSelect + " FROM ?", [records]); + //console.log(obj); + + var select = "SELECT "; + for (var i = 0; i < fields.length; i++) { + var key = Object.keys(obj[0])[i]; + var v = obj[0][key]; + if (!isNaN(v)) + select += fields[i] + "::NUMBER as " + this._fieldName(this._component.fields[i], "") + ", "; + else + select += fields[i] + " as " + this._fieldName(this._component.fields[i], "") + ", "; + } + select = select.slice(0, -2); + + var pureSelect = select; + /**/ + //GROUP BY var groupBy = ""; if(aggregators && aggregators.length) {