Line Chart - only show every other x-axis label


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

By Kandis Hoyt - 13 Years Ago

Hello - I need some help please.

I created a basic line chart that has data by week of year (01-52). I chose the option for categorical for the scale mode (although auto works as well). The text become very small when I deleted the checkbox to stagger the labels and only use the Autoscale option. I want to show only every other data label (ex. 01, 03, 05 etc.). Is there a way to do this?

Thanks!

By Nevron Support - 13 Years Ago

Hi Kandis,
You can achieve this with some custom code - 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];

NOrdinalScaleConfigurator scaleX = chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NOrdinalScaleConfigurator;
if (scaleX != null)
{
scaleX.MajorTickMode = MajorTickMode.CustomStep;
scaleX.CustomStep = 1;
scaleX.NumberOfTicksPerLabel = 2;
scaleX.LabelStyle.ContentAlignment = ContentAlignment.MiddleCenter;
scaleX.DisplayDataPointsBetweenTicks = false;
}
}
}
}

shows a label at every two ticks. Hope this helps - let us know if you meet any problems.

 

By Kandis Hoyt - 13 Years Ago
This worked. Thank you very much!