X-axis dates with inconsistent time-intervals


Author
Message
Vahid Mesri
Vahid Mesri
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)
Group: Forum Members
Posts: 11, Visits: 67
Hi,

In my smooth-line plot, the x-values are dates and the y-values are percentages.
The issue is that I have monthly values at the beginning section of my plot, however, after two years, the dates are updated on yearly basis, therefore the dates do not have consistent intervals.

Please find attached the plot I've created using the Microsoft chart control. I would like to use Nevron to reproduce this plot but unfortunately it treats the dates as categories and not datetime variables.

Thanks a lot for your help Smile

 https://www.nevron.com/forum/uploads/images/d3035e64-c2a9-4868-96e6-197d.png


Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K
Hello Vahid,
This is caused by the default axis scaling. You can use the following custom C# code:
using System;
using System.Drawing;
using Nevron.GraphicsCore;
using Nevron.Chart;
using Nevron.ReportingServices;

namespace MyNamespace
{
      /// <summary>
      /// Sample class
      /// </summary>
      public class MyClass
      {
           /// <summary>
           /// Main entry point
           /// </summary>
           /// <param name="context"></param>
           public static void RSMain(NRSChartCodeContext context)
           {
                NChart chart = context.document.Charts[0];
                NDateTimeScaleConfigurator dateTimeScale = chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NDateTimeScaleConfigurator;

                if (dateTimeScale != null)
                {
                      bool hasMin = false;
                      DateTime minValue = new DateTime();
                      foreach (NSeriesBase series in chart.Series)
                      {
                           NXYScatterSeries xyScatter = series as NXYScatterSeries;

                           if (xyScatter != null && xyScatter.XValues.Count > 0)
                           {
                                DateTime curXValue = DateTime.FromOADate((double)xyScatter.XValues[0]);
                                if (hasMin)
                                {
                                      minValue = minValue < curXValue ? minValue : curXValue;
                                }
                                else
                                {
                                      hasMin = true;
                                      minValue = curXValue;
                                }
                           }
                      }

                      if (hasMin)
                      {
                           dateTimeScale.UseOrigin = true;

                           dateTimeScale.Origin = new DateTime(minValue.Year, minValue.Month, 1, 0, 0, 0);
                      }
                }
           }
      }
}



Best Regards,
Nevron Support Team


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search