google / charts

https://pub.dev/packages/charts_flutter
Apache License 2.0
2.8k stars 1.2k forks source link

How to format the time axis in TimeSeriesChart #715

Open shiyu-sz opened 2 years ago

shiyu-sz commented 2 years ago

I know that domainFormatterFn and measureFormatterFn should be set, but are there examples?

bkbonner commented 2 years ago

There are examples in the repo. Since you didn't ask what you're trying to do, take a look here for formatting the axes: https://github.com/google/charts/blob/master/charts_flutter/example/lib/axes/

To format the ticks on the time axis, which I suspect is the domainAccess (the x-axis), you'll want to specify a different domainAccessSpec.

Play with info in the example here: https://github.com/google/charts/blob/master/charts_flutter/example/lib/axes/custom_axis_tick_formatters.dart

erSitzt commented 2 years ago

Same question here i guess.. My measureFn is measureFn: (Lap series, _) => series.duration.inMilliseconds, , but i dont want the user to see seconds or milliseconds, instead i would like to format it like this for example:

printDuration(duration, abbreviated: true, tersity: DurationTersity.millisecond))

Which should give me this instead of ms: 1min, 29s, 38ms

This is my test, for low values under two minutes this is ok, but with longer times the chart is not that easy to read quickly :(

image

I didnt find any example for measureFormatterFn @971586331 did you find a solution ? @bkbonner do you have an example for measureFormatterFn ?