Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual bug in PieChart when sections values are 0 except for one section #817

Closed
Herve-D opened this issue Nov 17, 2021 · 1 comment
Closed
Labels
bug Something isn't working Pie Chart

Comments

@Herve-D
Copy link

Herve-D commented Nov 17, 2021

Describe the bug
Hello, there seems to be a bug with PieChart, when only one SectionData has a value different than 0, and all others section have a value of 0. It's noticeable with the badges.
Let me know if I'm not clear enough, or if I just don't understand what's wrong here...

To Reproduce

import 'package:fl_chart/fl_chart.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Tests',
      home: Home(),
    );
  }
}

class Home extends StatefulWidget {
  @override
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: Column(
        children: [
          AspectRatio(
            aspectRatio: 1,
            child: PieChart(PieChartData(
                startDegreeOffset: 270,
                sectionsSpace: 5,
                sections: [
                  PieChartSectionData(
                      value: 25,
                      color: Colors.blue,
                      radius: 100,
                      badgeWidget: Container(
                        decoration: BoxDecoration(
                          shape: BoxShape.circle,
                          border: Border.all(color: Colors.red),
                        ),
                        padding: EdgeInsets.all(5),
                        child: Icon(Icons.ac_unit),
                      ),
                      badgePositionPercentageOffset: 1),
                  PieChartSectionData(
                      value: 0,
                      color: Colors.orange,
                      radius: 100,
                      badgeWidget: Container(
                        decoration: BoxDecoration(
                          shape: BoxShape.circle,
                          border: Border.all(color: Colors.red),
                        ),
                        padding: EdgeInsets.all(5),
                        child: Icon(Icons.access_alarm),
                      ),
                      badgePositionPercentageOffset: 1),
                ])),
          ),
        ],
      ),
    );
  }
}

Screenshots

With values non 0, badges are good.
OK

With only one value non 0 (as example in code), badges are off.
NOK

imaNNeo added a commit that referenced this issue Dec 2, 2021
@imaNNeo imaNNeo added bug Something isn't working Pie Chart labels Dec 2, 2021
@imaNNeo imaNNeo mentioned this issue Dec 3, 2021
imaNNeo added a commit that referenced this issue Dec 3, 2021
@imaNNeo
Copy link
Owner

imaNNeo commented Dec 3, 2021

Fixed in 0.40.5.
Please check it out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Pie Chart
Projects
None yet
Development

No branches or pull requests

2 participants