i want to change my Chart Control
title:
Title title = chart1.Titles.Add("Test");
Series s = new Series();
s.Color = Color.Blue;
s.ChartType = SeriesChartType.Line;
s.BorderWidth = 3;
s.Points.Add(new DataPoint(0.8, 3.2));
s.Points.Add(new DataPoint(0.83, 6.5));
s.Points.Add(new DataPoint(0.9, 12.9));
s.Points.Add(new DataPoint(1, 25.8));
s.Points.Add(new DataPoint(1.1, 29));
s.Points.Add(new DataPoint(1.2, 54.8));
s.Points.Add(new DataPoint(1.4, 58.1));
chart1.Series.Add(s);
chart1.Series.Add(s);
chart1.ChartAreas[0].AxisX.MajorGrid.LineColor = Color.White;
chart1.ChartAreas[0].AxisY.MajorGrid.LineColor = Color.White;
chart1.ChartAreas[0].AxisX.Maximum = 4;
chart1.ChartAreas[0].AxisX.Interval = 1;
chart1.ChartAreas[0].AxisX.IsStartedFromZero = true;
chart1.ChartAreas[0].AxisX.IntervalOffsetType = DateTimeIntervalType.Number;
Currently the title that i want to change is Series1
i have tried Title title = chart1.Titles.Add("Test")
but Series1
title still exists.
Edit:
After:
s.Legend = "DifferentLegend";
chart1.Series.Add(s);
This is the result:
You need to set the 'Legend' property of the series, something like this:
chart1.Series.Add(s);
chart1.Legends.Add(new Legend("DifferentLegend"));
chart1.Legends["DifferentLegend"].DockToChartArea = "Default";
chart1.Series["Series1"].Legend = "DifferentLegend";
chart1.Series["Series1"].IsVisibleInLegend = true;
The Title is something different - that's what appears at the top of the chart.
There must also be code for this chart that you're not showing, because I can't see 'Traffic rate' being set anywhere in your code!
For further information on setting Legends, see the documentation here .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.