數據我是新的網頁設計,我試圖填充用C#從SQL數據庫中的數據highcharts餅圖。我已經成功完成了條形圖,但在餅圖上遇到了麻煩。基本上我有一個表tblReport1,其中包含2個字段CustomerType和TotalOrdersHighCharts填充餅圖與SQL數據庫
我可以得到它帶來的價值,但我不能讓我的切片重命名爲CustomerType字段中的數據。我已經在這個論壇上嘗試了幾個建議,但無法讓他們工作。以下是我的代碼,任何建議將不勝感激。
private void Report1()
{
dsSeries = BindData();
if (dsSeries == null) return;
foreach (DataRow dr in dsSeries.Tables[0].Rows)
{
hidXCategories11.Add(dr["CustomerType"]);
}
foreach (DataRow dr1 in dsSeries.Tables[0].Rows)
{
hidValues11.Add(Convert.ToInt32(dr1["TotalOrders"]));
yValues = hidValues11.ToArray(typeof(object)) as object[];
}
DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart")
.InitChart(new Chart { PlotShadow = false })
.SetTitle(new Title { Text = "Orders by Customer Type" })
.SetTooltip(new Tooltip { Formatter = "function() { return '<b>'+ this.point.name +'</b>: '+ this.y +' Orders'; }" })
.SetPlotOptions(new PlotOptions
{
Pie = new PlotOptionsPie
{
ShowInLegend = true,
AllowPointSelect = true,
DataLabels = new PlotOptionsPieDataLabels
{
Formatter = "function() { return '<b>'+ this.point.name +'</b>: '+ this.y; }"
}
}
})
.SetSeries(new[]
{
new Series { Type = ChartTypes.Pie, Name = "help!", Data = new Data(yValues) }
});
ltrChart.Text = chart.ToHtmlString();
}
你可以忍受發送給客戶端的javscript的樣子嗎?這是.NET代碼(我甚至不知道有.NET接口),但「真正的」高位代碼都運行在客戶端。一目瞭然,您看起來像是在設置正確的選項,但是更容易檢查我們是否可以在JavaScript中看到真正的選項。 – Chris
嗨克里斯我沒有JavaScript的只是一個部分我的aspx文件中的 ASP:文字>和我鏈接到highchart.js文件 –
bsmith
@bsmith,你可以看看你的文字標籤應該在的位置的「實時」頁面,然後告訴我們這個javascript是什麼? .NET highcharts API創建一個它寫入的文字標籤(它實際上只是創建一串javascript並將其放入文字標籤中 - 或多或少)。 – wergeld