From 1b63b5b9ddd01793ef8200a16d7df8a6a4b3eb32 Mon Sep 17 00:00:00 2001 From: Aleksandar Jovanov Date: Fri, 22 Sep 2017 12:47:15 +0200 Subject: [PATCH] Fix filters not working --- ckanext/c3charts/fanstatic/charts.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ckanext/c3charts/fanstatic/charts.js b/ckanext/c3charts/fanstatic/charts.js index 0a62932..7e70257 100644 --- a/ckanext/c3charts/fanstatic/charts.js +++ b/ckanext/c3charts/fanstatic/charts.js @@ -11,8 +11,13 @@ this.ckan.views.c3charts = this.ckan.views.c3charts || {}; function initPlot(elementId, resource, resourceView) { + var filters = resourceView.filters || []; var queryParams = generateQueryParams(resource, {}); + jQuery.each(filters, function (field, values) { + queryParams.filters.push({type: 'term', field: field, term: values}); + }); + $.when( recline.Backend.Ckan.fetch(resource), recline.Backend.Ckan.query(queryParams, resource) @@ -44,12 +49,12 @@ this.ckan.views.c3charts = this.ckan.views.c3charts || {}; item: { onclick: function(id) {} }}; - + var labelX = resourceView.measure_unit_x; var labelY = resourceView.measure_unit_y; var positionX = 'outer-middle'; var positionY = 'outer-middle'; - + switch (chart_type) { case 'Pie Chart': chart_type = 'pie'; @@ -76,7 +81,7 @@ this.ckan.views.c3charts = this.ckan.views.c3charts || {}; if (!Array.isArray(key_fields)) { key_fields = [key_fields]; } - + if (resourceView.aggregate) { var remap_data = [], data_len, remap_data_len, aggregator, flag, tmp; @@ -317,4 +322,4 @@ this.ckan.views.c3charts = this.ckan.views.c3charts || {}; return query; } -})(this.ckan.views.c3charts, this.jQuery, this._); \ No newline at end of file +})(this.ckan.views.c3charts, this.jQuery, this._);