imaNNeo / fl_chart

FL Chart is a highly customizable Flutter chart library that supports Line Chart, Bar Chart, Pie Chart, Scatter Chart, and Radar Chart.
https://flchart.dev
MIT License
6.77k stars 1.74k forks source link

PieChart centerSpace disapearing #1617

Open Priyantha-Kingslake opened 6 months ago

Priyantha-Kingslake commented 6 months ago

I have a pieChart with only 2 sections where the section values are calculated dynamically. I saw that the innerCircle disappears when the first section's value is 0. I tested with switching the values, i.e. first section has a value and second section value = 0, then the bug is not there, the innerCircle is drawn as normal. (PieChartSectionData radius and PieChartData centerSpaceRadius is been given explicitly in all instances)

Steps to Reproduce create a PieChart with 2 PieChartSectionData( ) in sections parameter. provide value = 0 to first section and any value to 2nd section

Screenshots When values provided to both sections image

value = 0, in 1st section (value > 0 given to 2nd section) image

value = 0, in 2nd section (value > 0 given to 1st section) image

Versions

flutter version Flutter 3.19.3 • channel stable • https://github.com/flutter/flutter.git Framework • revision ba39319843 (3 weeks ago) • 2024-03-07 15:22:21 -0600 Engine • revision 2e4ba9c6fb Tools • Dart 3.3.1 • DevTools 2.31.1

fl_chart version fl_chart: ^0.66.2

FYI: I didn't check behavior with any other number of sections

Priyantha-Kingslake commented 6 months ago

Expected output can be taken by providing a veeery small value for the 1st section (0.000001) image

    [
      PieChartSectionData(
        showTitle: false,
        value: totalHours == 0 ? 0.000001 : totalHours,
        color: MyColors.kBlue,
        radius: radius,
      ),
      PieChartSectionData(
        showTitle: false,
        value: remaining,
        color: MyColors.kBlue.withOpacity(0.2),
        radius: radius,
      ),
    ]
imaNNeo commented 4 months ago

Can you please provide a reproducible code? (a simple main.dart file content)

Priyantha-Kingslake commented 4 months ago

Tried with minimum possible and the bug didn't occur. Issue's still there in the original. Will try to find cause Bit busy these days though... Will update here when I get some time.

soraef commented 3 months ago

This problem occurred when --web-renderer html was specified in Flutter web. If --web-renderer html is not shown, there seems to be no problem.

marcosgcd commented 2 months ago

The issue only occurs with PieChartSectionData is 100% of The Pie and the Color has opacity.

PieChart(
    PieChartData(
        sectionsSpace: 0,
        centerSpaceRadius: 18,
        sections: [
              PieChartSectionData(
                color: Theme.of(context).colorScheme.primary.withOpacity(0.5),
                radius: 4,
                value: 50,
                showTitle: false,
              ),
            ],
          ),
);

Result:

Bildschirmfoto 2024-07-17 um 04 09 28

Result with Theme.of(context).colorScheme.primary.withOpacity(1),:

Bildschirmfoto 2024-07-17 um 04 09 06

Without opacity the result is as expected