[英]How to add a legend for multiple series in ms chart c#
我一直在从事ASP.NET MVC剃须刀项目,C#,Visual Studio2012。我有一个包含两个系列的图表。
我的代码是:
var chartCentersByYear = new Chart
{
Width = 1000,
Height = 450,
RenderType = RenderType.ImageTag,
AntiAliasing = AntiAliasingStyles.Graphics,
TextAntiAliasingQuality = TextAntiAliasingQuality.High
};
chartCentersByYear.Series.Add("Count");
chartCentersByYear.Series.Add("Cases");
chartCentersByYear.Series[0].ChartType = SeriesChartType.Column;
chartCentersByYear.Series[1].ChartType = SeriesChartType.Line;
var totalCentersByYearResult = new Repository().GetTotalCentersByYear();
foreach (IGD_spInternationalReportCenterWithTots_Result item in totalCentersByYearResult)
{
chartCentersByYear.Series[0].Points.AddXY(item.YearEcmo, item.Count);
chartCentersByYear.Series[1].Points.AddY(item.Cases);
}
...等等。 我必须在图表中插入图例以在同一图例中显示两个系列。 我需要在图例符号旁边显示值,每年用于计数83,86,93 ...等,对于案例1644,1775,1933等。 我怎样才能做到这一点? 预先感谢您的任何帮助。
Legend secondLegend = new Legend("MyLegend");
this.Chart1.Legends.Add("MyLegend");
// Associate Series 2 with the second legend
chartCentersByYear.Series[0].Legend = "MyLegend";
chartCentersByYear.Series[1].Legend = "MyLegend";
chartCentersByYear.Series[2].Legend = "MyLegend";
chartCentersByYear.Series[3].Legend = "MyLegend";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.