Turning Gridlines, Axis Labels On or Off
Posted by Admin - on 21 March 2014 11:19 AM

Modifying Axis Properties

In our Examples Suite we have a demo which shows how to turn gridlines on or off, as well as modify other axis properties. This example is called Modify Axis Properties.

This example allows you to

  • Show / Hide Major Gridlines and Major Ticks
  • Show / Hide Axis Labels
  • Change XAxis or YAxis TextFormatting
  • Swap YAxis from the Right to the Left
  • Manually change Axis VisibleRange

Show / Hide Gridlines Code Example

To turn the Gridlines or Labels on or off, we can use the following code:

C#

var axis = new NumericAxis();
axis.DrawMajorGridLines = true;
axis.DrawMinorGridLines = true;
axis.DrawMajorTicks = true;
axis.DrawMinorTicks = true;
axis.DrawLabels = true;

XAML

<s:NumericAxis DrawMajorGridLines="True" DrawMinorGridLines="True" DrawMajorTicks="True" DrawMinorTicks="True" DrawLabels="True"/>

Hiding an Axis (Axis Visibility)

Since Axis.Visibility = Collapsed will not only hide the axis, but will also prevent WPF databindings from working, if you want to hide an axis, you will need to take a slightly different tactic.

Turn the labels, tick lines off, while keeping Grid lines on will give the appearance of a hidden axis.

C#

var axis = new NumericAxis();
axis.DrawMajorGridLines = true;
axis.DrawMinorGridLines = true;
axis.DrawMajorTicks = false;
axis.DrawMinorTicks = false;
axis.DrawLabels = false;

XAML

<s:NumericAxis DrawMajorGridLines="True" DrawMinorGridLines="True" DrawMajorTicks="False" DrawMinorTicks="False" DrawLabels="False"/>
(2 vote(s))
Helpful
Not helpful

CONTACT US

Not sure where to start? Contact us, we are happy to help!


CONTACT US

SciChart Ltd, 16 Beaufort Court, Admirals Way, Docklands, London, E14 9XL. Email: Legal Company Number: 07430048, VAT Number: 101957725