我有一个饼图,它存储标签的值,比如说 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)