Change series color per category from palette

4 posts, 0 answers
  1. Cameron
    Cameron avatar
    6 posts
    Member since:
    Dec 2013

    Posted 16 May 2014 Link to this post

    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>
  2. Cameron
    Cameron avatar
    6 posts
    Member since:
    Dec 2013

    Posted 16 May 2014 Link to this post

    Sorry, just noticed this is the wrong forum.  Can someone move it to WPF?
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 21 May 2014 Link to this post

    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.
     
  5. Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 21 May 2014 Link to this post

    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.
     
Back to Top