Labels over current values

2 posts, 0 answers
  1. David
    David avatar
    3 posts
    Member since:
    Apr 2013

    Posted 11 Sep 2015 Link to this post

    I have been asked to implement functionality so that as the user moves over a chart comprised of line series, that not only does an ellipse get drawn at the datapoints in the same vertical area of the chart but a label above the datapoints as well. To help visualize, imagine the "Zooming and Scrolling" ChartView example. In the top chart there is an area series being rendered in blue. As you move the mouse over the chart a dot is rendered over the point closest to the cursor. The users have asked for not only a dot, but the chart Y value displayed above the dot (in this example, the price). I recognize that this example is utilizing the trackball functionality of the chart, but I can't quite figure out how to get a label to appear above each series dot with the values. Any suggestions?
  2. Martin Ivanov
    Martin Ivanov avatar
    1408 posts

    Posted 16 Sep 2015 Link to this post

    Hi David,

    You can achieve your requirement using the approach with the trackball from the Zooming and Scrolling example along with custom LabelDefinition for the series. Basically, you can show the labels of the series, then define a property in the data points view model that tells if a point's label should be visible. After, this you can define a Template for the custom label definition and bind the Visibility of the element int he template to the property in the view model. You can use the TrackInfoUpdated event of the trackball behavior to get the highlighted data points and set the property that determines the visibility of the label. 

    For your convenience I attached a sample project demonstrating this approach. Please give it a try and let me know if you need any further assistance.

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top