我一直在使用 Flutter 图表的在线图库 ( https://google.github.io/charts/flutter/gallery.html ),但我正在努力为 x 和 y 轴值添加标题。
有人可以帮助我或告诉我如何将标签添加到图表中吗?
我还是新手,我一直在尝试在条形图中显示来自 http 请求的一些数据。我找不到任何例子。我希望你们中的一些人可以提供帮助:)
我想使用在线图库中的此图表。我刚刚为我的应用更改了类的名称:
import 'package:flutter/material.dart';
import 'package:charts_flutter/flutter.dart' as charts;
class SimpleSeriesLegend extends StatelessWidget {
final List<charts.Series> seriesList;
final bool animate;
SimpleSeriesLegend(this.seriesList, {this.animate});
factory SimpleSeriesLegend.withSampleData() {
return new SimpleSeriesLegend(
_createSampleData(),
// Disable animations for image tests.
animate: false,
);
}
@override
Widget build(BuildContext context) {
return new charts.BarChart(
seriesList,
animate: animate,
barGroupingType: charts.BarGroupingType.grouped,
// Add the series legend behavior to the chart to turn on series legends.
// By default the legend will display above the chart.
behaviors: …Run Code Online (Sandbox Code Playgroud)