SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components
We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!
I am trying to create a chart with additional information, similarly as discussed in this question:
It works fine for simple information, such as enums, that I can cast into a double (see also the example provided in the question mentioned above).
However it seems that there is a restriction on the generic class XyzDataSeries.
Whenever I try to use a different data types for TY and TZ
XyzDataSeries<DateTime, double, int>
I get the following exception at runtime:
SciChartSurface didn’t render, because an exception was thrown:
Message: Das Objekt des Typs "Abt.Controls.SciChart.Wpf.StoreEditor1[System.Int32]" kann nicht in Typ "System.Collections.Generic.IList1[System.Double]" umgewandelt werden. Stack Trace: bei Abt.Controls.SciChart.Wpf.NetworkResolver1.Execute(ResamplingMode resamplingMode, IndexRange pointRange, Int32 viewportWidth, Boolean isFifo, Boolean isCategoryAxis, IList xColumn, IList yColumn, Nullable1 dataIsSorted, Nullable1 dataIsEvenlySpaced, Nullable1 dataIsDisplayedAs2d, IRange visibleXRange) bei Abt.Controls.SciChart.Model.DataSeries.XyzDataSeries`3.ToPointSeries(ResamplingMode resamplingMode, IndexRange pointRange, Int32 viewportWidth, Boolean isCategoryAxis, Nullable1 dataIsDisplayedAs2D, IRange visibleXRange, IPointResamplerFactory factory) bei Abt.Controls.SciChart.Wpf.MethodManager.ListStream(AxisCollection urlAvailable, IRenderableSeries lockInitialized, RenderPassInfo valuesHeader, IPointResamplerFactory addressMap, IDataSeries& nextName, IndexRange& previousValues, IPointSeries& syncObjectHandle) bei Abt.Controls.SciChart.Wpf.MethodManager.ListStream(ISciChartSurface urlAvailable, Size lockInitialized) bei Abt.Controls.SciChart.Wpf.MethodManager.RenderLoop(IRenderContext2D renderContext) bei Abt.Controls.SciChart.Visuals.SciChartSurface.DoDrawingLoop()
Sorry for the german. The message translates to:
The object of type [...] cannot be casted into type [...]
I’m quite confused about this. It works nicely, if I use the same data types for TY and TZ .
XyzDataSeries<DateTime, double, double> XyzDataSeries<DateTime, int, int>
This is not what I would expect from a generic type with three types.
If the types for Y and Z values need to be of the same type, the class should rather look something like this:
The API documentation does not mention anything about this. It only states that the types need to be IComparables, which seems not the full truth.
This is a problem for me, because I have more complex metadata than a double, which I want to reference over the Z value.
But I don’t want to use an index of type double. I’d rather use a GUID or even add the metadata object itself as Z value.
Is this by design or is this something that could be fixed in the future?
Do you have a suggestion how to best reference point related metadata (without having to implement my own DataSeries)?