我一直致力于ASP.NET MVC razor项目,C#,Visual Studio 2012.我有一个包含两个系列的图表。
我的代码是:
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等。我怎样才能做到这一点?提前感谢您的帮助。
答案 0 :(得分:-1)
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";