Add d3 for correct imports in nvd3 chart

This commit is contained in:
Dannon Baker
2018-02-11 14:34:40 -05:00
committed by guerler
parent 5848c991ca
commit 3329bf8907
2 changed files with 361 additions and 351 deletions
File diff suppressed because one or more lines are too long
@@ -1,6 +1,7 @@
/** This is the common wrapper for nvd3 based visualizations. */
import Utilities from "./utilities/tabular-utilities";
import * as nv from "nvd3";
import * as d3 from "d3";
//import "nvd3/build/nv.d3.css";
var CommonWrapper = Backbone.View.extend({
@@ -23,10 +24,16 @@ var CommonWrapper = Backbone.View.extend({
d3chart.xAxis.axisLabel(chart.settings.get("x_axis_label"));
d3chart.yAxis.axisLabel(chart.settings.get("y_axis_label")).axisLabelDistance(30);
d3chart.options({ showControls: false });
d3chart.showLegend && d3chart.showLegend(chart.settings.get("show_legend") == "true");
if (d3chart.showLegend) {
d3chart.showLegend(chart.settings.get("show_legend") == "true");
}
self._makeAxes(d3chart, groups, chart.settings);
makeConfig && makeConfig(d3chart);
chart.settings.get("__use_panels") === "true" && d3chart.options({ showControls: false });
if (makeConfig) {
makeConfig(d3chart);
}
if (chart.settings.get("__use_panels") === "true") {
d3chart.options({ showControls: false });
}
d3chart.xAxis.showMaxMin(false);
d3chart.yAxis.showMaxMin(chart.definition.showmaxmin);
d3chart.tooltipContent(function(key, x, y, graph) {
@@ -36,7 +43,9 @@ var CommonWrapper = Backbone.View.extend({
var canvas = d3.select("#" + canvas_id);
canvas.datum(groups).call(d3chart);
if (chart.definition.zoomable && chart.definition.zoomable != "native") {
d3chart.clipEdge && d3chart.clipEdge(true);
if (d3chart.clipEdge) {
d3chart.clipEdge(true);
}
Utilities.addZoom({
xAxis: d3chart.xAxis,
yAxis: d3chart.yAxis,
@@ -66,10 +75,11 @@ var CommonWrapper = Backbone.View.extend({
type: settings.get(id + "_axis_type|type"),
precision: settings.get(id + "_axis_type|precision"),
formatter: function(formatter) {
formatter &&
if (formatter) {
d3chart[id + "Axis"].tickFormat(function(value) {
return formatter(value);
});
}
}
});
}