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

Change series color per category from palette

3 Answers 139 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Cameron
Top achievements
Rank 1
Cameron asked on 16 May 2014, 06:22 PM
I have searched and searched, but cannot figure out how to have each bar in each series be a different color from the bound palette per category.  Is this doable?  It appears so if you manually create each series, but my series are dynamic.  Attached is the markup for my chart control in its current state.

I also cannot get the smart labels to do anything.  I'm not sure if I have declare the strategy correctly or not.

<telerik:RadCartesianChart Palette="{Binding Palette}"
                                      telerik:ChartSeriesProvider.IsDynamicSeries="True"
                                      TooltipTemplate="{StaticResource BarChartTemplate}"
                                      HoverMode="FadeOtherSeries">              
               <telerik:RadCartesianChart.SmartLabelsStrategy>
                   <telerik:ChartSmartLabelsStrategy/>
               </telerik:RadCartesianChart.SmartLabelsStrategy>
               <telerik:RadCartesianChart.VerticalAxis>
                   <telerik:LinearAxis LabelFormat="N2"/>
               </telerik:RadCartesianChart.VerticalAxis>
               <telerik:RadCartesianChart.HorizontalAxis>
                   <telerik:CategoricalAxis />
               </telerik:RadCartesianChart.HorizontalAxis>
               <telerik:RadCartesianChart.SeriesProvider>
                   <telerik:ChartSeriesProvider Source="{Binding BarData}">
                       <telerik:ChartSeriesProvider.SeriesDescriptors>
                           <telerik:CategoricalSeriesDescriptor ItemsSourcePath="ChartData"
                                                                ValuePath="Value"
                                                                CategoryPath="Category">
                               <telerik:CategoricalSeriesDescriptor.Style>
                                   <Style TargetType="telerik:BarSeries">
                                       <Setter Property="CombineMode"
                                               Value='Cluster' />                                      
                                   </Style>
                               </telerik:CategoricalSeriesDescriptor.Style>
                           </telerik:CategoricalSeriesDescriptor>
                       </telerik:ChartSeriesProvider.SeriesDescriptors>
                   </telerik:ChartSeriesProvider>
               </telerik:RadCartesianChart.SeriesProvider>
           </telerik:RadCartesianChart>

3 Answers, 1 is accepted

Sort by
0
Cameron
Top achievements
Rank 1
answered on 17 May 2014, 12:43 AM
Sorry, just noticed this is the wrong forum.  Can someone move it to WPF?
0
Peshito
Telerik team
answered on 21 May 2014, 07:26 AM
Hello Cameron,

From the code shared is seems like your there is something wrong with your Palette binding. I had no issues applying a palette using the same scenario as you did. Please check if you have set a value for your Palette in the code behind. For instance:
public MainViewModel()
{
    this.Data = GetSampleData();
    this.Palette = ChartPalettes.Windows8;
}
You can also take a look at our online demo example showing the same approach.

Regarding the question about smart labels, your strategy seems to be declared fine, however I see that your series has no labels displayed. In order to show them, use the "ShowLabels" property.
<telerik:CategoricalSeriesDescriptor.Style>
    <Style TargetType="telerik:BarSeries">
        <Setter Property="CombineMode"
                Value='Cluster' /> 
         <Setter Property="ShowLabels" Value="True"/>                                             
    </Style>
</telerik:CategoricalSeriesDescriptor.Style>
Hope that helps.

Regards,
Peshito
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Peshito
Telerik team
answered on 21 May 2014, 07:31 AM
Hi Cameron,

This is a follow up to my previous answer. As I forgot to provide a link to the demo example, I am doing this now.

Link to Palette online demo example.

Regards,
Peshito
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
ChartView
Asked by
Cameron
Top achievements
Rank 1
Answers by
Cameron
Top achievements
Rank 1
Peshito
Telerik team
Share this question
or