RadCartesianChart - Change series color per category from palette

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

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

    Posted 21 May 2014 Link to this post

    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.
     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Cameron
    Cameron avatar
    6 posts
    Member since:
    Dec 2013

    Posted 21 May 2014 in reply to Peshito Link to this post

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

    Posted 21 May 2014 Link to this post

    I figured it out.  I did not have my data aggregated quite right.  
Back to Top