Set bar chart label via code

2 posts, 0 answers
  1. DMM
    DMM avatar
    8 posts
    Member since:
    May 2010

    Posted 15 Jun 2012 Link to this post

    BarSeries series = new BarSeries();                 
    series.CategoryBinding = new PropertyNameDataPointBinding() { PropertyName = "Name" };                 
    series.ValueBinding = new PropertyNameDataPointBinding() { PropertyName = "Value" };                 
    series.ShowLabels = true;                 
    series.ItemsSource = points;

    My ItemsSource is just a list of my datapoint class.
    How do I set the label for each point?
    I can do it via xaml easy enough. How about code?

    <telerik:CategoricalDataPoint Category="1" Value="0.05" Label="Some Point Specific Text"> 

    I tried and failed with
                 <telerik:BarSeries.LabelDefinitions > 
                        <telerik:ChartSeriesLabelDefinition >
                                        <TextBlock Text="{Binding}"></TextBlock>
                                             <Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type telerik:BarSeries}}" 
  2. Petar Marchev
    Petar Marchev avatar
    996 posts

    Posted 19 Jun 2012 Link to this post

    Hi David,

    Currently it is not possible to have access to the DataItem from the label template. I have discussed this with our developers and we think that it will be of great help to have access to both the value and the data item. This is why I have logged this as a feature request here in our PITS where you can vote for the feature and track its status.

    We are sorry for the inconvenience. I have updated your Telerik points as a thank you for pointing this issue to us and helping us improve our products.

    Petar Marchev
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top