Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for referring specific svg #2612

Merged
merged 4 commits into from
Apr 30, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions superset/assets/visualizations/nvd3_vis.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ const timeStampFormats = TIME_STAMP_OPTIONS.map(opt => opt[0]);
const minBarWidth = 15;
const animationTime = 1000;

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 @@ -118,6 +117,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 @@ -161,7 +164,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 @@ -191,7 +194,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 @@ -372,11 +375,7 @@ function nvd3Vis(slice, payload) {
} else {
chart.margin({ bottom: fd.bottom_margin });
}

let svg = d3.select(slice.selector).select('svg');
if (svg.empty()) {
svg = d3.select(slice.selector).append('svg');
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codeclimate is complaining about "Trailing spaces not allowed"

if (vizType === 'dual_line') {
const yAxisFormatter1 = d3.format(fd.y_axis_format);
const yAxisFormatter2 = d3.format(fd.y_axis_2_format);
Expand Down