google / charts

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

Changing vertical property of a BarChart doesn't redraw the chart #362

Open Krigpl opened 4 years ago

Krigpl commented 4 years ago

When an action is performed to change the state of the widget which results in the vertical property being changed, the bar chart doesn't seem to respect that and stays in the same orientation.

Code sample:

import 'package:flutter/material.dart';

import 'package:charts_flutter/flutter.dart' as charts;

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  bool vertical = false;

  @override
  Widget build(BuildContext context) {
    Widget chart = charts.BarChart(
      [
        charts.Series<int, String>(
          domainFn: (int item, _) => "",
          measureFn: (int item, _) => item,
          data: [10, 20],
        ),
      ],
      vertical: vertical,
    );
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Container(
              height: 100,
              child:
                chart,
            ),
            FlatButton(
              child: Text("click"),
              onPressed: () {
                setState(() {
                  vertical = !vertical;
                });
              },
            ),
          ],
        ),
      ),
    );
  }
}
97ihsan commented 4 years ago

I have the same problem

Massmaker commented 4 years ago

I have the same problem

+1

Nocturnalypso commented 3 years ago

Also running into this. Has anyone found a workaround?

sedagurocak commented 3 years ago

I have same issue, also I need to change label. I mean if I am using search field and I am expecting labels which result of search. But chart doesn't redraw

rilpires commented 2 years ago

(still having the same problem)

lafetamarcelo commented 2 years ago

Same problem here