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

series bars how change color of label Text depending if SyncFusion is moving in or out the box bar

Hello I have an issue.

I am doing a bars chart using code like below

:ColumnSeries.DataMarker>

<chart:ChartDataMarker LabelContent="Percentage" ShowLabel="True">

<chart:ChartDataMarker.LabelStyle>

<chart:DataMarkerLabelStyle

BackgroundColor="Transparent"

LabelPosition="Auto"

TextColor = "White"

BorderColor="White"

BorderThickness="1">

chart:DataMarkerLabelStyle>

chart:ChartDataMarker.LabelStyle>

chart:ChartDataMarker>

chart:ColumnSeries.DataMarker>


Using the property LabelPosition="Auto" SyncFusion automatically will move the text of the BarLabel in or out the box.

I need to change the color of the text depending by if it is moved inside or outside the bar. How I can do it?


Could you please give to me a sample starting from XAML page, explaining how access/change the text label properties = TextColor based on where SyncFusion is moving the text (based on LabelPosition)?


Just an example to better explain:

if Value = 5% the text will be moved out and being the background color = white I need color to be black

if Value is 70% in this case text will be inside and color need to be white cause background color of the bar is blue.


GC







7 Replies

IM Iyyappan Mani Syncfusion Team August 29, 2017 03:23 PM UTC

Hi Garbiele,

Thanks for using Syncfusion Products.

As per your requirement, we have prepared a workaround sample using LabelTemplate Property in DataMarker. Please find the sample in below location.

Sample: http://www.syncfusion.com/downloads/support/forum/132359/ze/CustomLabel1990129899

Please let us know, if you need further assistance on this.

Thanks,
Iyyappan M.



GA Gabriele August 30, 2017 10:20 AM UTC

Hello


thanks for your reply.

My need was more to recognize how the LabelPosition=Auto was locating the text of the label and depending if inside or outside changing the color of the text.

You gave an example based on the yvalue that is not exactly what I asked. Sure that could be a sort of workaround so if not other solutions are possible it is fine.


I have another question:

Always for the chart:BarSeries I need to have e legend that will be aligned on the right to the Bars of the chart. How can I achieve this goal?


I see that for this type of Chart is not possible to define a fix widht  of the bars so how would be possible to build a custom layout structure on the right of the chart to have aligned to the bar more complex elements (like buttons, link, image...)? This for more complex layout.


BR

GC



PS Parthiban Sundaram Syncfusion Team August 30, 2017 12:41 PM UTC

Hi Gabriele,  
 
Thanks for the update. 
 
Query 1: 
 
We would like to inform you that our previous solution was the possible way to change individual data label background.  
 
Query 2: 
 
You can achieve this requirement using DockPosition in Legend. Please find the below code snippet for more details  
 
 
 
    <chart:SfChart.Legend> 
      <chart:ChartLegend DockPosition="Right"/> 
    </chart:SfChart.Legend> 
 
 
 
Query 3: 
 
We suspect that your requirement is related to customize the width of the bars which can be achieved using Width property in BarSeries. Please refer the following code snippet.  
 
 
 
<chart:BarSeries x:Name="series" ItemsSource ="{Binding Items}"  
                XBindingPath="XValue" YBindingPath="YValue" Label="ColumnSeries" Width ="0.5" />   
 
If your requirement is different from this.  Please provide more details to provide a proper solution.  
 
 
Regards,
Parthiban S
 
 



GA Gabriele September 25, 2017 09:23 AM UTC

Hello and thanks for your reply.


I think my point is not yet clear, sorry probably I have been not abel to explain it clearly, I will try to be as much simplest as possible.

on XAML file I setup the property LabelPosition="Auto".

This means that sync chart automatically locate the label writing in or out the bar.

What I would like to know is:

is it possible at runtime to know if the label writings is inside or outside the label? if you want: how sync is resolving the "Auto" feature? as Inner or as Outer?

Please let me know if this clarify my doubt.


BR

Gabriele



PS Parthiban Sundaram Syncfusion Team November 24, 2017 05:16 AM UTC

Hi Gabriele,

We have checked your scenario at maximum possibilities. Still we are unable to achieve your requirement, due to certain limitations in application level. So, we have logged this as a feature (Need to provide new APIs for customize the label position for each data marker) and it will be available in any of our upcoming release.

Regards,
Parthiban S.
 



MJ Marcelo J Macedo replied to Parthiban Sundaram September 4, 2019 02:12 AM UTC

Hi Gabriele,

We have checked your scenario at maximum possibilities. Still we are unable to achieve your requirement, due to certain limitations in application level. So, we have logged this as a feature (Need to provide new APIs for customize the label position for each data marker) and it will be available in any of our upcoming release.

Regards,
Parthiban S.
 


Any news in this functionality?


MK Muneesh Kumar G Syncfusion Team September 4, 2019 04:36 AM UTC

Hi Gabriele, 
 
Thanks for your patience. And we glad to announce that the reported feature implemented in our 2018 Vol 2 release (16.2.0.41) itself. Please find the release notes regarding this feature.  
 
 
Please find the help documentation section for this feature below.  
 
 
Please let us know if you have any other queries.  
 
Thanks,  
Muneesh Kumar G  
 


Loader.
Up arrow icon