Show every second label on the chart web part X axis

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

How to show every second label on the chart web part X axis?

In Nevron Chart for SharePoint you can use Custom Code injection to change the X or Y axis labels display sequence.



The following code example can be used to display labels at every fourth tick for the X axis and every second tick for the Y axis:

[C#]
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];
                   
                  NStandardScaleConfigurator scaleX = chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NStandardScaleConfigurator;
                  scaleX.NumberOfTicksPerLabel = 4;
 
                  NStandardScaleConfigurator scaleY = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NStandardScaleConfigurator;
                  scaleY.NumberOfTicksPerLabel = 2;
            }
      }
}

[VB.NET]
Imports System
Imports System.Drawing
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 scaleX As NStandardScaleConfigurator = TryCast(chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator, NStandardScaleConfigurator)
            scaleX.NumberOfTicksPerLabel = 4
 
            Dim scaleY As NStandardScaleConfigurator = TryCast(chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator, NStandardScaleConfigurator)
            scaleY.NumberOfTicksPerLabel = 2
        End Sub
    End Class
End Namespace

Article ID: 183, Created On: 3/9/2011, Modified: 1/29/2013