data is not plotted sequentially in LineSeries

I have problems when viewing the data in the line graph.
I get the data from firestore, and when a new data arrives it is not sorted in a straight way but the new data joins the nearest point.

I want the data to be displayed as in the second image
    

3 Replies

RK Rokesh Karthikeyan Syncfusion Team February 25, 2020 01:43 PM UTC

Hi Aldair, 
 
Greetings from Syncfusion. 
 
We have analyzed your query. The data points will be rendered in the order it is specified and this is the default behavior of charts. And for your scenario, you can use the sorting feature in the chart. Specify the x value field in the sortFieldValueMapper property and also specify ascending value for sortingOrder property. Now the dynamic data points will also be sorted and rendered properly. Please find the code snippet below. 
  
[Dart] 
SfCartesianChart( 
   series: <LineSeries<OrdinalSalesint>>[ 
      LineSeries<OrdinalSalesint>( 
         dataSource: chartData, 
         sortingOrder: SortingOrder.ascending, 
         sortFieldValueMapper: (OrdinalSales sales, _) => sales.country, 
         xValueMapper: (OrdinalSales sales, _) => sales.country, 
         yValueMapper: (OrdinalSales sales, _) => sales.sales 
       ) 
   ] 
) 
 
   
The below screenshot shows the default behavior. 
 
 
Whereas the below screenshot shows the sorted rendering. 
 
 
Please check this and let us know if you face any concerns. 
 
Thanks, 
Rokesh Karthikeyan 




AR Aldair Ramiro Turizo Gamarra March 17, 2020 08:37 PM UTC

Thank you very much, your help has helped me a lot.


DD Dharanidharan Dharmasivam Syncfusion Team March 18, 2020 12:01 PM UTC

Hi Aldair, 
 
Most welcome. Kindly get back to us if you have further queries, we are always happy in assisting you. 
 
Thanks, 
Dharani. 


Loader.
Up arrow icon