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

LineSeries: how to show some labels, some not?

2 Answers 190 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 2
Michael asked on 06 Dec 2012, 10:39 PM
Hello,

I would like my chart to consists of a LineSeries that does not have labels shown on every node. For this, I have bound the ItemsSource of the LineSeries to an ObservableCollection<MyCrazyLineNode>. MyCrazyLineNode has Properties for the Value, the Category and an additional Property "IsValueVisible".

I tried to accomblish this by setting "ShowLabels" to "False" and define my own labels in the PointTemplate.
My code looks similar to this:
<telerik:LineSeries ItemsSource="{Binding MyCrazyLineNodes}" ValueBinding="Value" CategoryBinding="Category" ShowLabels="False">
  <telerik:LineSeries.PointTemplate>
    <DataTemplate>
      <Grid>
        <Canvas Margin="0,10,0,0" Visibility="{Binding IsValueVisible, [Converter stuff...}">
          <TextBlock Text="{Binding Value}" />
        </Canvas>
        <Path Data="M4,0 L8,4 L4,8 L0,4 Z" Fill="Red" Width="8" Height="8" Stretch="Fill" />
      </Grid>
    </DataTemplate>
  </telerik:LineSeries.PointTemplate>
  <AxisStuffAndSoOn />
</telerik:LineSeries>

However, this does not work, because I cannot bind to the Property IsValueVisible.
How can I do what I want? I hope my problem is understandable. ;-)

Best Regards
Michael

2 Answers, 1 is accepted

Sort by
0
Accepted
Missing User
answered on 11 Dec 2012, 05:16 PM
Hi Michael,

The easiest way to do this is to create a new property (which is either an empty string or the value you need to show), use the LabelDefinitions and set the Binding property. Please refer to the attached sample project.

All the best,
Ivan N.
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Michael
Top achievements
Rank 2
answered on 12 Dec 2012, 11:03 AM
Thanks a lot!

Best regards,
Michael Hilus
Tags
Chart
Asked by
Michael
Top achievements
Rank 2
Answers by
Missing User
Michael
Top achievements
Rank 2
Share this question
or