imaNNeo / fl_chart

FL Chart is a highly customizable Flutter chart library that supports Line Chart, Bar Chart, Pie Chart, Scatter Chart, and Radar Chart.
https://flchart.dev
MIT License
6.87k stars 1.78k forks source link

The X line data sorted wrong which leads to an invalid graph #1572

Closed heshaShawky closed 9 months ago

heshaShawky commented 9 months ago

Describe the bug The Line chart ( x Line ) gets sorted ASC by default, which leads to an invalid graph

To Reproduce So for example I have the following set of data:

final data = [
  FlSpot(1, 1),
  FlSpot(3, 2),
  FlSpot(2, 4),
];

This will end up like the below because you sort the x line as ( 1, 2, 3 ) not as my array order ( 1, 3, 2 ) and there's no way I can prevent that from happening

The x line mostly represents a string like days, weeks, dates ...etc so letting the order to the developer is what should be.

So another example below, I want to get the past 7 days ( Sunday is 0, and Saturday is 6 ) so the order should be like below and this is the correct order as I see your comment about it on another issues same as this you tell to order it by yourself outside, ( but it's already ordered )

[
  0, // sun ( as today )
  6, // sat
  5, // thu
  4, // wen
  ...etc
]

Screenshots Screenshot_1706487998

imaNNeo commented 9 months ago

I think it is related to #1393 I will close this issue and please provide me a reproducible code for the other issue. Thanks!