From 98809cb3f4886f3e0ff33724342da73acce85bb0 Mon Sep 17 00:00:00 2001 From: BradBaker Date: Fri, 8 Jan 2016 12:12:26 -0800 Subject: [PATCH 1/2] Fix for 2-axis charts where it shrinks them a little bit --- panoramix/static/panoramix.js | 7 ------- panoramix/static/widgets/viz_nvd3.js | 9 ++++++++- 2 files changed, 8 insertions(+), 8 deletions(-) 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..51c91c934c7 100644 --- a/panoramix/static/widgets/viz_nvd3.js +++ b/panoramix/static/widgets/viz_nvd3.js @@ -33,7 +33,7 @@ function viz_nvd3(slice) { nv.addGraph(function() { if (viz_type === 'line') { if (viz.form_data.show_brush) { - chart = nv.models.lineWithFocusChart() + chart = nv.models.lineWithFocusChart(); //chart.lines2.xScale( d3.time.scale.utc()); chart.lines2.xScale(d3.time.scale.utc()); chart.x2Axis @@ -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; }); From 7e827da3b12cf8aadd524aa2a999ca6a2bd23760 Mon Sep 17 00:00:00 2001 From: bradmbaker Date: Fri, 8 Jan 2016 14:26:49 -0800 Subject: [PATCH 2/2] fixing indents --- panoramix/static/widgets/viz_nvd3.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/panoramix/static/widgets/viz_nvd3.js b/panoramix/static/widgets/viz_nvd3.js index 51c91c934c7..1bf63670a49 100644 --- a/panoramix/static/widgets/viz_nvd3.js +++ b/panoramix/static/widgets/viz_nvd3.js @@ -34,12 +34,12 @@ function viz_nvd3(slice) { 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.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() }