Group: Forum Members
Last Active: 8 Years Ago
Posts: 61,
Visits: 35
|
Hi,
I am trying to create a real time graph with multiple lines in it. The number of lines are always different and it is possible that this number changes while the graph already running.
All of the lines need to have separate Y axis but I always just want to display one of those, but I still will display the max and min values of the axis on the top and bottom.
I wrote a method which should add the lines to the graph, but it does not seems to be working.
this is my method:
private void addNormalLine(int i) { // add line NLineSeries line = new NLineSeries(); line = (NLineSeries)m_Chart.Series.Add(SeriesType.Line); line.MultiLineMode = MultiLineMode.Series; line.DataLabelStyle.Visible = false; line.Values.ValueFormatter = new NNumericValueFormatter("0.0"); line.BorderStyle.Color = colors[i % 16]; line.BorderStyle.Width = new NLength(1, NGraphicsUnit.Pixel); line.MarkerStyle.BorderStyle.Color = colors[i % 16]; line.MarkerStyle.FillStyle = new NColorFillStyle(colors[i % 16]); line.DataLabelStyle.TextStyle.BackplaneStyle.Visible = false; line.DataLabelStyle.ArrowStrokeStyle.Width = new NLength(0, NGraphicsUnit.Pixel); line.DataLabelStyle.ArrowLength = new NLength(2.5f, NRelativeUnit.ParentPercentage); line.DataLabelStyle.TextStyle.FontStyle = new NFontStyle("Arial", 8);
//set the axis of the line NAxis axis = ((NCartesianAxisCollection)m_Chart.Axes).AddCustomAxis(AxisOrientation.Vertical, AxisDockZone.FrontLeft); axisList.Add(axis);
NLinearScaleConfigurator linearScale;
linearScale = new NLinearScaleConfigurator(); axis.ScaleConfigurator = linearScale;
linearScale.RulerStyle.FillStyle = new NColorFillStyle(colors[i % 16]); linearScale.RulerStyle.BorderStyle.Color = colors[i % 16]; linearScale.InnerMajorTickStyle.LineStyle.Color = colors[i % 16]; linearScale.OuterMajorTickStyle.LineStyle.Color = colors[i % 16]; linearScale.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back, ChartWallType.Left }; linearScale.LabelStyle.TextStyle.FillStyle = new NColorFillStyle(colors[i % 16]);
//set the axis of the line m_Chart.Axis(axis.AxisId).View = new NRangeAxisView(new NRange1DD(50, 100)); line.DisplayOnAxis(StandardAxis.PrimaryY, false); line.DisplayOnAxis(axisList[i].AxisId, true);
//axisList[i].Anchor = new NDockAxisAnchor(AxisDockZone.FrontLeft, true);
lineList.Add(line);
nChartControl1.Refresh(); }
If anyone could point out any mistake of mine it would be great.
When the code divided to parts then it works. I mean When I have set number of lines then first I create all of the lines then all of the axis then set the linear scale for all of the axis and for last I attach the lines to the axis.
I do not really get why it works when I build up everything separate then building up the whole stuff line by line.
Edit:
I manage to make it kind of work, there is just one thing now, it is missing the second axis, its always the second one, and I can not find the reason why.
Regards Daniel
|