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.
Unfortunately, activation email could not send to your email. Please try again.

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

Thread ID:

Created:

Updated:

Platform:

Replies:

132359 Aug 28,2017 10:32 AM Nov 24,2017 12:16 AM Xamarin.Forms 5
loading
Tags: SfChart
Gabriele
Asked On August 28, 2017 10:34 AM

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







Iyyappan Mani [Syncfusion]
Replied On August 29, 2017 11:23 AM

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.


Gabriele
Replied On August 30, 2017 06:20 AM

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


Parthiban Sundaram [Syncfusion]
Replied On August 30, 2017 08:41 AM

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
 
 


Gabriele
Replied On September 25, 2017 05:23 AM

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


Parthiban Sundaram [Syncfusion]
Replied On November 24, 2017 12:16 AM

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.
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;