Knowledgebase
Turning Gridlines, Axis Labels On or Off
Posted by Admin - on 13 February 2019 06:26 PM

To see a documentation on this topic please refer to the Axis Styling - Styling Gridlines, Tick Lines and Labels article.

Modifying Axis Properties

In our Examples Suite we have the Modify Axis Properties demo example which shows how to turn Gridlines on or off, as well as modify other 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 setting Axis.Visibility = Collapsed will not only hide the Axis, but will also prevent WPF Bindings 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 Gridlines 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"/>

Further Reading

For more information and examples on Axis Styling, please refer to our documentation:

(6 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