@@ -16,6 +16,21 @@ function splitAngleColor(dataProps: BasicDataPropertyForAdvice[]): [ReturnField,
1616 return [ field4Color , field4Angle ] ;
1717}
1818
19+ /**
20+ * Process date column to new Date().
21+ * @param field
22+ * @param dataProps
23+ * @returns
24+ */
25+ function processDateEncode ( field : string , dataProps : BasicDataPropertyForAdvice [ ] ) {
26+ const dp = dataProps . find ( ( dataProp ) => dataProp . name === field ) ;
27+
28+ if ( dp ?. recommendation === 'date' ) {
29+ return ( d ) => new Date ( d [ field ] ) ;
30+ }
31+ return field ;
32+ }
33+
1934function pieChart ( data : Data , dataProps : BasicDataPropertyForAdvice [ ] ) : Advice [ 'spec' ] {
2035 const [ field4Color , field4Angle ] = splitAngleColor ( dataProps ) ;
2136 if ( ! field4Angle || ! field4Color ) return null ;
@@ -29,6 +44,10 @@ function pieChart(data: Data, dataProps: BasicDataPropertyForAdvice[]): Advice['
2944 } ,
3045 transform : [ { type : 'stackY' } ] ,
3146 coordinate : { type : 'theta' } ,
47+ animate : {
48+ enter : { type : 'waveIn' } ,
49+ update : { type : 'waveIn' } ,
50+ } ,
3251 } ;
3352 return spec ;
3453}
@@ -46,6 +65,10 @@ function donutChart(data: Data, dataProps: BasicDataPropertyForAdvice[]): Advice
4665 } ,
4766 transform : [ { type : 'stackY' } ] ,
4867 coordinate : { type : 'theta' , innerRadius : 0.6 } ,
68+ animate : {
69+ enter : { type : 'waveIn' } ,
70+ update : { type : 'waveIn' } ,
71+ } ,
4972 } ;
5073 return spec ;
5174}
@@ -67,7 +90,7 @@ function lineChart(data: Data, dataProps: BasicDataPropertyForAdvice[]): Advice[
6790 type : 'line' ,
6891 data,
6992 encode : {
70- x : field4X . name ,
93+ x : processDateEncode ( field4X . name , dataProps ) ,
7194 y : field4Y . name ,
7295 } ,
7396 } ;
@@ -87,7 +110,7 @@ function stepLineChart(data: Data, dataProps: BasicDataPropertyForAdvice[]): Adv
87110 type : 'line' ,
88111 data,
89112 encode : {
90- x : field4X . name ,
113+ x : processDateEncode ( field4X . name , dataProps ) ,
91114 y : field4Y . name ,
92115 shape : 'hvh' ,
93116 } ,
@@ -120,7 +143,7 @@ function areaChart(data: Data, dataProps: BasicDataPropertyForAdvice[]): Advice[
120143 type : 'area' ,
121144 data,
122145 encode : {
123- x : field4X . name ,
146+ x : processDateEncode ( field4X . name , dataProps ) ,
124147 y : field4Y . name ,
125148 } ,
126149 } ;
@@ -136,7 +159,7 @@ function stackedAreaChart(data: Data, dataProps: BasicDataPropertyForAdvice[]):
136159 type : 'area' ,
137160 data,
138161 encode : {
139- x : field4X . name ,
162+ x : processDateEncode ( field4X . name , dataProps ) ,
140163 y : field4Y . name ,
141164 color : field4Series . name ,
142165 } ,
@@ -154,7 +177,7 @@ function percentStackedAreaChart(data: Data, dataProps: BasicDataPropertyForAdvi
154177 type : 'area' ,
155178 data,
156179 encode : {
157- x : field4X . name ,
180+ x : processDateEncode ( field4X . name , dataProps ) ,
158181 y : field4Y . name ,
159182 color : field4Series . name ,
160183 } ,
0 commit comments