diff --git a/cdm-tests/src/App.js b/cdm-tests/src/App.js index cece457..0a234ae 100644 --- a/cdm-tests/src/App.js +++ b/cdm-tests/src/App.js @@ -238,20 +238,26 @@ class App extends Component {

JSChart CDM Demo



-
+

- FIO Chart Dataset Selection: -

+ FIO Chart Dataset Selection: + +
+
-
+

- IOSTAT Chart Dataset Selection: -

+ IOSTAT Chart Dataset Selection: + +
+
-
+

- MPSTAT Chart Dataset Selection: -

+ MPSTAT Chart Dataset Selection: + +
+
); diff --git a/jschart/index.js b/jschart/index.js index 931b7ac..36d60e7 100644 --- a/jschart/index.js +++ b/jschart/index.js @@ -2813,8 +2813,13 @@ function build_chart(chart) { ); return; } - - var table = chart.dom.div.append("table"); + + var table = chart.dom.div.append("table") + .attr("class", "graphtable") + .style("max-width", chart.dimensions.viewport_width+"px") + .style("flex", "0.9 0.9 auto") + .style("width", 0) + .style("word-break", "break-all"); var row = table.append("tr") .classed("wrapper", true) @@ -2917,13 +2922,8 @@ function build_chart(chart) { .enter() .append("svg") .classed("svg", true) - .attr( - "width", - chart.dimensions.viewport_width + - chart.dimensions.margin.left + - chart.dimensions.margin.right - ) - .attr("height", get_svg_height(chart)); + .attr("viewBox", "0 0" + " " + (chart.dimensions.viewport_width + chart.dimensions.margin.left + + chart.dimensions.margin.right) + " " + (get_svg_height(chart) ) + ""); chart.chart.defs = chart.chart.svg.append("defs"); if (!chart.options.scatterplot) { @@ -3647,7 +3647,9 @@ function load_datasets(chart) { if (chart.datasets.all.length > chart.dataset_count) { console.log('Resizing SVG for chart "' + chart.chart_title + '".'); - chart.chart.svg.attr("height", get_svg_height(chart)); + chart.chart.svg.attr("height", get_svg_height(chart)) + .attr("viewBox", "0 0" + " " + (chart.dimensions.viewport_width + chart.dimensions.margin.left + + chart.dimensions.margin.right) + " " + (get_svg_height(chart)) + ""); console.log('...finished resizing SVG for chart "' + chart.chart_title + '".'); } @@ -3701,6 +3703,9 @@ exports.create_jschart = function( stacked = 0; } + d3.select('#'+location) + .style("display","flex") + // add an entry to the chart generating queue charts_queue.defer( generate_chart, @@ -3717,6 +3722,9 @@ exports.create_jschart = function( exports.finish_page = function () { // wait for initial chart generation to complete before logging that it is done and changing the page background // note: chart datasets may still be loading asynchronously + d3.selectAll(".svg") + .style("width",'100%') + .style("height","auto") charts_queue.await(function(error, results) { d3.select("body").classed("completedpage", true); console.log("Finished creating all charts"); @@ -5374,7 +5382,9 @@ function reset_chart(chart) { reset_axes_domains(chart); - chart.chart.svg.attr("height", get_svg_height(chart)); + chart.chart.svg.attr("height", get_svg_height(chart)) + .attr("viewBox", "0 0" + " " + (chart.dimensions.viewport_width + chart.dimensions.margin.left + + chart.dimensions.margin.right) + " " + (get_svg_height(chart)) + ""); chart.state.reset = true; } @@ -5385,7 +5395,7 @@ function get_svg_height(chart) { chart.dimensions.margin.bottom + ( Math.ceil(chart.datasets.all.length / chart.state.legend_columns) - 1 + chart.options.legend_entries.length - ) * chart.dimensions.legend_properties.row_height; + ) * chart.dimensions.legend_properties.row_height; } function reload_chart(chart) { diff --git a/tests/src/App.js b/tests/src/App.js index f17154a..4b7f42e 100644 --- a/tests/src/App.js +++ b/tests/src/App.js @@ -141,11 +141,13 @@ class App extends Component {

JSChart Demos



-
+

- Dynamic Chart Dataset Selection: -

-
+ Dynamic Chart Dataset Selection: + +
+
+