Configure the Chart Web Part date time axis label formatting

Applies to: Nevron Chart for SharePoint (WSS3.0, SharePoint 2007/2010/2013)

How to configure the Chart Web Part date time axis label formatting?

Let's say that you have a XY scatter chart which uses Date Time axis and you need to change the formatting of the axis labels.

In Nevron Chart for SharePoint, you can easily configure the Date Time Axis Label Formatting by using custom code.

using System;
using System.Drawing;
using Nevron.Dom;
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;
                                    dateTimeScale.EnableUnitSensitiveFormatting = false;
                                    dateTimeScale.LabelValueFormatter = new NDateTimeValueFormatter("HH:mm"); //some Date Time Format String

Imports System
Imports System.Drawing
Imports Nevron.Dom
Imports Nevron.GraphicsCore
Imports Nevron.Chart
Imports Nevron.ReportingServices
Namespace MyNamespace
    ''' <summary>
    ''' Sample class
    ''' </summary>
    Public Class [MyClass]
        ''' <summary>
        ''' Main entry point
        ''' </summary>
        ''' <param name="context"></param>
        Public Shared Sub RSMain(context As NRSChartCodeContext)
            Dim chart As NChart = context.Document.Charts(0)
            Dim dateTimeScale As NDateTimeScaleConfigurator = TryCast(chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator, NDateTimeScaleConfigurator)
            dateTimeScale.EnableUnitSensitiveFormatting = False
            dateTimeScale.LabelValueFormatter = New NDateTimeValueFormatter("HH:mm")
            'some Date Time Format String
        End Sub
    End Class
End Namespace

Article ID: 192, Created On: 6/22/2011, Modified: 1/29/2013