Group: Forum Members
Last Active: 8 Years Ago
Posts: 61,
Visits: 35
|
Hi,
You are right, sorry. I guess in my previous version/try I did not remove properly the line from the series that is why the legend never disappeared...
Thank you, Daniel
|
Group: Forum Members
Last Active: 1 days ago @ 1:54 AM
Posts: 3,054,
Visits: 4,009
|
Hi Daniel, Why do you need to remove the single legend from the chart? It does not make sense - when you remove a line series this will automatically affect the legend and it will display information only about the present series in the chart(s) it is attached to. If there are no series the legend is automatically hidden anyway (unless it contains header / footer).
Best Regards, Nevron Support Team
|
Group: Forum Members
Last Active: 8 Years Ago
Posts: 61,
Visits: 35
|
Hi,
The removing code is all there in my question, I do not have any more code for that. When I add a line the only code what I have regarding the legend is that: m_Line.Legend.Mode = SeriesLegendMode.Series;
I think I do not remove the series I just remove a line from the series, are not I?
When the user adds a new line each of them gets a unique name. I store the lines in a list so I can search for them easily. By searching of the line it gives back an index. The index of the line is the same as the index of the line in the series or the index of its legend. Let me reference to the above code again just with some more comments:
//name is the name of the graph internal void removeLine(string name) { //find the right line, //return the shared index of it int index = findChartIndex(name);
//get the line from the line list so it can be removed NLineSeries m_Line = lineList[index]; NCartesianChart m_Chart = (NCartesianChart)nChartControl1.Charts[0];
//remove line from the chart series m_Chart.Series.Remove(m_Line);
//remove line from the line list lineList.RemoveAt(index);
//remove legend //if statement should not be needed, //but because all of the legends disappear its needed to be added if (nChartControl1.Legends.Count > index) nChartControl1.Legends.RemoveAt(index);
//refresh the chart nChartControl1.Refresh(); }
I do not set anything else in the line adding regarding the legends, but here is my code about adding a line as it might help too:
public void addNormalLine(string name, Color color, bool leftAxes) { // add a line series NLineSeries m_Line = new NLineSeries(); NCartesianChart m_Chart = (NCartesianChart)nChartControl1.Charts[0]; m_Line = (NLineSeries)m_Chart.Series.Add(SeriesType.Line); m_Line.Name = name; m_Line.InflateMargins = true; m_Line.DataLabelStyle.Visible = false; m_Line.MarkerStyle.Visible = false; m_Line.SamplingMode = SeriesSamplingMode.Enabled;
m_Line.DataLabelStyle.VertAlign = VertAlign.Center; m_Line.DataLabelStyle.Format = ""; m_Line.DataLabelStyle.TextStyle.FillStyle = new NColorFillStyle(Color.White); m_Line.DataLabelStyle.TextStyle.FontStyle.EmSize = new NLength(1.4f, NRelativeUnit.RootPercentage); m_Line.DataLabelStyle.TextStyle.BackplaneStyle.Visible = false;
m_Line.Legend.Mode = SeriesLegendMode.Series;
m_Line.MarkerStyle.PointShape = PointShape.Cylinder; m_Line.MarkerStyle.Width = new NLength(1.5f, NRelativeUnit.ParentPercentage); m_Line.MarkerStyle.Height = new NLength(1.5f, NRelativeUnit.ParentPercentage); m_Line.UseXValues = true; m_Line.BorderStyle.Color = color;
if (leftAxes) { m_Line.DisplayOnAxis(StandardAxis.PrimaryY, true); } else { m_Line.DisplayOnAxis(StandardAxis.PrimaryY, false); m_Line.DisplayOnAxis(StandardAxis.SecondaryY, true); }
lineList.Add(m_Line);
nChartControl1.Refresh(); }
Hope it makes the things a bit more clear.
Regards Daniel
|
Group: Forum Members
Last Active: 1 days ago @ 1:54 AM
Posts: 3,054,
Visits: 4,009
|
Hi Daniel, From the code below it looks like the you remove series from the chart. Note that one or more series by default share a single legend (that depends on the configuration of the control). When you remove the legend in the list you in fact remove the target legend for all series. Can you share more information about the configuration of the control - how do you add remove chart, series and legends and how you specify the target legend for each series?
Best Regards, Nevron Support Team
|
Group: Forum Members
Last Active: 8 Years Ago
Posts: 61,
Visits: 35
|
Hi,
I have an interactive graph where the users can add/remove charts. The problem of mine is whenever I remove the first added graph with its graph legend then all of the graph legends disappear and they do not reappear if I add more graphs.
This is my code:
//find the right line int index = findChartIndex(name);
NLineSeries m_Line = lineList[index]; NCartesianChart m_Chart = (NCartesianChart)nChartControl1.Charts[0]; //remove line from the chart m_Chart.Series.Remove(m_Line);
//remove line from the line list lineList.RemoveAt(index);
//remove legend if (nChartControl1.Legends.Count > index) nChartControl1.Legends.RemoveAt(index);
nChartControl1.Refresh();
Do you have any idea whey it removes all of the legends, it seems like it "Clear()"s the legends.
Regards Daniel
|