gpt4 book ai didi

javascript - CanvasJS 图表上的交互式垂直线注释

转载 作者:行者123 更新时间:2023-11-28 17:44:24 24 4
gpt4 key购买 nike

我正在尝试以类似于 dygraphs 功能( example here )的方式向我的 CanvasJS 图表添加注释,但尚未找到方法。我见过一个例子,他们用图像( here )替换了一个点,但它并不完全相同,因为我需要点之间的标记并拥有它自己的工具提示。 CanvasJS 有什么办法可以实现这一点吗?

最佳答案

您可以使用indexLabels以及indexLabelLineThickness显示注释,但仅针对数据点显示工具提示。

var chart = new CanvasJS.Chart("chartContainer", {
title: {
text: "Line Chart with Index-Labels"
},
data: [{
type: "line",
indexLabelBackgroundColor: "LightBlue",
indexLabelLineThickness: 1,
dataPoints: [
{ x: 10, y: 71 },
{ x: 20, y: 55, indexLabel: "{y}" },
{ x: 30, y: 50 },
{ x: 40, y: 65 },
{ x: 50, y: 95 },
{ x: 60, y: 68, indexLabel: "{y}" },
{ x: 70, y: 28 },
{ x: 80, y: 34, indexLabel: "{y}" },
{ x: 90, y: 14 }
]
}]
});

chart.render();
<script type="text/javascript" src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<div id="chartContainer" style="height: 250px; width: 100%;"></div>

关于javascript - CanvasJS 图表上的交互式垂直线注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47116101/

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