Skip to content

Allow to not show Grid Lines on Charts #66

Description

@amitaypb

Hello,

I am using your Charts and I would like to have the possibility to be able to hide and show the Grid Lines of Charts.
I was checking your code and when getting the Axes of a Chart, you are setting the axis.ShowGridLines = true (this is done on the protected override void GetAxes(DataPoint firstDataPoint) method)

Can you please add a ShowGridLines dependency Property to the DataPointSingleSeriesWithAxes class and use it on the GetAxes method of each Chart?

For instance:

On DataPointSingleSeriesWithAxes class:

///


/// Gets or sets a value indicating whether grid lines should be shown.
///

[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "GridLines", Justification = "This is the expected casing.")]
public bool ShowGridLines
{
get { return (bool)GetValue(ShowGridLinesProperty); }
set { SetValue(ShowGridLinesProperty, value); }
}

    /// <summary>
    /// Identifies the ShowGridLines dependency property.
    /// </summary>
    [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "GridLines", Justification = "This is the expected capitalization.")]
    [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "GridLine", Justification = "This is the expected capitalization.")]
    public static readonly DependencyProperty ShowGridLinesProperty =
        DependencyProperty.Register(
            "ShowGridLines",
            typeof(bool),
            typeof(DataPointSingleSeriesWithAxes),
            new PropertyMetadata(true));

And on ColumnSeries.cs, BarSeries.cs, etc

protected override void GetAxes(DataPoint firstDataPoint)
{
...
if (axis != null)
{
axis.ShowGridLines = ShowGridLines; //Use the value of the Dependency Property
}
...
}

With that, we can do something like (To hide the Grid Lines):
<chartingToolkit:ColumnSeries Grid.Row="0"
Grid.Column="0"
DependentValuePath="Value"
IndependentValuePath="Key"
ItemsSource="{Binding Data}"
ShowGridLines="False"/>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions