我需要用数据填充馅饼这是一个查询结果(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