@@ -22,6 +22,17 @@ import { formatLabel } from './utils';
22
22
23
23
const NOOP = ( ) => { } ;
24
24
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
+
25
36
export default function transformProps ( chartProps ) {
26
37
const { width, height, annotationData, datasource, formData, hooks, queryData } = chartProps ;
27
38
@@ -78,24 +89,13 @@ export default function transformProps(chartProps) {
78
89
} ) )
79
90
: rawData ;
80
91
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
-
92
92
if ( chartProps . formData . vizType === 'pie' ) {
93
- numberFormat = grabD3Format ( chartProps . formData . metric ) || numberFormat ;
93
+ numberFormat = grabD3Format ( chartProps , chartProps . formData . metric ) || numberFormat ;
94
94
} 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 ;
97
97
} 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 ;
99
99
}
100
100
101
101
return {
0 commit comments