gpt4 book ai didi

apexcharts - 如何访问 Apexchart 的 dataPointSelection 函数的值

转载 作者:行者123 更新时间:2023-12-05 01:14:57 30 4
gpt4 key购买 nike

如何通过单击工具提示访问顶点图表的数据值?

我不想要索引。我需要值(value)。我如何访问该值?

<script>
var options = {
chart: {
type: 'line',
events: {
dataPointSelection: function (event, chartContext, config) {
console.log(config);
var ix = config.dataPointIndex;

alert(ix);

}
}
},
series: [{
name: 'TEST',
data: [[1324508400000, 34], [1324594800000, 54], [1325604800000, 39] , [1326236400000, 43]]
}],
xaxis: {

},
tooltip: {
intersect: true,
shared: false
},
markers: {
size: 6,
}
}

var chart = new ApexCharts(document.querySelector("#chart"), options);

chart.render();
</script>

最佳答案

这对我有用:

dataPointSelection: (event, chartContext, config) => {
console.log(config.w.config.series[config.dataPointIndex])
console.log(config.w.config.labels[config.dataPointIndex])
}

codesandbox

关于apexcharts - 如何访问 Apexchart 的 dataPointSelection 函数的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57486591/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com