Reputation: 207
I have been working on ASP.NET MVC razor project, C#, Visual Studio 2012. I have a chart with two series.
My code is:
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);
}
...etc. I have to insert a legend in the chart to show both series in the same legend. I need to show values next to the legend symbol, for Count 83,86,93 ... etc and for Cases 1644,1775,1933 etc for each year. How can I do that? Thank you in advance for any help.
Upvotes: 0
Views: 2753
Reputation: 21
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";
Upvotes: 1