1

I have a pie chart which stores value of a label let say label1 = 1.60 and label2 is 20.00 I want to compare the value of label1 to label2. Like 20.00 is the base and 1.60 is the percentage. can anyone help me with this?

This is what I tried so far

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

This is how i load my label value to chart

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

This is how i render my chart

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();
 }

This is how I get the value of a label and store in chart

ClientScript.RegisterClientScriptBlock(Me.[GetType](), "Script", "changepie(" + Label1.Text + ");", True)
        ClientScript.RegisterClientScriptBlock(Me.[GetType](), "Script", "changepie2(" + potload_val2.Text + ");", True)
x'tian
  • 734
  • 2
  • 14
  • 40
  • what sort of comparison do you need, if the two values are equal? and when would you want to perform the comparison? before / after drawing the chart? – WhiteHat Aug 05 '16 at 18:41
  • I want to perform the comparison after the drawing chart I want the two value of the label compared to each other like if label1=20.00 then label2=50.00. Then when label1 become 50.00 too I want the pie to be loaded with one color only meaning the pie was fully loaded because the label1 and label2 already has the same value. – x'tian Aug 11 '16 at 03:17

0 Answers0