pie_chart icon indicating copy to clipboard operation
pie_chart copied to clipboard

[BUG] Random Angle on Repaint

Open MelvinIdema opened this issue 3 years ago • 6 comments

Whenever Flutter repaints the PieChart angle will seemingly change to a random angle.

https://user-images.githubusercontent.com/2219074/170731588-70a5eae1-b8b1-461e-a348-7fccca7a118a.mov

This is how PieChart is used in my app:

           PieChart(
              initialAngleInDegree: 270.0,
              dataMap: {
                "water": value,
              },
              ringStrokeWidth: 6.0,
              chartType: ChartType.ring,
              totalValue: maxValue,
              baseChartColor: Colors.black38,
              colorList: const [
                Colors.greenAccent,
              ],
              chartValuesOptions: const ChartValuesOptions(
                showChartValues: false,
              ),
              legendOptions: const LegendOptions(
                showLegends: false,
              ),
            ),
          ),

What could possibly be the issue? Is it a bug in PieChart self?

MelvinIdema avatar May 27 '22 15:05 MelvinIdema

Wrapping the PieChart in a RepaintBoundary seems to fix the issue for me. Still, no clue why it happens?

MelvinIdema avatar May 27 '22 16:05 MelvinIdema

Can you please provide what data you are passing in data object? Also what about total value parameter. Currently it makes value rendered as 100% without total value parameter

apgapg avatar Sep 19 '22 04:09 apgapg

I wrapped it into RepaintBoundary and it worked well for me. But I was invoking it like:

PieChart(
        dataMap: {"Title": 5},
        totalValue: 10,
        baseChartColor: const Color(0xAAD6DADA),
        animationDuration: const Duration(milliseconds: 800),
        chartLegendSpacing: 32,
        initialAngleInDegree: 0,
        chartType: ChartType.ring,
        legendOptions: const LegendOptions(showLegends: false),
        chartValuesOptions: const ChartValuesOptions(showChartValues: false),
        ringStrokeWidth: 3,
        chartRadius: 15
        colorList: const [
          Color.fromRGBO(67, 221, 166, 1),
        ],
      )

avdept avatar Sep 19 '22 06:09 avdept

Let me just try this sample code

apgapg avatar Sep 19 '22 06:09 apgapg

Same thing happened on pie_chart: ^5.3.2 Wrapping with RepaintBoundary fixed it

riccardocescon avatar Dec 15 '22 08:12 riccardocescon

Happend to me too, but happend only when the provided Data is not 100% from the defined totalValue.

Tobias-Keller avatar Feb 20 '23 08:02 Tobias-Keller