CanvasJS 图形上的交互式垂直线注释
Interactive, vertical line annotations on CanvasJS graph
我正在尝试以类似于 dygraphs 的功能 (example here) but haven't found a way to. I've seen an example where they replaced a point with an image (here) 的方式向我的 CanvasJS 图形添加注释,但它并不完全相同,因为我需要点之间的标记并且有它是自己的工具提示。在 CanvasJS 中有什么方法可以做到这一点吗?
您可以使用 indexLabels along with 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>
我正在尝试以类似于 dygraphs 的功能 (example here) but haven't found a way to. I've seen an example where they replaced a point with an image (here) 的方式向我的 CanvasJS 图形添加注释,但它并不完全相同,因为我需要点之间的标记并且有它是自己的工具提示。在 CanvasJS 中有什么方法可以做到这一点吗?
您可以使用 indexLabels along with 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>