SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components

0
0

There are multiple Y axes in my chart. I am displaying grid lines only for the primary axis and I would like to change its color. Please let me know how it might be possible.
I have tried style and it works for X axis (single axes) but doesn’t for Y axes (multiple)

    <Style x:Key="MajorGridLineStyle" TargetType="Line">
        <Setter Property="Stroke" Value="Red"/>
    </Style>


        <s:SciChartSurface.XAxis>
            <s:NumericAxis AxisTitle="{Binding XAxisTitle}" DrawMajorBands="False" DrawMinorGridLines="False" DrawMinorTicks="False"
                           MajorGridLineStyle="{StaticResource MajorGridLineStyle}"/>
        </s:SciChartSurface.XAxis>

I have also tried majorgridlinebrush in my viewmodel but it doesn’t work. Some default color is show for the gridlines

        YAxes.Add(new NumericAxisViewModel
        {
            DrawMajorBands = false,
            DrawMinorGridLines = false,
            DrawMinorTicks = false,
            MajorGridLinesBrush = new SolidColorBrush(Colors.Red)
        });
Version
6.5
  • You must to post comments
0
0

Hi Kapil

I modified this sample I shared with you last week about Axis MVVM styling,

Added this one line to MainViewModel

    public MainViewModel()
    {
        YAxisViewModels.Add(new NumericAxisViewModel()
        {
            // Apply a style key here to apply a named style to this axis
            StyleKey = "YAxisStyle",
            AxisTitle = "Y Axis",
            MajorGridLinesBrush = Brushes.Purple // this line
        });

I was able to reproduce the problem you saw, where MajorGridLinesBrush wasn’t applied.

I suggest as a workaround now, using the AxisMVVM styling technique I previously described here.

I have also reported a bug, SC-6704 AxisViewModel.MajorGridlinesBrush seems to be ignored

Best regards
Andrew

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.