We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

TextLabel, relative positioning and applying a background.

Hello again,

I couldn't find anything in the documentation so I assume that it's either not documented or not a feature, but I figured I should ask. Is it possible to apply a TextLabel in a SfChart:
  1. With relative positioning? Meaning having the label always at the same place with respect to the chart, without having to toy with X and Y positioning myself.
  2. With a white background? Currently it's hard to read the label because of the lines of the chart. It would be neat to be able to specify a background color in order to keep it readable.
Thank you for your help.

Regards,
Jeremie

3 Replies

RA Rachel A Syncfusion Team November 10, 2015 09:45 AM UTC

Hi Jeremie,

Thanks for contacting Syncfusion support.

We can achieve your requirement by using TextAnnotation in SfChart. TextAnnotation is used to add text inside chart area. We have prepared the sample for your reference and you can download the sample from the following location.

Chart_WPF_Sample

Please find the following UG documentation to know more about TextAnnotation.

http://help.syncfusion.com/wpf/sfchart/annotations#textannotation

Regards,
Rachel. A


JC Jeremie Clos November 11, 2015 02:29 PM UTC

Thanks Rachel it looks good.

One other question on the same topic: I want to bind the location of this Label to an expression that depends partly on the width of a Column in a ColumnSeries. How do I retrieve the width of columns?


SJ Sumathi Jayaraj Syncfusion Team November 12, 2015 12:02 PM UTC

Hi Jeremie,

Thanks for the update.

We have analyzed your requirement and we are able to calculate the individual segment width as per the below code snippet. 

Code snippet[C#]:



//To calculate the column segment width        

private void chart_Loaded(object sender, RoutedEventArgs e)

{

    var segmentsCount = (series.ItemsSource asObservableCollection<Model>).Count;

    var segmentWidth = chart.SeriesClipRect.Width / segmentsCount;

    var columnSgmtWidth = segmentWidth * (1- ChartSeries.GetSpacing(series));
}


 
Regards,
Sumathi J

Loader.
Live Chat Icon For mobile
Up arrow icon