Skip to content
This repository was archived by the owner on Jun 25, 2020. It is now read-only.

Commit 67544e3

Browse files
committed
respecting D3 Format column for a handful of NVD3 charts
1 parent 60c41d1 commit 67544e3

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

packages/superset-ui-legacy-preset-chart-nvd3/src/transformProps.js

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,26 +59,50 @@ export default function transformProps(chartProps) {
5959
xAxisFormat,
6060
xAxisLabel,
6161
xAxisShowminmax,
62-
numberFormat,
6362
xLogScale,
6463
xTicksLayout,
6564
y,
66-
yAxisFormat,
67-
yAxis2Format,
6865
yAxisBounds,
6966
yAxisLabel,
7067
yAxisShowminmax,
7168
yLogScale,
7269
} = formData;
7370

71+
let {
72+
numberFormat,
73+
yAxisFormat,
74+
yAxis2Format,
75+
} = formData;
76+
7477
const rawData = queryData.data || [];
7578
const data = Array.isArray(rawData)
7679
? rawData.map(row => ({
7780
...row,
7881
key: formatLabel(row.key, datasource.verboseMap),
7982
}))
8083
: rawData;
84+
85+
const grabD3Format = (targetMetric) => {
86+
let foundFormatter;
87+
chartProps.datasource.metrics.forEach((metric) => {
88+
if(metric.d3format && metric.metric_name === targetMetric){
89+
foundFormatter = metric.d3format;
90+
}
91+
});
92+
return foundFormatter;
93+
}
8194

95+
if (chartProps.formData.vizType == "pie") {
96+
numberFormat = grabD3Format(chartProps.formData.metric) || numberFormat;
97+
}
98+
else if (chartProps.formData.vizType == "dual_line") {
99+
yAxisFormat = grabD3Format(chartProps.formData.metric) || yAxisFormat;
100+
yAxis2Format = grabD3Format(chartProps.formData.metric2) || yAxis2Format;
101+
}
102+
else if(["line","dist_bar","bar","area"].indexOf(chartProps.formData.vizType) > -1){
103+
yAxisFormat = grabD3Format(chartProps.formData.metrics[0]) || yAxisFormat;
104+
}
105+
82106
return {
83107
width,
84108
height,

0 commit comments

Comments
 (0)