This is a migrated thread and some comments may be shown as answers.

How to apply DefaultVisualStyle in ScatterSeriesDescriptor.Style

4 Answers 398 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Joel
Top achievements
Rank 1
Iron
Joel asked on 24 Mar 2015, 01:11 PM
    <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?

4 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 25 Mar 2015, 09:15 AM
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.

 
0
Joel
Top achievements
Rank 1
Iron
answered on 25 Mar 2015, 09:59 AM
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?
0
Accepted
Martin Ivanov
Telerik team
answered on 27 Mar 2015, 03:08 PM
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.

 
0
Joel
Top achievements
Rank 1
Iron
answered on 30 Mar 2015, 01:44 AM
Hi Martin,
  Thanks for the suggestion.
   I will stay with setting the Palette for now.
Tags
ChartView
Asked by
Joel
Top achievements
Rank 1
Iron
Answers by
Martin Ivanov
Telerik team
Joel
Top achievements
Rank 1
Iron
Share this question
or