WpfToolkit icon indicating copy to clipboard operation
WpfToolkit copied to clipboard

Allow to not show Grid Lines on Charts

Open amitaypb opened this issue 2 years ago • 2 comments

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"/>

amitaypb avatar Nov 04 '22 17:11 amitaypb

您好,我现在正在忙,可能无法亲自回复您的邮件。我将以最快的速度,尽快给您回复。 

icehoo avatar Nov 04 '22 17:11 icehoo

if you create a pull req for this, i will merge

jogibear9988 avatar Dec 17 '22 14:12 jogibear9988