google / charts

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

Vertical Barchart label color #291

Open RobertBrunhage opened 5 years ago

RobertBrunhage commented 5 years ago

How do I change the color of the labels of a vertical barChart?

found the following

defaultRenderer: charts.BarRendererConfig(
   barRendererDecorator: charts.BarLabelDecorator(
     outsideLabelStyleSpec: charts.TextStyleSpec(
       color: charts.Color.white,
       fontSize: 12,
     ),
   ),
),

But it doesn't seem to work (not implemented?).

This is my BarChart

return charts.BarChart(
      _createList(data.reversed.toList()),
      animate: animate,
      defaultInteractions: false,
      behaviors: [
        charts.SelectNearest(),
        charts.DomainHighlighter(),
      ],
      defaultRenderer: charts.BarRendererConfig(
        barRendererDecorator: charts.BarLabelDecorator(
          outsideLabelStyleSpec: charts.TextStyleSpec(
            color: charts.Color.white,
            fontSize: 12,
          ),
        ),
      ),
      domainAxis: charts.AxisSpec<String>(
        renderSpec: renderSpecDomain,
      ),
    );
  }
virokannas commented 4 years ago

It seems that the outsideLabelStyleSpec of the BarLabelDecorator has no effect whatsoever.

If you return a different spec with outsideLabelStyleAccessorFn of the Series, it does what you probably would imagine outsideLabelStyleSpec to do.

But, if you want to change the color of the label that is below the chart (or to the left if it's horizontal), let me know if you find a way...