【问题标题】:apexcharts with vue - pie chart seriesIndex and dataPointIndex are -1 for click带有 vue 的 apexcharts - 饼图 seriesIndex 和 dataPointIndex 为 -1 表示点击
【发布时间】:2021-09-02 17:27:12
【问题描述】:

我正在使用 Vue 顶点图表,每当我点击饼图时,我都会看到:

options: {
          chart: {
            events: {
              click:
                  (event: any, chartContext: any, config: any) => {
                    console.log('Clicked', chartContext);
                    console.log('Event', event);
                    console.log('Config', config);
                  }
            },
          },

在控制台中,config.seriesIndexconfig.dataPointIndex 始终为-1 - 如何获取我点击的饼图的值?索引/标签/什么??

【问题讨论】:

    标签: javascript vuejs2 apexcharts


    【解决方案1】:

    要获得对单击的饼图的引用,您需要改用dataPointSelection 函数。这允许您以您尝试过的方式获得config.seriesIndexconfig.dataPointIndex

    options: {
              chart: {
                events: {
                  dataPointSelection:
                      (event, chartContext, config) => {
                        console.log('seriesIndex', config.seriesIndex);
                        console.log('dataPointIndex', config.dataPointIndex);
                      }
                },
              },
    },
    
    

    click 函数在用户单击图表上的任意位置时触发,并且不用于提取有关用户与特定数据点交互的数据。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-03
      • 2022-11-24
      • 2011-04-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多