ChartNew.js - 从饼图中删除/隐藏零标签

时间:2016-03-19 17:23:05

标签: chart.js

我试图从ChartNew.js中的饼图中删除零(0)标签。 无法解决这个问题。

以下是示例:



InlineData

var pieData = [
	{
        value: 0,
        color: "sandybrown",
        title: "label1",

    }, 
	{
        value: 10,
        color: "gold",
        title: "label2",

    }, 
	{
        value: 46,
        color: "darkviolet",
        title: "label3",

    }, 
	{
        value: 0,
        color: "green",
        title: "label4",

    },
	{
        value: 33,
        color: "DeepSkyBlue",
        title: "label5",

    }
	
	];

	var myoptions = { 
	animateRotate : true,
	animateScale : false,
	animationByData : false,
	animationSteps : 50,
	canvasBorders : true,
	canvasBordersWidth : 0,
	canvasBordersColor : "black",
	legend : true,
	inGraphDataShow : true,
	animationEasing: "linear",
	annotateDisplay : true,
	spaceBetweenBar : 5,
	graphTitleFontSize: 18,
	extrapolateMissingData : false	
	};  

    var myPie = new Chart(document.getElementById("canvas1").getContext("2d")).Pie(pieData, myoptions);




<SCRIPT src='https://rawgit.com/FVANCOP/ChartNew.js/master/ChartNew.js'></SCRIPT>

<canvas id="canvas1" height="500" width="500"></canvas>

我试图从图表中删除label1和label4。

1 个答案:

答案 0 :(得分:0)

根据V-Q-A NGUYEN的建议,在选项中添加以下行

inGraphDataTmpl: "<%=(v6 > 0 ? v6+' %' : ' ')%>",