AxisValueType.DateTime

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Arction_LasseP

ahe
Posts: 51
Joined: Tue Aug 11, 2015 4:33 pm
Location: Düsseldorf, DE

AxisValueType.DateTime

Post by ahe » Wed Aug 24, 2016 10:15 am

Hello,

I am not quite satisfied with the representation of some of the values on an absolute time axis (AxisValueType.DateTime), for example: "mm:ss" versus "hh:ss" - this should be hh:mm:ss to avoid ambiguity. (See ISO-8601) - could this please be changed? Or is this culture specific?

The documentation for the FormatValueLabel event, bzw. the FormatValueLabelEventArgs class is also a bit thin, i.e. no explanation of the value range or examples on how to convert from double to DateTime.


There seems to be an issue with values before 2010, as the date becomes negative:
DateTimeAxis.png
DateTimeAxis.png (63.45 KiB) Viewed 11528 times
Can be reproduced with the sample app / XY view examples / Stocks/Trading / Segments with splitters : zoom out, scroll to 1.1.2010

Since Dates before the year -1000 and after 10000 are invalid, the axis can become empty - not a bug in itself, but I feel that the zoom speed is maybe too high, it's too easy to scroll out too much.

Regards, Andreas

ahe
Posts: 51
Joined: Tue Aug 11, 2015 4:33 pm
Location: Düsseldorf, DE

Re: AxisValueType.DateTime

Post by ahe » Wed Aug 24, 2016 11:32 am

Forgot to mention, it's version 7.1.2

Another screenshot of the date origin issue.
2016-08-24--Zeit.png
2016-08-24--Zeit.png (186.86 KiB) Viewed 11526 times
By the way, this has only very low priority for me since I am currently still using AxisValueType.Number with the FormatValueLabel event to emulate .DateTime (for historic reasons). Might change in the future though.

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

Re: AxisValueType.DateTime

Post by ArctionPasi » Wed Aug 24, 2016 5:30 pm

Hi Andreas,

the axis.DateOriginYear, Month and Day must represent lower date than actual range to be shown. Then it won't show negative values. DateOrigin differential system is made to show nanosecond time scale precision with normal Double floating point accuracy.

See http://arction.com/download/lightningch ... manual.pdf, chapter 6.2.3


Very few people are happy with same and automatic formatting. So we've provided several ways to customize the formatting of the labels.

e.g. :

Set axis.AutoFormatLabels = False, and set axis.LabelNumberFormat or axis.LabelTimeFormat manually.
Or use axis.FormatValueLabel event handler.
Or use CustomAxisTicks

I hope this helps.
LightningChart Support Team, PT

ahe
Posts: 51
Joined: Tue Aug 11, 2015 4:33 pm
Location: Düsseldorf, DE

Re: AxisValueType.DateTime

Post by ahe » Fri Sep 02, 2016 8:22 am

I am considering using the automatic since it covers 99% of my needs and I'd hate having to reinvent the wheel, but I'm really unhappy with the invalid negative dates on the axis.

Is there an easier way to restrict the zoomable range other than to override the user input in the RangeChanged event?

Code: Select all

private double xAxisRestrictMin;
private double xAxisRestrictMax;

void CreateChart()
{ ...
    xAxisRestrictMin = xAxis.DateTimeToAxisValue(new DateTime(2016, 9, 1));
    xAxisRestrictMax = xAxis.DateTimeToAxisValue(new DateTime(2016, 9, 5));
    xAxis.RangeChanged += xAxis_RangeChanged;
... }

void xAxis_RangeChanged(object sender, RangeChangedEventArgs e)
{
    bool overridden = false;
    var newMin = e.NewMin;
    var newMax = e.NewMax;

    if (newMin < xAxisRestrictMin && newMax > xAxisRestrictMax)
    {
        overridden = true;
    }
    else if (newMin < xAxisRestrictMin)
    {
        overridden = true;
        newMin = xAxisRestrictMin;
        newMax = newMin + (e.NewMax - e.NewMin);
    }
    else if (newMax > xAxisRestrictMax)
    {
        overridden = true;
        newMax = xAxisRestrictMax;
        newMin = newMax - (e.NewMax - e.NewMin);
    }
    if (overridden)
    {
        e.CancelRendering = true;

        newMin = Math.Max(newMin, xAxisRestrictMin);
        newMax = Math.Min(newMax, xAxisRestrictMax);

        _chart.BeginUpdate();
        e.Axis.SetRange(newMin, newMax);
        _chart.EndUpdate();
    }
    ...DoStuff(newMin, newMax);
}

And maybe you could change "mm:ss" to "hh:mm:ss"? Please? :-)

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

Re: AxisValueType.DateTime

Post by ArctionPasi » Fri Sep 02, 2016 9:16 am

To prevent negative values, you can define date origin to say year 1900.

The axis range limiting you are using is currently probably the best approach and should be fully working.

mm:ss issue: changed. Available in next update.
LightningChart Support Team, PT

ahe
Posts: 51
Joined: Tue Aug 11, 2015 4:33 pm
Location: Düsseldorf, DE

Re: AxisValueType.DateTime

Post by ahe » Fri Sep 02, 2016 9:58 am

Thank you very much :-)