Skip to content

Commit

Permalink
Merge pull request #102 from bradmbaker/brad_baker_adding_two_x_axis_…
Browse files Browse the repository at this point in the history
…rescaling_to_nvd3_file

Fix for 2-axis charts where it shrinks them a little bit
  • Loading branch information
mistercrunch committed Jan 8, 2016
2 parents 897d519 + 7e827da commit e36ebfe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
7 changes: 0 additions & 7 deletions panoramix/static/panoramix.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 14 additions & 7 deletions panoramix/static/widgets/viz_nvd3.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down Expand Up @@ -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;
});
Expand Down

0 comments on commit e36ebfe

Please sign in to comment.