echarts icon indicating copy to clipboard operation
echarts copied to clipboard

Series data dont apply on legend but data exist on series and legend.

Open prpanto opened this issue 1 year ago • 3 comments

The problem is the series set the data and legend set the data but in the end the legend dont show and have an error Legend data should be same with series name or data name.

charts varsion: 5.5.1

const option = shallowRef<echarts.EChartsCoreOption>({
  legend: {
    type: 'scroll',
    bottom: '0%',
    left: 'center',
  },
  polar: {
    radius: [50, '60%'],
    startAngle: 90,
  },
  angleAxis: {
    show: false,
  },
  radiusAxis: {
    show: false,
    type: 'category',
  },
  series: {
    name: 'Alarms',
    type: 'bar',
    roundCap: true,
    data: {},
    coordinateSystem: 'polar',
    label: {
      show: false,
    },
  },
  graphic: [
    {
      type: 'text',
      left: 'center',
      top: '46%',
      style: {
        text: 'TOTAL',
        textAlign: 'center',
        fontSize: 22,
        fontWeight: 'normal',
        fill: '#6A5ACD',
      }
    },
    {
      type: 'text',
      left: 'center',
      top: '51%',
      style: {
        text: null,
        textAlign: 'center',
        fontSize: 22,
        fontWeight: 'normal',
        fill: '#6A5ACD',
      }
    }
  ]
})

onMounted(async () => {
  data.value = await fetchData()

  const chartData = [
    { name: 'Alarms', value: data.value.alarms, },
    { name: 'Readings', value: data.value.readings, },
    { name: 'Smart', value: data.value.smart, },
  ]

  option.value.series.data = chartData
  option.value.legend.data = chartData
  option.value.angleAxis.max = data.value.total
  option.value.graphic[1].style.text = data.value.total
})

prpanto avatar Dec 11 '24 11:12 prpanto

https://echarts.apache.org/en/api.html#echartsInstance.setOption ?

MatthiasMert avatar Dec 11 '24 14:12 MatthiasMert

https://echarts.apache.org/en/api.html#echartsInstance.setOption ?

I set the option to the chart

prpanto avatar Dec 11 '24 14:12 prpanto

you are missing setOption command at the end - Demo

helgasoft avatar Dec 11 '24 19:12 helgasoft