How to apply DefaultVisualStyle in ScatterSeriesDescriptor.Style

5 posts, 1 answers
  1. Joel
    Joel avatar
    53 posts
    Member since:
    Sep 2013

    Posted 24 Mar 2015 Link to this post

        <telerik:RadCartesianChart.SeriesProvider>
            <telerik:ChartSeriesProvider Source="{Binding CieDatums, Mode=OneWay}">
                <telerik:ChartSeriesProvider.SeriesDescriptors>
                    <telerik:ScatterSeriesDescriptor  ItemsSourcePath="Value" XValuePath="X" YValuePath="Y" CollectionIndex="0">
                        <telerik:ScatterSeriesDescriptor.Style>
                            <Style TargetType="telerik:ScatterPointSeries">
                                <Setter Property="RenderOptions" Value="{StaticResource renderOptions}" />
                                <Setter Property="ShowLabels" Value="{Binding IsShowLabel, Mode=OneWay}"/>
                                <Setter Property="PointSize" Value="5,5"/>
                                <!-- Not able to apply DefaultVisualStyle,  -->
                                <Setter Property="DefaultVisualStyle">
                                    <Setter.Value>
                                        <Style TargetType="{x:Type Path}">
                                            <Setter Property="Fill" Value="Black"/>
                                        </Style>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </telerik:ScatterSeriesDescriptor.Style>
                    </telerik:ScatterSeriesDescriptor>
                </telerik:ChartSeriesProvider.SeriesDescriptors>
            </telerik:ChartSeriesProvider>
        </telerik:RadCartesianChart.SeriesProvider>
    </telerik:RadCartesianChart>

    I am trying to set the Point fill color to Black. DefaultVisualStyle seems to have no effect. 
    What is the proper way of applying DefaultVisualStyle in ScatterSeriesDescriptor.Style?
  2. Martin
    Admin
    Martin avatar
    1099 posts

    Posted 25 Mar 2015 Link to this post

    Hello Joel,

    Indeed, this is the proper way of applying the DefaultVisualStyle in a SeriesDescriptor. However, keep in mind that the chart's Palette has a bigger priority than the default visual style - in other words, if the Palette property is set the DefaultVisualStyle of the series will be ignored.

    I tested the reported behavior but I was not able to reproduce it without using a palette. If this is not the case, I would ask you to send me a sample project or a runnable code snippets that demonstrates the issue. This information will help me to investigate what is causing the described behavior.

    Regards,
    Martin
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Joel
    Joel avatar
    53 posts
    Member since:
    Sep 2013

    Posted 25 Mar 2015 in reply to Martin Link to this post

    Hi Martin,

      Indeed the Palette is set in my code. 
      I am just wondering is there a way to skip/ignore the Palette so that i can use the DefaultVisualStyle to set the point color?
  5. Answer
    Martin
    Admin
    Martin avatar
    1099 posts

    Posted 27 Mar 2015 Link to this post

    Hello Joel,

    You cannot change the precedence of setting the data points' colors. However, if the entries in the palette that targets the point series are missing, there won't be any colors for them and the chart will  use the default visual style instead.

    To use palette for the other series, different then the one that uses DefaultVisualStyle, you can create a custom palette that targets only particular series - the ones that you want to be affected by the palette.
    <Window.Resources>
        <telerik:ChartPalette x:Key="customPalette">
            <telerik:ChartPalette.SeriesEntries>
                <telerik:PaletteEntryCollection SeriesFamily="Pie">
                    <telerik:PaletteEntry Fill="#FF1FAFD3" Stroke="White"/>
                    <telerik:PaletteEntry Fill="#FFC32E0A" Stroke="White"/>
                    <telerik:PaletteEntry Fill="#FFFA6F5E" Stroke="White"/>
                </telerik:PaletteEntryCollection>
                <telerik:PaletteEntryCollection SeriesFamily="Bar">
                    <telerik:PaletteEntry Fill="#FF006968" Stroke="White"/>
                    <telerik:PaletteEntry Fill="#FF7A6CC4" Stroke="White"/>
                    <telerik:PaletteEntry Fill="#FF1FAFD3" Stroke="White"/>
                </telerik:PaletteEntryCollection>
                <!-- etc. -->
            </telerik:ChartPalette.SeriesEntries>
        </telerik:ChartPalette>
    </Window.Resources>

    <telerik:RadCartesianChart Palette="{StaticResource customPalette}">
    Or you can copy some of the predefined palettes and remove their PaletteEntryCollections that targets the series that you do not want to color - ScatterPointSeries for example.
    var myPalette = new ChartPalette();           
    foreach (var seriesEntry in ChartPalettes.Windows8.SeriesEntries)
    {
        if (seriesEntry.SeriesFamily != "Point")
        {
            myPalette.SeriesEntries.Add(seriesEntry);
        }               
    }
     
    this.chart.Palette = myPalette;

    Please let me know if this helps.

    Regards,
    Martin
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  6. Joel
    Joel avatar
    53 posts
    Member since:
    Sep 2013

    Posted 29 Mar 2015 Link to this post

    Hi Martin,
      Thanks for the suggestion.
       I will stay with setting the Palette for now.
Back to Top
UI for WPF is Visual Studio 2017 Ready