我需要用數據填充餡餅這是一個查詢結果(LINQ到SQL)DOTNET的HighCharts,填充了查詢結果的餡餅
問題是我不能管理裏面添加一個foreach此代碼插入我的數據,而不是靜態的火狐,Chrome,IE ECT的...
protected void Page_Load(object sender, EventArgs e)
{
//RepeaterVersionsForPie.DataSource = DAaccess.LibDataVersion.LibDataVersion.GetNumberOfCompaniesUsingEachVersions();
//RepeaterVersionsForPie.DataBind();
var test = DAaccess.LibDataVersion.LibDataVersion.GetNumberOfCompaniesUsingEachVersions();
Highcharts chart = new Highcharts("chart")
.InitChart(new Chart { PlotShadow = false })
.SetTitle(new Title { Text = "Browser market shares at a specific website, 2010" })
.SetTooltip(new Tooltip { Formatter = "function() { return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %'; }" })
.SetPlotOptions(new PlotOptions
{
Pie = new PlotOptionsPie
{
AllowPointSelect = true,
Cursor = Cursors.Pointer,
DataLabels = new PlotOptionsPieDataLabels
{
Color = ColorTranslator.FromHtml("#000000"),
ConnectorColor = ColorTranslator.FromHtml("#000000"),
Formatter = "function() { return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %'; }"
},
Point = new PlotOptionsPiePoint
{
Events = new PlotOptionsPiePointEvents
{
Click = "function() { alert (this.category +': '+ this.y); }"
}
}
}
})
.SetSeries(new Series
{
Type = ChartTypes.Pie,
Name = "Browser share",
Data = new Data(new object[]
{
new object[] { "Firefox", 45.0 },
new object[] { "IE", 26.8 },
new DotNet.Highcharts.Options.Point
{
Name = "Chrome",
Y = 12.8,
Sliced = true,
Selected = true
},
new object[] { "Safari", 8.5 },
new object[] { "Opera", 6.2 },
new object[] { "Others", 0.7 }
})
});
ltrChart.Text = chart.ToHtmlString();
}
其實,我需要能夠插入這樣的事情:
foreach (var item in test)
{
new object[] { item.name, item.count}
}
但沒有按VS」讓我做成功h的東西 在此先感謝您的幫助...
嘿,你的解決方案讓我解決了我的問題。我不得不稍微修改它,然後讓它工作。謝謝您的幫助。我會給你賞金,但我把它放在別人的問題上。希望它對他們有用,並將其標記爲已接受。 – Linger 2012-04-10 21:50:43
我現在看到如何獎勵賞金,但我必須等待24小時。 – Linger 2012-04-10 21:58:04
在這裏看到我的答案http://stackoverflow.com/questions/10074620/pass-a-list-of-series-to-setseries/10096108#10096108。正如我所指出的,我對DotNet.HighCharts項目並不熟悉,但是基於Linger的註釋,該方法可能需要返回一個Series數組而不是一個對象數組。 – 2012-04-11 13:24:14