diff --git a/panoramix/static/panoramix.js b/panoramix/static/panoramix.js index 43bfaddbe6a..17598acc564 100644 --- a/panoramix/static/panoramix.js +++ b/panoramix/static/panoramix.js @@ -327,13 +327,6 @@ var px = (function() { current_col = $(this).attr('data-col'); $( this ).css('z-index', 100 - current_col); }); - - // this makes the whole chart fit within the dashboard div - $(".slice_container > svg").each(function(index){ - w = $( this ).width(); - h = $( this ).height(); - $( this ).get(0).setAttribute('viewBox', '0 0 '+w+' '+(h+30)); - }); } // Export public functions diff --git a/panoramix/static/widgets/viz_nvd3.js b/panoramix/static/widgets/viz_nvd3.js index 42cef7c387d..1bf63670a49 100644 --- a/panoramix/static/widgets/viz_nvd3.js +++ b/panoramix/static/widgets/viz_nvd3.js @@ -33,13 +33,13 @@ function viz_nvd3(slice) { nv.addGraph(function() { if (viz_type === 'line') { if (viz.form_data.show_brush) { - chart = nv.models.lineWithFocusChart() - //chart.lines2.xScale( d3.time.scale.utc()); - chart.lines2.xScale(d3.time.scale.utc()); - chart.x2Axis - .showMaxMin(viz.form_data.x_axis_showminmax) - .tickFormat(formatDate) - .staggerLabels(true); + chart = nv.models.lineWithFocusChart(); + //chart.lines2.xScale( d3.time.scale.utc()); + chart.lines2.xScale(d3.time.scale.utc()); + chart.x2Axis + .showMaxMin(viz.form_data.x_axis_showminmax) + .tickFormat(formatDate) + .staggerLabels(true); } else { chart = nv.models.lineChart() } @@ -167,6 +167,13 @@ function viz_nvd3(slice) { .datum(data.chart_data) .transition().duration(500) .call(chart); + // if it is a two axis chart, rescale it down just a little so it fits in the div. + if(chart.hasOwnProperty("x2Axis")) { + two_axis_chart = $(slice.selector + " > svg"); + w = two_axis_chart.width(); + h = two_axis_chart.height(); + two_axis_chart.get(0).setAttribute('viewBox', '0 0 '+w+' '+(h+30)); + } return chart; });