How can i change bar labels size and display direction ?
Description of issues:
I want to achieve having a barChart with panning and pinch to zoom behavior, Google didn't helped me very much i found that i can add behaviors: [ charts.PanBehavior(), charts.PanAndZoomBehavior(), ],.
to the BarChart parameters but it didn't work. Any ideas ?
2.I have situations where i need to show more than 10 or 20 bars on one chart. When number of charts is small everything looks fine. Labels are shown properly. But when number of bars increases labels changes it display direction from horizontal to vertical. My goal is to block that behavior and force labels to stay horizontal and scale to the Bar's width. You can see it on screenshots below. Does anybody has idea how to solve it ?
`import 'package:charts_flutter/flutter.dart' as charts;
Hey Im facing a problems with BarChart:
Description of issues:
I want to achieve having a barChart with panning and pinch to zoom behavior, Google didn't helped me very much i found that i can add
behaviors: [ charts.PanBehavior(), charts.PanAndZoomBehavior(), ],
.to the BarChart parameters but it didn't work. Any ideas ?
2.I have situations where i need to show more than 10 or 20 bars on one chart. When number of charts is small everything looks fine. Labels are shown properly. But when number of bars increases labels changes it display direction from horizontal to vertical. My goal is to block that behavior and force labels to stay horizontal and scale to the Bar's width. You can see it on screenshots below. Does anybody has idea how to solve it ?
`import 'package:charts_flutter/flutter.dart' as charts;
import '../models/drive_style_series.dart'; import 'package:flutter/material.dart';
class DriveSummaryChart extends StatelessWidget { const DriveSummaryChart({Key? key, required this.dataSeriesList}) : super(key: key);
final List dataSeriesList;
@override Widget build(BuildContext context) { List<charts.Series<DriveStyleSeries, String>> series = [ charts.Series( id: 'km', data: dataSeriesList, labelAccessorFn: (DriveStyleSeries series, ) => series.distance.toDouble().toStringAsFixed(1), domainFn: (DriveStyleSeries series, ) => series.date, measureFn: (DriveStyleSeries series, ) => series.distance, colorFn: (DriveStyleSeries series, ) => charts.ColorUtil.fromDartColor( Colors.greenAccent), ), ]; return SizedBox( height: 300, child: charts.BarChart( series, animate: true, animationDuration: const Duration(milliseconds: 200), barRendererDecorator: charts.BarLabelDecorator(
labelPosition: charts.BarLabelPosition.outside,
labelAnchor: charts.BarLabelAnchor.middle,
labelPadding: 5,
outsideLabelStyleSpec: charts.TextStyleSpec(
color: charts.ColorUtil.fromDartColor(Colors.black)),
),
primaryMeasureAxis:
const charts.NumericAxisSpec(renderSpec: charts.NoneRenderSpec()),
domainAxis: const charts.OrdinalAxisSpec(
showAxisLine: false, renderSpec: charts.NoneRenderSpec()),
behaviors: [
charts.PanBehavior(),
charts.PanAndZoomBehavior(),
],
layoutConfig: charts.LayoutConfig(
bottomMarginSpec: charts.MarginSpec.fixedPixel(0),
leftMarginSpec: charts.MarginSpec.fixedPixel(0),
rightMarginSpec: charts.MarginSpec.fixedPixel(0),
topMarginSpec: charts.MarginSpec.fixedPixel(20),
),
),
);
}
}
`