我使用canvasjs来创建圆环图 - 图表本身效果很好,但我希望标签从图表本身中删除,只显示在工具提示中。
我根据我在canvasjs网站上看到的内容尝试了以下内容,但它没有隐藏标签:
<div id="chartContainer" style="width:150px; height:150px;"></div>
var chart = new CanvasJS.Chart("chartContainer",
{
animationEnabled: true,
theme: "theme2",
creditText:"",
axisY:{
valueFormatString: " ",
tickLength: 0
},
axisX:{
valueFormatString: " ",
tickLength: 0
},
data: [
{
type: "doughnut",
startAngle:270 ,
toolTipContent: "{label}: {y}",
dataPoints: [
{ y: 2, label: "L1"},
{ y: 3, label: "L2"},
{ y: 8, label: "L3"}
]
}
]
});
chart.render();
有没有办法停止图表中显示的标签,但仍有标签值用于工具提示?
答案 0 :(得分:0)
刚刚找到了一种方法,可以使用dataPoints中的name属性:
var chart = new CanvasJS.Chart("chartContainer",
{
animationEnabled: true,
theme: "theme2",
data: [
{
type: "doughnut",
startAngle:270 ,
toolTipContent: "{name}: {y}",
dataPoints: [
{ y: 2, name: "L1"},
{ y: 3, name: "L2"},
{ y: 8, name: "L3"}
]
}
]
});
chart.render();
http://canvasjs.com/docs/charts/chart-options/data/datapoints/