Problem to show label from binding data

Hello,

I am using sfchart  with I would like to be able to define the label of the X axis (NumericalAxis) in relation to a binding value of the series (FastLineBitmapSeries).
I tried to use LabelsSource, ContentPath, PositionPath but there is no label under the X axis.
The idea would be to be able to have the X axis which increments with respect to the position of the data in the array (Indexed value) but display the datetime of the measure instead of the index number. I have not found an example showing the whole thing with the MVVM.

Hope it's clear enough

3 Replies 1 reply marked as answer

YP Yuvaraj Palanisamy Syncfusion Team May 20, 2021 11:28 AM UTC

Hi Laurent Ratzé, 
 
Greetings from Syncfusion.

We have analyzed your query and achieved your requirement “binding the custom labels for primary axis with MVVM” with the help of LabelsSoucre, ContentPath and PositionPath property of ChartAxis. Please find the below code example for your reference.  
 
CodeSnippet: 
<chart:SfChart.PrimaryAxis> 
    <chart:NumericalAxis LabelsSource="{Binding Labels}"  
                         ContentPath="Content"  
                         PositionPath="Position"  
                         EdgeLabelsDrawingMode="Shift"/> 
</chart:SfChart.PrimaryAxis> 
 
Model.cs 
public class LabelItem 
{ 
    public string Content { get; set; } 
 
    public int Position { get; set; } 
} 
 
ViewModel.cs 
public class ViewModel 
{ 
 
    public ObservableCollection<LabelItem> Labels { get; set; } 
     
    public ViewModel() 
    { 
        GenerateData(); 
 
        Labels = new ObservableCollection<LabelItem>() 
        { 
            new LabelItem() {Position=0, Content = "01/01/2021"}, 
            new LabelItem() {Position=1, Content = "02/01/2021"}, 
            new LabelItem() {Position=2, Content = "03/01/2021"}, 
            new LabelItem() {Position=3, Content = "04/01/2021"}, 
            new LabelItem() {Position=4, Content = "05/01/2021"}, 
            new LabelItem() {Position=5, Content = "06/01/2021"}, 
        }; 
    } 
} 
 
 
Also, we have attached the sample for your reference. Please find the sample from the below link. 
 
  
Output: 
 
 
 
Regards, 
Yuvaraj. 


Marked as answer

LA Laurent May 20, 2021 07:19 PM UTC

ok thank you it work good :)


YP Yuvaraj Palanisamy Syncfusion Team May 21, 2021 07:44 AM UTC

Hi Laurent Ratzé, 
 
Thank you for your update. 
 
Please let us know if you have any further assistance. 
 
Regards,  
Yuvaraj.  


Loader.
Up arrow icon