饼图值与具有小数

时间:2016-08-05 02:01:11

标签: javascript asp.net charts jscharts

我有一个饼图,它存储标签的值,比如说label1 = 1.60,label2是20.00我想比较label1和label2的值。像20.00是基数,1.60是百分比。谁能帮我这个?

这是我到目前为止所尝试的

<asp:Label ID="Label1" runat="server" Text="Label" ></asp:Label>
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
<div id="chartContainer"></div>

这就是我将标签值加载到图表

的方法
 var pie = 0;
      function changepie(val) {
          pie = val;
 }
 var pie2 = 0;
      function changepie2(val) {
          pie2 = val;
 }

这是我渲染图表的方式

window.onload = function () {

     var chart = new CanvasJS.Chart("chartContainer",
    {

        animationEnabled: true,
        animationDuration: 1300,
        legend: {
            verticalAlign: "bottom",
            horizontalAlign: "center"
        },
        data: [
        {
            indexLabelFontSize: 20,
            indexLabelFontFamily: "Monospace",
            indexLabelFontColor: "darkgrey",
            indexLabelLineColor: "darkgrey",
            indexLabelPlacement: "outside",
            type: "pie",

            toolTipContent: "{y} - <strong>#percent%</strong>",
            dataPoints: [
                { y: pie, legendText: "" },
                { y: pie2, legendText: "" },
            ]
        }
        ]
    });
     chart.render();
 }

这就是我在图表中获取标签和商店的价值

ClientScript.RegisterClientScriptBlock(Me.[GetType](), "Script", "changepie(" + Label1.Text + ");", True)
        ClientScript.RegisterClientScriptBlock(Me.[GetType](), "Script", "changepie2(" + potload_val2.Text + ");", True)

0 个答案:

没有答案