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

0
0

I would like to implement a custom DateTime axis LabelProvider with the following behavior:

  • Show full date and time at the start of the visible region
  • Show only time on all other ticks unless the date changes from the previous tick.

So, an axis might look like:

10/01/2016 23:00 23:30 10/02 00:00 00:30 01:00

It seems this is doable as long as 00:00:00 appears as one of the label values, but I’m not sure l can be guaranteed. It is likely that none of the entries in the series would contain that exact value. One entry might be 23:59:17 and the next 00:01:13.

Is there any way for a LabelProvider to determine what the preceding label value was?

Bill

Version
4.1
  • You must to post comments
1
0

Hi Bill,

Thanks for your inquiry. The FormatLabel() method is called for every axis label which is going to appear on an axis. So yes, it is possible to implement your desired behavior. Just store a previous date and compare it with current one.

The documentation article on LabelProviders can be found here.

Hope this helps!

Best regards,
Yuriy

  • You must to post comments
0
0

Yuriy,
This worked great. Thank you.
One more question. Is there a recommended way to force a regeneration of axis labels, other than changing its visible range?. The scaling on my axis depends on an external value . When that value changes, I would like to regenerate the axis labels. I’ve tried nudging the visible range min value up and down, but it seems the labels are not regenerated unless I move the range far enough to be noticeable on screen.
Bill

  • Andrew
    Hi Bill, you can try sciChartSurface.InvalidateElement() to force a redraw. Best regards, Andrew
  • You must to post comments
0
0

That worked! Thanks.

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.