Rotate Labels on BarChart

Based on this tutorial, , how do you rotate the labels on the x-axis of the chart?


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there @ohohabbydale,

I came across this example from the following GitHub thread here.

Stanisław Góra, has put together a nice code snippet which seems to be exactly what you are looking for:

import 'dart:math';

import 'package:flutter/material.dart';
import 'package:charts_flutter/flutter.dart';
import 'package:charts_flutter/src/text_element.dart';
import 'package:charts_flutter/src/text_style.dart' as style;

class Chart extends StatelessWidget {
  Widget build(BuildContext context) {
    return LineChart(
      behaviors: [
          symbolRenderer: CustomCircleSymbolRenderer()
      selectionModels: [
          changedListener: (SelectionModel model) {

  List<Series<LinearSales, int>> _createSampleData() {
    final data = [
      new LinearSales(0, 5),
      new LinearSales(1, 25),
      new LinearSales(2, 100),
      new LinearSales(3, 75),
    return [
      new Series<LinearSales, int>(
        id: 'Sales',
        colorFn: (_, __) =>,
        domainFn: (LinearSales sales, _) => sales.year,
        measureFn: (LinearSales sales, _) => sales.sales,
        data: data,

class CustomCircleSymbolRenderer extends CircleSymbolRenderer {
  void paint(ChartCanvas canvas, Rectangle<num> bounds, {List<int> dashPattern, Color fillColor, Color strokeColor, double strokeWidthPx}) {
    super.paint(canvas, bounds, dashPattern: dashPattern, fillColor: fillColor, strokeColor: strokeColor, strokeWidthPx: strokeWidthPx);
      Rectangle(bounds.left - 5, - 30, bounds.width + 10, bounds.height + 10),
      fill: Color.white
    var textStyle = style.TextStyle();
    textStyle.color =;
    textStyle.fontSize = 15;
      TextElement("1", style: textStyle),
        ( - 28).round()
class LinearSales {
  final int year;
  final int sales;
  LinearSales(this.year, this.sales);

Regards, Bobby