@@ -27,38 +27,44 @@ export interface BaseChartRawBindings<C extends PlotConfig> {
2727 getChartConfig : ( ) => ChartOptions
2828}
2929
30- export default defineComponent < BaseChartProps < any > , BaseChartRawBindings < any > > ( {
30+ const BaseChart = defineComponent <
31+ BaseChartProps < any > ,
32+ BaseChartRawBindings < any >
33+ > ( {
34+ inheritAttrs : false ,
3135 name : 'BaseChart' ,
3236 mounted ( ) {
3337 const { chart : Chart } = this . $attrs as Record < string , any >
3438 const { data, config } = this . getChartConfig ( )
3539 this . config = cloneDeep ( config )
3640 const normalizedData = data || [ ]
3741 this . data = normalizedData
38- const chart = new Chart ( this . $el , {
42+ this . plot = new Chart ( this . $el , {
3943 data : normalizedData ,
4044 ...config ,
4145 } )
42- this . plot = chart
4346 this . plot . render ( )
4447 } ,
4548 beforeUpdate ( ) {
4649 const { data, config } = this . getChartConfig ( )
4750 const normalizedData = data || [ ]
51+ /* istanbul ignore else */
4852 if ( this . plot ) {
4953 if ( ! isEqual ( config , this . config ) || ! this . data . length ) {
5054 this . config = cloneDeep ( config )
5155 this . plot . updateConfig ( {
52- data,
56+ data : normalizedData ,
5357 ...config ,
5458 } )
5559 this . plot . render ( )
5660 } else {
5761 this . plot . changeData ( normalizedData )
5862 }
63+ this . data = normalizedData
5964 }
6065 } ,
6166 beforeUnmount ( ) {
67+ /* istanbul ignore else */
6268 if ( this . plot ) {
6369 this . plot . destroy ( )
6470 }
@@ -80,3 +86,5 @@ export default defineComponent<BaseChartProps<any>, BaseChartRawBindings<any>>({
8086 return < div />
8187 } ,
8288} )
89+
90+ export default BaseChart
0 commit comments