c# – 饼图中的值
发布时间:2020-12-15 19:50:34 所属栏目:百科 来源:网络整理
导读:如何使用ChartHelper在饼图中显示每个饼图的值?我正在使用MVC3 / Razor语法. 试着这样做: 对于MVC中的ChartHelper,图像来自this tutorial: 我的代码: var bytes = new Chart(600,300).AddSeries( chartType: "pie",legend: "Sales in Store per Payment
如何使用ChartHelper在饼图中显示每个饼图的值?我正在使用MVC3 / Razor语法.
试着这样做: 对于MVC中的ChartHelper,图像来自this tutorial: 我的代码: var bytes = new Chart(600,300).AddSeries( chartType: "pie",legend: "Sales in Store per Payment Collected",xValue: viewModel.SalesInStorePerPaymentCollected.XValues,yValues: viewModel.SalesInStorePerPaymentCollected.YValues ) .GetBytes("png"); return File(bytes,"image/png"); 解决方法
我是通过使用System.Web.UI.DataVisualization.Charting.Chart类完成的.
这是我的控制器中的代码: public ActionResult Chart() { Chart chart = new Chart(); chart.ChartAreas.Add(new ChartArea()); chart.Series.Add(new Series("Data")); chart.Series["Data"].ChartType = SeriesChartType.Pie; chart.Series["Data"]["PieLabelStyle"] = "Outside"; chart.Series["Data"]["PieLineColor"] = "Black"; chart.Series["Data"].Points.DataBindXY( data.Select(data => data.Name.ToString()).ToArray(),data.Select(data => data.Count).ToArray()); //Other chart formatting and data source omitted. MemoryStream ms = new MemoryStream(); chart.SaveImage(ms,ChartImageFormat.Png); return File(ms.ToArray(),"image/png"); } 观点: <img alt="alternateText" src="@Url.Action("Chart")" /> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |