Profile Picture

Using fixed date units for each row of the NRangeTimelineScaleConfigurator

Posted By Irene 12 Years Ago
Author
Message
Irene
Posted 12 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: Forum Members
Last Active: 12 Years Ago
Posts: 2, Visits: 1
Hi!
I need to plot data with different date range (from few days, to several years), and I want to use fixed date units for each row: first row always shows days, second - months, third – years.
For small ranges, all three rows should be visible, for big ranges (several years) – only third.
Different rows should not display the same date units.
How should I configure the scale to satisfy the above requirements?


Nevron Support
Posted 12 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009

Hi Irene,

You should configure the scale to use Custom step for each row - the following configuration replicates your first case (when the date range is small):

   NChart chart = nChartControl1.Charts[0];

   NRangeTimelineScaleConfigurator rangeScale = new NRangeTimelineScaleConfigurator();

   rangeScale.FirstRow.TickMode = TimelineScaleRowTickMode.Custom;
   rangeScale.FirstRow.CustomStep = new NDateTimeSpan(1, NDateTimeUnit.Day);

   rangeScale.SecondRow.TickMode = TimelineScaleRowTickMode.Custom;
   rangeScale.SecondRow.CustomStep = new NDateTimeSpan(1, NDateTimeUnit.Month);

   rangeScale.ThirdRow.TickMode = TimelineScaleRowTickMode.Custom;
   rangeScale.ThirdRow.CustomStep = new NDateTimeSpan(1, NDateTimeUnit.Year);

   NLineSeries line = new NLineSeries();
   chart.Series.Add(line);

   line.UseXValues = true;
   line.DataLabelStyle.Visible = false;

   DateTime current = DateTime.Now;
   TimeSpan span = new TimeSpan(0, 4, 0, 0);

   Random rand = new Random();

   for (int i = 0; i < 100; i++)
   {
    line.Values.Add(rand.Next(100));
    line.XValues.Add(current);

    current += span;
   }

For the second case you should simply set the visibility of the second and third rows to hidden:

rangeScale.FirstRow.Visible = false;
rangeScale.SecondRow.Visible =
false;

Hope this helps - let us know if you meet any problems or have any questions.



Best Regards,
Nevron Support Team



Irene
Posted 12 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: Forum Members
Last Active: 12 Years Ago
Posts: 2, Visits: 1
Thank you for your response.
But I need to prevent labels from overlapping and word wrapping (labels must occupy a single row). How can I achieve this?
Also is it possible to automatically hide/show scale rows depending on scale range and zoom level?


Nevron Support
Posted 12 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009

Hi Irene,

It's not possible to remove overlapping labels in a range scale - this is because all labels in fact do not overlap as they are generated for non overlapping ranges. You'll probably need to create a custom scale in this case. Please send a request to support@nevron.com with complete requirements.



Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic