YAxes and Series RemoveAt

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Arction_LasseP

Posts: 48
Joined: Mon Jan 12, 2015 6:52 am

YAxes and Series RemoveAt

Post by ehdrnsep » Mon Mar 23, 2015 6:11 am

How are you?

I was sent an e-mail.
But no reply and write for the forum.

The first question.
I want to fix the X-Axis Label from real-time charts.
Was attached my sample project.
To draw a fixed X-axis Label in real-time charts should you proceed as sample projects?

The second question.
This Exception occur in the following scenarios.

1. Add Multiple Series and YAxes.
2. Remove using a "RemoveAt" method Series and YAxes in the middle.

The sample project was attached.
My OS: Windows7 64bit
VS: VisualStudio 2013 Professional

Thank you.



Message : Invalid Y axis index

HResult : -2146233088

TargetSite : {Boolean LTB(Int32)}

StackTrace :
위치: Arction.LightningChartUltimate.SeriesXY.SeriesBaseXY.LTB(Int32 A)
위치: Arction.LightningChartUltimate.SeriesXY.SeriesBaseXY.SetSubNodeOwners(IChartNode ownerNode)
위치: Arction.LightningChartUltimate.SeriesXY.PointLineSeriesBase.SetSubNodeOwners(IChartNode ownerNode)
위치: Arction.LightningChartUltimate.Views.ViewXY.ViewXY.SetSubNodeOwners(IChartNode ownerNode)
위치: Arction.LightningChartUltimate.LightningChartUltimate.NCC(Object A, EventArgs B)
위치: System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
위치: System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
위치: System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
위치: System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
위치: System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
위치: System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
위치: YAxesControl.Program.Main() 파일 e:\Work\Project\LightningChart\Chart영역_추가삭제\YAxesControl\YAxesControl\Program.cs:줄 18
위치: System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
위치: Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
위치: System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
위치: System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
위치: System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
위치: System.Threading.ThreadHelper.ThreadStart()
[The first Question]
Sample project
(207.45 KiB) Downloaded 281 times
[The first Question]<br />Fixed Custom Label image
[The first Question]
Fixed Custom Label image
customLabel.png (98.64 KiB) Viewed 4662 times
[The second question.]
Sample project
(59.75 KiB) Downloaded 266 times

User avatar
Posts: 1365
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland

Re: YAxes and Series RemoveAt

Post by ArctionPasi » Mon Mar 23, 2015 11:34 am


we replied to you by e-mail today morning. Please note different European and Asian time zones, and our office is closed during weekend. There can be 0.5 - 2 days processing queue.

First question

Rendering labels with GDI over the chart is not a good approach, because of flickering and performance hit.
I think you want to keep the X axis range the same all the time, even if the data scrolls in the chart. You can achieve that easier by adding 2nd X axis and setting it's range from 0...10 seconds. Attach the series to 1st X axis, and hide that axis by setting ViewXY.XAxes[0].Visible = false. In monitoring, increment 1st X axis ScrollPosition, but leave 2nd X axis ScrollPosition as it is. That's probably the easiest and performance-efficient way.

Second question
After deleting, the series must be assigned with new AssignYAxisIndexes again, otherwise they get wrong axis reference.

Like this:

private void btnRemove_Click(object sender, EventArgs e)
ViewXY viewXY = this.chart.ViewXY;
if (viewXY.YAxes.Count != 0)

//Change AssignYAxisIndex for remaining SampleDataSeries
foreach (SampleDataSeries series in chart.ViewXY.SampleDataSeries)
series.AssignYAxisIndex = viewXY.SampleDataSeries.IndexOf(series);

General tips
We strongly recommend using
chart.BeginUpdate...chartEndUpdate around the code you update the chart. Like that, the chart renders faster and doesn't flicker.

LightningChart Support Team, PT

Posts: 48
Joined: Mon Jan 12, 2015 6:52 am

Re: YAxes and Series RemoveAt

Post by ehdrnsep » Tue Mar 24, 2015 12:45 am

Thank you so much. :P