Set maximum value on primary measure axis

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Set maximum value on primary measure axis



This is a question for Flutter development using charts_flutter. Is there a parameter to fix the maximum value on the measure axis? I'm currently using desiredTickCount as a hack but I ideally only want 3 tickers (0,5,10) for a range of 0-10 on the measure axis.


charts_flutter


desiredTickCount



Code snippet:


return new charts.BarChart(
_createSampleData(),
animate: true,
vertical: false,


primaryMeasureAxis: new charts.NumericAxisSpec(
tickProviderSpec: new charts.BasicNumericTickProviderSpec(
desiredTickCount: 11,
),
),
barRendererDecorator: new charts.BarLabelDecorator(),
// Hide domain axis.
domainAxis:
new charts.OrdinalAxisSpec(renderSpec: new charts.NoneRenderSpec()),
);
}

static List<charts.Series<OrdinalSales, String>> _createSampleData()
final data = [
new OrdinalSales('Liver', 8),
new OrdinalSales('Heart', 4),
new OrdinalSales('Spleen', 5),
new OrdinalSales('Lung', 1),
new OrdinalSales('Kidney', 2),
];

return [
new charts.Series<OrdinalSales, String>(
id: 'Sales',
domainFn: (OrdinalSales sales, _) => sales.year,
measureFn: (OrdinalSales sales, _) => sales.sales,
data: data,
// Set a label accessor to control the text of the bar label.
labelAccessorFn: (OrdinalSales sales, _) => '$sales.year',
),
];

}

class OrdinalSales
final String year;
final int sales;

OrdinalSales(this.year, this.sales);





Do you mean using charts_flutter? google_charts is for web. Please post the snippet where you currently use desiredTickCount.
– Richard Heap
2 hours ago


charts_flutter


google_charts


desiredTickCount





Yes, I meant using charts_flutter. Apologies for the confusion.
– Hayden Lak
17 mins ago




1 Answer
1



If you really just want 0, 5 and 10 try using a StaticNumericTickProviderSpec


StaticNumericTickProviderSpec


primaryMeasureAxis: new charts.NumericAxisSpec(
tickProviderSpec: new charts.StaticNumericTickProviderSpec(
<charts.TickSpec<num>>[
charts.TickSpec<num>(0),
charts.TickSpec<num>(5),
charts.TickSpec<num>(10),
],
),
),






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard