Month end date for X-Axis label


https://www.nevron.com/Forum/Topic7633.aspx
Print Topic | Close Window

By Tanawit Boonteppratan - 11 Years Ago
Hello,

I have an Area chart SubType "XY Scatter (3)"
The Primary X Axis Scale-> SubType is DateTime.
The data is daily, the Axis label is displaying beginning of the month.
Is there a way to make the X-Axis labels display month end date instead?
IE instead of 1/1/2013 can the X-Axis display 1/31/2013 ?

Thank you
By Nevron Support - 11 Years Ago

Hi Tanawit,

You can use custom code to apply an offset to the actual formatted value of the labels - for example:

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 scale = chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NDateTimeScaleConfigurator;
   
   if (scale != null)
   {
    DateTime dt1 = new DateTime();
    DateTime dt2 = dt1.AddMinutes(1);

    scale.LabelStyle.ValueOffset -= dt2.ToOADate() - dt1.ToOADate();
   }
  }
 }
}


Configures the chart to display the previous day so if you have a label 1/2/2013 it will be actaully formatted as 31/1/2013. Hope this helps - let us know if you meet any problems...

By Swathi Sadasivam - 11 Years Ago
Regarding the same issue
How to set the interval range so that the dates corresponding to the range interval is plotted instead of the first days of months?

Similar to the date range in the screenshot added.
By Nevron Support - 11 Years Ago
Hi Swathi,

Can you elaborate on this question?