Skip to content

Commit

Permalink
Fix for referring specific svg (#2612)
Browse files Browse the repository at this point in the history
* Fix for referring specific svg

* Remove trailing space
  • Loading branch information
songyanho authored and mistercrunch committed Apr 30, 2017
1 parent ac3aba7 commit ef0c4be
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions superset/assets/visualizations/nvd3_vis.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ const BREAKPOINTS = {
small: 340,
};

const addTotalBarValues = function (chart, data, stacked) {
const svg = d3.select('svg');
const addTotalBarValues = function (svg, chart, data, stacked) {
const format = d3.format('.3s');
const countSeriesDisplayed = data.length;

Expand Down Expand Up @@ -123,6 +122,10 @@ function nvd3Vis(slice, payload) {
let row;

const drawGraph = function () {
let svg = d3.select(slice.selector).select('svg');
if (svg.empty()) {
svg = d3.select(slice.selector).append('svg');
}
switch (vizType) {
case 'line':
if (fd.show_brush) {
Expand Down Expand Up @@ -166,7 +169,7 @@ function nvd3Vis(slice, payload) {

if (fd.show_bar_value) {
setTimeout(function () {
addTotalBarValues(chart, payload.data, stacked);
addTotalBarValues(svg, chart, payload.data, stacked);
}, animationTime);
}
break;
Expand Down Expand Up @@ -196,7 +199,7 @@ function nvd3Vis(slice, payload) {
}
if (fd.show_bar_value) {
setTimeout(function () {
addTotalBarValues(chart, payload.data, stacked);
addTotalBarValues(svg, chart, payload.data, stacked);
}, animationTime);
}
if (!reduceXTicks) {
Expand Down Expand Up @@ -382,10 +385,6 @@ function nvd3Vis(slice, payload) {
chart.margin({ bottom: fd.bottom_margin });
}

let svg = d3.select(slice.selector).select('svg');
if (svg.empty()) {
svg = d3.select(slice.selector).append('svg');
}
if (vizType === 'dual_line') {
const yAxisFormatter1 = d3.format(fd.y_axis_format);
const yAxisFormatter2 = d3.format(fd.y_axis_2_format);
Expand Down

0 comments on commit ef0c4be

Please sign in to comment.