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

RadCartesianChart - Change series color per category from palette

3 Answers 341 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Cameron
Top achievements
Rank 1
Cameron asked on 17 May 2014, 05:10 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
Peshito
Telerik team
answered on 21 May 2014, 07:29 AM
Hi Cameron,

I replied to your question in the other thread you have started. I would suggest to keep the conversation in a single thread so it is easier for both sides to follow. I am also pasting the same answer here for your convenience:

"From the code shared is seems like 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
Cameron
Top achievements
Rank 1
answered on 21 May 2014, 01:31 PM
The palette applies fine, I just want each series in each category to be different colors instead of the entire category being the same color as shown in the pictures.

As to the smartlabels, turning showlabel to true does nothing for the smart labels.  There are no lines or no smart rounding.
0
Cameron
Top achievements
Rank 1
answered on 21 May 2014, 06:46 PM
I figured it out.  I did not have my data aggregated quite right.  
Tags
Chart
Asked by
Cameron
Top achievements
Rank 1
Answers by
Peshito
Telerik team
Cameron
Top achievements
Rank 1
Share this question
or