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

Commit 95e2638

Browse files
committed
style: moving grabD3Format outside the transformProps block
1 parent 2a27782 commit 95e2638

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ import { formatLabel } from './utils';
2222

2323
const NOOP = () => {};
2424

25+
const grabD3Format = (chartProps, targetMetric) => {
26+
let foundFormatter;
27+
chartProps.datasource.metrics.forEach(metric => {
28+
if (metric.d3format && metric.metric_name === targetMetric) {
29+
foundFormatter = metric.d3format;
30+
}
31+
});
32+
33+
return foundFormatter;
34+
};
35+
2536
export default function transformProps(chartProps) {
2637
const { width, height, annotationData, datasource, formData, hooks, queryData } = chartProps;
2738

@@ -78,24 +89,13 @@ export default function transformProps(chartProps) {
7889
}))
7990
: rawData;
8091

81-
const grabD3Format = targetMetric => {
82-
let foundFormatter;
83-
chartProps.datasource.metrics.forEach(metric => {
84-
if (metric.d3format && metric.metric_name === targetMetric) {
85-
foundFormatter = metric.d3format;
86-
}
87-
});
88-
89-
return foundFormatter;
90-
};
91-
9292
if (chartProps.formData.vizType === 'pie') {
93-
numberFormat = grabD3Format(chartProps.formData.metric) || numberFormat;
93+
numberFormat = grabD3Format(chartProps, chartProps.formData.metric) || numberFormat;
9494
} else if (chartProps.formData.vizType === 'dual_line') {
95-
yAxisFormat = grabD3Format(chartProps.formData.metric) || yAxisFormat;
96-
yAxis2Format = grabD3Format(chartProps.formData.metric2) || yAxis2Format;
95+
yAxisFormat = grabD3Format(chartProps, chartProps.formData.metric) || yAxisFormat;
96+
yAxis2Format = grabD3Format(chartProps, chartProps.formData.metric2) || yAxis2Format;
9797
} else if (['line', 'dist_bar', 'bar', 'area'].indexOf(chartProps.formData.vizType) > -1) {
98-
yAxisFormat = grabD3Format(chartProps.formData.metrics[0]) || yAxisFormat;
98+
yAxisFormat = grabD3Format(chartProps, chartProps.formData.metrics[0]) || yAxisFormat;
9999
}
100100

101101
return {

0 commit comments

Comments
 (0)