| | |
| | | <template> |
| | | <div> |
| | | <div style="position: relative;"> |
| | | <div ref="chartRef" :style="chartStyle"></div> |
| | | <slot></slot> |
| | | </div> |
| | | </template> |
| | | |
| | |
| | | type: Array, |
| | | default: () => [] |
| | | }, |
| | | visualMap: { |
| | | type: Object, |
| | | default: () => ({}) |
| | | }, |
| | | option: { |
| | | type: Object, |
| | | default: () => ({}) |
| | |
| | | |
| | | // Methods |
| | | function generateChart(option) { |
| | | const copiedOption = JSON.parse(JSON.stringify(option)) // ✅ 深拷贝 |
| | | const copiedOption = option |
| | | |
| | | if (copiedOption.series && copiedOption.series.length > 0) { |
| | | copiedOption.series.forEach((s, index) => { |
| | |
| | | const option = { |
| | | color: props.color.length ? props.color : undefined, |
| | | backgroundColor: props.options.backgroundColor || '#fff', |
| | | textStyle: props.options.textStyle || { color: '#333' }, |
| | | xAxis: props.xAxis, |
| | | yAxis: props.yAxis, |
| | | dataset: props.dataset, |
| | | series: props.series, |
| | | grid: props.grid, |
| | | legend: props.legend, |
| | | tooltip: props.tooltip |
| | | tooltip: props.tooltip, |
| | | visualMap: Object.keys(props.visualMap).length ? props.visualMap : undefined, |
| | | } |
| | | |
| | | chartInstance.clear() |
| | |
| | | |
| | | // Watch all reactive props that affect the chart |
| | | watch( |
| | | () => [props.xAxis, props.series], |
| | | () => [props.xAxis, props.yAxis, props.series, props.legend, props.tooltip, props.visualMap], |
| | | () => { |
| | | if (chartInstance) { |
| | | renderChart() |