Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
3220
xamDataChart: Show last value in legend
posted

Hello,

Is there an easy why to show always the last value from the series in the legend?

Parents
No Data
Reply
  • 2700
    Offline posted

    Hello Bin,

    Thank you for posting to Infragistics Community!

    I have been looking into your question and created a small sample with a XamDataChart with ColumnSeries demonstrating how your requirement about only showing the last item’s value in the legend can be achieved.

    A custom LegendItemTemplate DataTemplate can be created for the target series. For the purposes of the example, the template is really simple, however it can be styled as per your taste. The TextBlock within it is bound to the corresponding Series’ ItemsSource. With the help of a converter, returning the last item of a collection, the last object’s target property value is accessed and a custom string is returned from the Convert method. This is what is finally shown in the legend. This is simply one approach to how this can be achieved, for example you could keep the last item of the collection in your view model or local data, so that the binding does not use a converter.

    Please, test the below attached sample on your side and if you require any further assistance on the matter, please let me know.

    Sincerely,
    Bozhidara Pachilova
    Associate Software Developer

    2308.XDCLegendLastSeriesItem.zip

Children