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)