This repository was archived by the owner on Jun 25, 2020. It is now read-only.
File tree 1 file changed +27
-3
lines changed
packages/superset-ui-legacy-preset-chart-nvd3/src
1 file changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -59,26 +59,50 @@ export default function transformProps(chartProps) {
59
59
xAxisFormat,
60
60
xAxisLabel,
61
61
xAxisShowminmax,
62
- numberFormat,
63
62
xLogScale,
64
63
xTicksLayout,
65
64
y,
66
- yAxisFormat,
67
- yAxis2Format,
68
65
yAxisBounds,
69
66
yAxisLabel,
70
67
yAxisShowminmax,
71
68
yLogScale,
72
69
} = formData ;
73
70
71
+ let {
72
+ numberFormat,
73
+ yAxisFormat,
74
+ yAxis2Format,
75
+ } = formData ;
76
+
74
77
const rawData = queryData . data || [ ] ;
75
78
const data = Array . isArray ( rawData )
76
79
? rawData . map ( row => ( {
77
80
...row ,
78
81
key : formatLabel ( row . key , datasource . verboseMap ) ,
79
82
} ) )
80
83
: 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
+ }
81
94
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
+
82
106
return {
83
107
width,
84
108
height,
You can’t perform that action at this time.
0 commit comments