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

Color columns in bar chart with global pallete

3 Answers 41 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Oleg
Top achievements
Rank 1
Oleg asked on 09 Sep 2013, 11:35 AM
Hi, according to sample, i am coloring columns using DataTemplate. At the same page, i use the same colors to color Pie chart, there they are defined in the global pallete. Is there any change to use one declaration of colors to avoid copy-paste?
<Grid Grid.Row="1">
    <Grid.Resources>
        <telerikChart:ChartPalette x:Key="paletteEntryCollection">
            <telerikChart:ChartPalette.GlobalEntries>
                <telerikChart:PaletteEntry Fill="#207098" Stroke="{StaticResource PhoneForegroundBrush}" />
            </telerikChart:ChartPalette.GlobalEntries>
        </telerikChart:ChartPalette>
    </Grid.Resources>
         
    <telerikChart:RadCartesianChart Name="BarChart"
                                    Palette="{StaticResource paletteEntryCollection}" >             
 
        <telerikChart:RadCartesianChart.HorizontalAxis>
            <telerikChart:LinearAxis ShowLabels="False" />
        </telerikChart:RadCartesianChart.HorizontalAxis>
        <telerikChart:RadCartesianChart.VerticalAxis >
            <telerikChart:CategoricalAxis>
                <telerikChart:CategoricalAxis.LabelStyle>
                    <Style TargetType="TextBlock">
                        <Setter Property="FontSize" Value="20" />
                    </Style>
                </telerikChart:CategoricalAxis.LabelStyle>
            </telerikChart:CategoricalAxis>
        </telerikChart:RadCartesianChart.VerticalAxis>
                 
        <telerikChart:BarSeries ShowLabels="True" ValueBinding="Value" CategoryBinding="Category">
            <telerikChart:BarSeries.PointTemplates>
                <DataTemplate>
                    <Rectangle Fill="#207098"/>
                </DataTemplate>
            </telerikChart:BarSeries.PointTemplates>
        </telerikChart:BarSeries>
    </telerikChart:RadCartesianChart>
</Grid>
 

3 Answers, 1 is accepted

Sort by
0
Deyan
Telerik team
answered on 12 Sep 2013, 07:09 AM
Hi Oleg,

Thanks for writing.

As far as I understand the scenario, you may try to additionally define the colors as static resources in the Grid's resource dictionary and reference them when needed?

Regards,
Deyan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINDOWS PHONE 7.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Oleg
Top achievements
Rank 1
answered on 15 Sep 2013, 05:12 AM
Yes i can, then i will have the same colors two times - in chart pallete and in datapoints templates
0
Rosy Topchiyska
Telerik team
answered on 18 Sep 2013, 04:52 PM
Hi Oleg,

You can use a value converter when setting the Fill property of the Rectangle in the  template to get the index of the corresponding DataPoint and convert it to a PaletteEntry. I have attached a sample runnable application that demonstrates how this can be achieved in practice.

I hope this helps. Please, do not hesitate to contact us if there is anything else we can assist you with.

Regards,

Rositsa Topchiyska
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINDOWS PHONE 7.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
Chart
Asked by
Oleg
Top achievements
Rank 1
Answers by
Deyan
Telerik team
Oleg
Top achievements
Rank 1
Rosy Topchiyska
Telerik team
Share this question
or