How do I set the data for the x-axis?
978740431 opened this issue ยท 4 comments
Now the display is 0~N, I want to display the date, how do I need to set
Hey,
With GridDecoration or VerticalAxisDecoration you have valueFromIndex
. This is a function that will return you index and you can return any string you want as label text.
Hope that helps ๐
Thank you very much, it is ready to use.
I hope there is a case in the demo, because my English and flutter technology is very poor, so after reading your reply I still took some time to solve it, if the case has examples, it will be very good to help sdk users
Great ๐
Okay, thanks for input. I'll add that to readme and maybe some examples ๐
For anyone looking to do this, here is an example that adds three letter day names to the horizontal axis (starting from today - var now = new DateTime.now();
GridDecoration(
showHorizontalValues: false,
showVerticalValues: true,
verticalAxisValueFromIndex: (int value) {
return DateFormat.E().format(now.add(new Duration(days: value))).toString();
},
verticalAxisStep: 1,
horizontalAxisStep: 3,
textStyle: TextStyle(color: Colors.grey),
gridColor: Theme.of(context).dividerColor,
),