mirror of
https://github.com/apache/superset.git
synced 2026-06-07 16:49:17 +00:00
Merge pull request #102 from bradmbaker/brad_baker_adding_two_x_axis_rescaling_to_nvd3_file
Fix for 2-axis charts where it shrinks them a little bit
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user