Nevron Forum

NDateTimeScaleConfigurator AutoScale: current format

https://www.nevron.com/Forum/Topic5735.aspx

By Alina Voskova - Tuesday, October 18, 2011

Hello.
I use autoscale for OX axis like this:
List dateTimeUnits = new List();

dateTimeUnits.Add(NDateTimeUnit.Second);
dateTimeUnits.Add(NDateTimeUnit.Minute);
dateTimeUnits.Add(NDateTimeUnit.Hour);
dateTimeUnits.Add(NDateTimeUnit.Day);
dateTimeUnits.Add(NDateTimeUnit.Month);
dateTimeUnits.Add(NDateTimeUnit.Year);

var autoUnits = dateTimeUnits.ToArray();

dateConfigurator.MajorTickMode = MajorTickMode.AutoMaxCount;

dateConfigurator.InflateViewRangeBegin = false;
dateConfigurator.InflateViewRangeEnd = true;

dateConfigurator.EnableUnitSensitiveFormatting = true;
dateConfigurator.AutoDateTimeUnits = autoUnits;
dateConfigurator.LabelValueFormatter = new NDateTimeValueFormatter("dd.MM HH:mm:ss");
The value format depends on graph's scale. How I can determine the current Date-time unit and value format in axes's properties?
By Nevron Support - Wednesday, October 19, 2011

Hi Ereona,

You cannot get the date time unit selected by the scale, however you can change the value format that corresponds to a unit - for example:

someDateTimeScale.DateTimeUnitFormatterPairs.DayFormatter = new NDateTimeValueFormatter(DateTimeValueFormat.DateHour);

changes the default day formatting to day + hour. The other units have similar properties, SecondFormatter, MinuteFormatter etc.

By Alina Voskova - Wednesday, October 19, 2011

I need to format one additional value (not on the axis) like the values are formatted on axis. If I set the format manually, I can do it:
label.Text = ((NStandardScaleConfigurator)xAxis.ScaleConfigurator).LabelValueFormatter.FormatValue(value);
But with autoformat it's impossible, isn't so?
By Nevron Support - Wednesday, October 19, 2011

Hi Ereona,

The standard formatters rely that the value is of type double - they do not try to convert for performance reasons and may fail if used in such context. What is the value you pass there? 

By Alina Voskova - Thursday, October 20, 2011

The value is correct double value. Without autoformat I get the correct string - the value is formatted like value on axis. But with autoformat I get the string with default format (which I set for LabelValueFormatter), not with current.