Custom text in StackingBar100Series

Hello. I have a StackingBar100Series chart in my app. Working normal and I am able to see the label. Is there any way to display my own custom text and not the data value? Basically I wanna change the displayed value '30' to '30%'.

5 Replies

MK Muneesh Kumar G Syncfusion Team May 25, 2018 09:00 AM UTC

Hi Konstantinos, 
 
Thanks for using Syncfusion products. 
 
You can achieve this requirement display custom text in data marker using below solutions.  
 
Solution 1: By setting LabelFormat in DateMarkerLabelStyle you can format the yvalue shown in data marker label as per the below code snippet.  
 
Codesnippet XAML: 
<chart:ChartDataMarker> 
     <chart:ChartDataMarker.LabelStyle> 
          <chart:DataMarkerLabelStyle LabelFormat="#'%'"> 
          </chart:DataMarkerLabelStyle> 
    </chart:ChartDataMarker.LabelStyle> 
</chart:ChartDataMarker> 
  
Solution 2: By setting LabelTamplate in ChartDataMarker you can show custom string in data marker label as per the below code snippet.  
 
Codesnippet XAML: 
<ContentPage.Resources> 
         <ResourceDictionary> 
            <DataTemplate x:Key="dataMarkerTemplate"> 
                <StackLayout Orientation="Horizontal"> 
                    <Label Text="{Binding XValue}"/> 
                </StackLayout> 
            </DataTemplate> 
        </ResourceDictionary> 
  
</ContentPage.Resources> 
 … 
 <chart:StackingBar100Series.DataMarker> 
                     <chart:ChartDataMarker LabelTemplate="{StaticResource dataMarkerTemplate}"> 
                    </chart:ChartDataMarker> 
</chart:StackingBar100Series.DataMarker> 
  
For more detail about LabelTemplate property please refer following link 
 
 
Output :  
 
Please let us know if you have any queries.  
 
Thanks, 
Muneesh Kumar G. 



KE Konstantinos Evangelidis May 25, 2018 02:54 PM UTC

Can you please give the c# code to set custom text in xamarin android?


LR Lakshmi Radha Krishnan Syncfusion Team May 28, 2018 12:56 PM UTC

Hi Konstantinos,
 
Please find the code snippet to customize the data marker label in C#.
 
Solution 1: By using LabelFormat property in DataMarkerLabelStyle.
 
 
ColumnSeries series = new ColumnSeries();
Series.DataMarker.LabelStyle.LabelFormat = “#%”;
 
 
Solution2: By using DataMarkerLabelCreated event in ChartSeries. 
 
 
ColumnSeries series = new ColumnSeries();
series.DataMarkerLabelCreated += Series_DataMarkerLabelCreated;
 
void Series_DataMarkerLabelCreated(object sender, ChartSeries.DataMarkerLabelCreatedEventArgs e)
{
            e.DataMarkerLabel.Label = e.DataMarkerLabel.Label  +  "%";
}
 
Please let us know,  if you need further assistance on this.
 
Regards,
Lakshmi R.



KE Konstantinos Evangelidis May 30, 2018 03:29 PM UTC

Thank you very much for your answer. I used the second method and is working fine.


DV Divya Venkatesan Syncfusion Team May 31, 2018 09:44 AM UTC

Hi Konstantinos,

Thanks for the update. We are glad to know that the given solution works.

Please let us know if you need any further assistance.

Regards,
Divya Venkatesan


Loader.
Up arrow icon