From 691c4c611269d75c63f2a4ca0d83af45ce4bcf7f Mon Sep 17 00:00:00 2001 From: Aleksandar Jovanov Date: Thu, 22 Dec 2016 11:56:46 +0100 Subject: [PATCH] Use width and height for chart --- ckanext/c3charts/fanstatic/charts.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ckanext/c3charts/fanstatic/charts.js b/ckanext/c3charts/fanstatic/charts.js index 909e418..61c22bb 100644 --- a/ckanext/c3charts/fanstatic/charts.js +++ b/ckanext/c3charts/fanstatic/charts.js @@ -136,8 +136,16 @@ this.ckan.views.c3charts = this.ckan.views.c3charts || {}; data = remap_data; key_fields = remap_key_fields; } + + var chartContainer = $(elementId).parent(); + var width = chartContainer.attr('data-graph_width'); + var height = chartContainer.attr('data-graph_height'); return { + size: { + width: Number(width), + height: Number(height) + }, bindto: elementId, data: { json: data, @@ -309,4 +317,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._);