我成功地向数据点添加了onclick事件。
但我想在标签上添加onclick事件(例如01、02、03、04、05),
有人知道该怎么做吗?
我用于数据点的代码是这样的:
var options = {
chart: {
height: 400,
type: 'line',
stacked: false,
events: {
dataPointSelection: (event, chartContext, config) => {
var selecteddate = pad(config.dataPointIndex + 1, 2);
console.log(selecteddate);
}
}
}
这可行,但是如何将事件添加到标签?
还是不可能?
我设法通过向页面添加事件监听器来做到这一点。
它可能不是标签,但工具提示也很棒。
$(".apexcharts-xaxistooltip").click(function(){
var selecteddate = $(this).text();
// do something
});
之后,我还将覆盖工具提示的CSS。
.tooltip-inner {
background-color: #00acd6 !important;
/*!important is not necessary if you place custom.css at the end of your css calls. For the purpose of this demo, it seems to be required in SO snippet*/
color: #fff;
}
.apexcharts-xaxistooltip{
opacity: 1;
pointer-events: all;
}
.apexcharts-xaxistooltip:hover{
background: #46A7B3;
color: white;
cursor: pointer;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句