thekeenant / fcharts

:bar_chart: Create beautiful, responsive, animated charts using a simple and intuitive API.
https://pub.dartlang.org/packages/fcharts
MIT License
326 stars 46 forks source link

set x and y axis values ordered #32

Closed nasr25 closed 5 years ago

nasr25 commented 5 years ago

Hi

i have example code to show line chart, but X and Y axis values not ordered, how can i make it ordered from 0 to big number in series.

`class SimpleLineChart extends StatelessWidget { // X value -> Y value static const myData = [ [2,5], [1,3], [10,9], ];

@override Widget build(BuildContext context) { return new LineChart( lines: [ new Line<List, String, String>( data: myData, xFn: (datum) => datum[0], yFn: (datum) => datum[1], ), ], chartPadding: new EdgeInsets.fromLTRB(30.0, 10.0, 10.0, 30.0), ); } }`

nasr25 commented 5 years ago

No answer ???

thekeenant commented 5 years ago

Hi, it's just me on this project so there isn't much support.

You can sort the data before providing it to the line chart. This sorts your data by the X axis value ascending:

final sortedData = <List<int>>[]..addAll(myData)..sort((a, b) {
  return a.first.compareTo(b.first);
});
nasr25 commented 5 years ago

Ok, thanks