Band Disappear Error

A forum dedicated to WPF version of LightningChart Ultimate.

Moderator: Arction_LasseP

fukasawa
Posts: 18
Joined: Fri Sep 04, 2015 11:13 am

Band Disappear Error

Post by fukasawa » Fri Nov 24, 2017 6:20 am

Hello,

I need to be helped for a error.

I use Bands.
The error is occored following method.
1.Set Bands -> OK
2.Reset View -> OK
3.Click any band -> Broken and Error
2017-11-24.png
2017-11-24.png (41.26 KiB) Viewed 13335 times
(Initialized)
2017-11-24 (1).png
2017-11-24 (1).png (31.84 KiB) Viewed 13335 times
(Clicked)

This is Error Detail.
- $exception {"Axis index for axis related item is invalid: Invalid x-axis/index for Band"} Arction.Wpf.SemibindableCharting.ChartException
+ Data {System.Collections.ListDictionaryInternal} System.Collections.IDictionary {System.Collections.ListDictionaryInternal}
Details "Invalid x-axis/index for Band" string
ErrorDescription "Axis index for axis related item is invalid" string
ErrorType InvalidAxisIndexForSeries Arction.Wpf.SemibindableCharting.ErrorType
HResult -2146233088 int
HelpLink null string
+ IPForWatsonBuckets 0x1783bf98 System.UIntPtr
+ InnerException null System.Exception
IsTransient false bool
Message "Axis index for axis related item is invalid: Invalid x-axis/index for Band" string
RemoteStackTrace null string
Source "Arction.Wpf.SemibindableCharting.LightningChartUltimate" string
StackTrace " 場所 Arction.Wpf.SemibindableCharting.LightningChartUltimate.UXC(AxisX A, VB B, Double C, Double F, Int32 G, Rectangle H)" string
+ TargetSite {Void UXC(Arction.Wpf.SemibindableCharting.Axes.AxisX, A.VB, Double, Double, Int32, System.Drawing.Rectangle)} System.Reflection.MethodBase {System.Reflection.RuntimeMethodInfo}

ArctionKestutis
Posts: 383
Joined: Mon Mar 14, 2016 9:22 am

Re: Band Disappear Error

Post by ArctionKestutis » Fri Nov 24, 2017 9:24 am

Hello,

A band can be bound to a Y axis or X axis: the Binding property is to control that. If you bind to Xaxis (similar for Y), the AssignXAxisIndex could not be <0 and >= XAxis.Count. Otherwise you will get Error.
If you remove axis, to which Band was previously assign, the AssignAxisIndex is set to -1. Therefore, by removing axis you will get Error.

What your 'Reset View' does? If you clear/remove and recreate axis without assigning Band's index, there is your problem and solution.

All the best.

fukasawa
Posts: 18
Joined: Fri Sep 04, 2015 11:13 am

Re: Band Disappear Error

Post by fukasawa » Tue Nov 28, 2017 2:42 am

Thank you Kestutis

I use MVVM and Semi-Bindable Chart.
I Bind 'Bands', 'Maxim' of XAxis and 'Minimum' of XAxis (NOT bind XAxes).

'Reset View' mean Dispose UserControl which include LightningChart.

In Addition, Band.AssignXAxisIndex is '-1' when Error occured.

