SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.

Answered
0
0

Hello SciChart-Team!

I’m trying to give the user of my application the ability to switch between relative (TimeSpan) or absolute (DateTime) time on the X-Axis inside the graph.
I know that I could go with two separate XyDataSeries objects, one for each type but I’d rather not do this because of memory consumption. (millions of datapoints that would need to be stored in memory twice)

My idea would have been to make my code generic with an IComparable instead of TimeSpan or DateTime. Like this:`

new XyDataSeries<IComparable, double>()

The application would then decide on startup which X-Values it should go with and either show a TimeSpanAxis or a DateTimeAxis.

Sadly, this doesn’t work.
When initializing an XyDataSeries like that I get a NotImplementedException

Exception:
Cannot create a DataDistributionCalculator for the type TX=System.IComparable

Stacktrace:

   at A.c5777c70d4cd0dda50a2117fa1aaa10fc.c368dd1d74117b21c11923a7963ca446f[c96cfda5e71b9e51b60daed32a29c7426](Boolean c9d35973164d478a320e72d2740e74116)
   at SciChart.Charting.Model.DataSeries.DataSeries`2.Clear()
   at SciChart.Charting.Model.DataSeries.DataSeries`2..ctor()
   at SciChart.Charting.Model.DataSeries.XyDataSeries`2..ctor(Int32 capacity)
   at PreSens.PMS2.ViewModels.Charting.SingleChannel.ChartData..ctor() in C:\**redacted**\ChartData.cs:line 91

Is this a bug or is this feature not yet implemented? Or is this not possible at all?
If it’s not possible to do it that way, what would you recommend to solve this problem with relative and absolute time?

Regards
Michael

Version
4.2.0.9227
  • You must to post comments
Great Answer
1
0

I couldn’t solve my issue by using the PointMetadata API. That was not what I was looking for.

What I did now is that instead of
new XyDataSeries<TimeSpan, double>()

I use
new XyDataSeries<long, double>()

This allows me to use either the TimeSpan ticks or DateTime ticks as the X-Value for my graph. In the UI I use a regular NumericAxis with a custom label provider that, depending on user configuration, converts the ticks to a DateTime or a TimeSpan value.

Regards
Michael

  • Andrew
    Hi Michael. Of course! Apologies, I must have misread your question. I’m glad you got it sorted though and thank you for posting the answer. Best regards, Andrew
  • You must to post comments
0
0

Morning! (Or afternoon depending on timezone 🙂 )

Have a look at DataSeries Types in SciChart. At the moment:

NOTE: Allowable types in SciChart include DateTime, TimeSpan, Int64, Int32, Int16, Byte, Double, Float, UInt64, UInt32, UInt16, SByte.
DateTime, TimeSpan are only allowable on TX. The type Decimal (128) bit is not allowed. Custom types are not allowed.

If you want to include custom data per-point you can do so using our PointMetadata API. This is an optional API to include any type on some or all data-points. PointMetadata can be passed through to tooltips and paletteprovider, or used for custom drawing.

Let me know if this helps,

Best regards,
Andrew

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.