gaoluyang
2 天以前 7df3c552f1a8961bb8cca34b09a992b44e032f58
src/components/Echarts/echarts.vue
@@ -1,6 +1,7 @@
<template>
  <div>
  <div style="position: relative;">
    <div ref="chartRef" :style="chartStyle"></div>
    <slot></slot>
  </div>
</template>
@@ -89,7 +90,7 @@
// 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) => {
@@ -112,13 +113,14 @@
  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,
  }
  
  chartInstance.clear()
@@ -147,7 +149,7 @@
// Watch all reactive props that affect the chart
watch(
    () => [props.xAxis, props.series],
    () => [props.xAxis, props.series, props.legend, props.tooltip],
    () => {
      if (chartInstance) {
        renderChart()