So now, I change to reset AssignXAxisIndex of Band to 0 when Chart.Loaded Event.
But problem still occurred. :(

ArctionKestutis
Posts: 383
Joined: Mon Mar 14, 2016 9:22 am

Re: Band Disappear Error

Post by ArctionKestutis » Tue Nov 28, 2017 12:39 pm

Hello,

If you can, please send your simplified application to Arction's support account, so we could look at the issue.

At the moment it looks that we are talking about different kind of 'binding'. The WPF binding is one thing. In LightningChart internally we calling 'assignment'. All series should be bound/assigned to X and Y axes, during creation of series or latter through AssignXAxisIndex and AssignYAxisIndex properties. In contrast to other series, Band could be assigned only to X or Y axis: Axis.Binding = XAxis/Yaxis will tell that. If this property set to Xaxis, band will move only from left to right. If this property set to Yaxis, band will move only up-down.
Bands bounding.jpg
Bands bounding.jpg (98.36 KiB) Viewed 13315 times
Only bind axis index need to be set correctly (AssignXAxisIndex or AssignYAxisIndex), another could be -1. During initial creation of series, Assign-AxisIndex is set to 0 by default.

If you dispose Chart, it should dispose everything (including axes and bands). Even if for some reason Bands have not been disposed, it definitely will will have AssignXAxisIndex =-1.
To understand better, where create-dispose-create pattern get wrong we would need your test project.

All the best.

fukasawa
Posts: 18
Joined: Fri Sep 04, 2015 11:13 am

Re: Band Disappear Error

Post by fukasawa » Wed Nov 29, 2017 6:42 am

Thank you ArctionKestutis

First, I mistook, the view dosen't disposed in my application.
I only recreate View and rebind(WPF) to viewmodel.
If call chart.Dispose(), the application dosen't continue.
Sorry for my misinform.

I tried to create simplified application.
But, error message is different and application dosen't continue.

1.Set Bands -> OK
2.Reset View(Click Button) -> OK
3.Drag LineCursor(red) -> Broken and Error
2017-11-29.png
2017-11-29.png (34.92 KiB) Viewed 13313 times
Actually, I have already find solution.

Code: Select all

<lcusb:LineSeriesCursor x:Name="cursor" ValueAtXAxis="{Binding CursorXValue, Mode=TwoWay}" />
If LineSeriesCursor ValueAtXAxis Binding Mode is OneWay, the Error dosen't occur.
This solution is effective in my real application.
But I need to TwoWay-Binding.
Are there any other solution?

This is Error Detail.
- $exception {"Unspecified error: Axis index for axis related item is invalid: Invalid x-axis or index for series when trying to draw titles.Stack trace: 場所 Arction.Wpf.SemibindableCharting.LightningChartUltimate.RVC()\r\n 場所 Arction.Wpf.SemibindableCharting.LightningChartUltimate.EUC()\r\n 場所 Arction.Wpf.SemibindableCharting.LightningChartUltimate.JNC()"} Arction.Wpf.SemibindableCharting.ChartException
+Data {System.Collections.ListDictionaryInternal} System.Collections.IDictionary {System.Collections.ListDictionaryInternal}
Details "Axis index for axis related item is invalid: Invalid x-axis or index for series when trying to draw titles.Stack trace: 場所 Arction.Wpf.SemibindableCharting.LightningChartUltimate.RVC()\r\n 場所 Arction.Wpf.SemibindableCharting.LightningChartUltimate.EUC()\r\n 場所 Arction.Wpf.SemibindableCharting.LightningChartUltimate.JNC()" string
ErrorDescription "Unspecified error" string
ErrorType Unspecified Arction.Wpf.SemibindableCharting.ErrorType
Message "Unspecified error: Axis index for axis related item is invalid: Invalid x-axis or index for series when trying to draw titles.Stack trace: 場所 Arction.Wpf.SemibindableCharting.LightningChartUltimate.RVC()\r\n 場所 Arction.Wpf.SemibindableCharting.LightningChartUltimate.EUC()\r\n 場所 Arction.Wpf.SemibindableCharting.LightningChartUltimate.JNC()" string
Attachments
LChartBandErrorTest.zip
simplified application
(27.51 KiB) Downloaded 302 times

ArctionKestutis
Posts: 383
Joined: Mon Mar 14, 2016 9:22 am

Re: Band Disappear Error

Post by ArctionKestutis » Thu Nov 30, 2017 2:14 pm

Hello,

When LightingChart's objects are not needed anymore it's good practice to Dispose them to prevent memory leaking. The removal from collection (as in your code) does not automatically dispose object. I believe that failure to dispose is pointing to actual problem. That problem is parent-child relationship of objects in LightningChart. Chart is the parent of all its objects including those you bind. In other words after you did Bands binding, LightningChart is set as Bands parent. Then you create new LightningChart instance it tries to get ownership for the Bands, but "Sharing objects between other objects" is not allowed in LightningChart https://forum.arction.com/viewtopic.php?f=29&t=973. It will fail with one or another exception.

Overall, you should Dispose LightingChart in your app when you 'reset view' and you should recreate Bands object as well before you could bind to the new instance of LightingChart.

Hope this helps.

fukasawa
Posts: 18
Joined: Fri Sep 04, 2015 11:13 am

Re: Band Disappear Error

Post by fukasawa » Fri Dec 01, 2017 6:28 am

Thank your advice, I realized basic mistake.

It's my understanding, when lifetimes of View and VM are different, LightingChart's objects must not be located both View and VM.

I think there are 3 solution.

[1].LightingChart's are located only View.
[2].Don't reset View only
If View is reset, VM is reset too.
[3].Don't bind LightingChart's objects directory.
If the objects are binding(WPF), use converter or something.

[1] and [2] don't occur the error
But, they restrict whole app design.

[3] is works fine in my simplified application with Dispose().
But, it have bad performance.

Are there any other solution?

Best Regards,

My sample converter of [2].

Code: Select all

[ValueConversion(typeof(IEnumerable<double>), typeof(BandCollection))]
public class BandConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        var bandCollection = new BandCollection();

        if (!(value is IEnumerable<double> bandVMs))
            return bandCollection;

        bandVMs
            .Select(ConvertToBand)
            .ToList()
            .ForEach(bandCollection.Add);

        return bandCollection;
    }

    private Band ConvertToBand(double value)
        => new Band
        {
            //Set value direct or binding in code.
            ValueBegin = value,
        };

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        => Binding.DoNothing;
}

ArctionKestutis
Posts: 383
Joined: Mon Mar 14, 2016 9:22 am

Re: Band Disappear Error

Post by ArctionKestutis » Fri Dec 01, 2017 9:01 am

Hello Fukasawa,

Correct me if I am wrong, but your subscription already ended. While you can use the LightningChart components indefinitely, the expiration ends technical support, updates and warranty. Please renew the subscription to extend those services, or inform about valid subscription to Arction's email account.

Meanwhile just words on latest reply. The fourth option would be reuse of chart (without disposing it). 1 & 2 are good options. The implementation of 3 at first glance looks fine, but you need to debug where performance penalty comes from.

All the best.

fukasawa
Posts: 18
Joined: Fri Sep 04, 2015 11:13 am

Re: Band Disappear Error

Post by fukasawa » Fri Dec 08, 2017 8:00 am

Hi ArctionKestutis

First of all, I'm sorry to my misunderstanding.
I'll talk to our purchase department.

In addition, thank for your advice.