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.87k stars 1.78k forks source link

Pie chart sections all black iff one sections was once 100% (360 degrees) #1538

Closed buchen closed 10 months ago

buchen commented 10 months ago

Problem

If the chart once contains one section that takes up 100%, then after an update, pie slices will all be black.

To Reproduce

Version 0.66.0

Potential root cause

With change 68cf161f2623cedda2bf1b51bef758cf62beb812, the blendMode is set to BlendMode.srcOut on the _sectionPaint if there is a slice that takes up 100%. Later, if there are multiple slices, the drawSection is using the same _sectionPaint with the altered blendMode.

I can confirm that the following code fixes the problem:


 void drawSection(
    PieChartSectionData section,
    Path sectionPath,
    CanvasWrapper canvasWrapper,
  ) {
    _sectionPaint
      ..setColorOrGradient(
        section.color,
        section.gradient,
        sectionPath.getBounds(),
      )
      ..blendMode = BlendMode.srcOver       <==== set blend mode to srcOver
      ..style = PaintingStyle.fill;
    canvasWrapper.drawPath(sectionPath, _sectionPaint);
  }
shaynec25 commented 10 months ago

same issue here

tattuu commented 10 months ago

same issue here

imaNNeo commented 10 months ago

Yes, it is related to the code that you mentioned. Thanks for your detailed issue.

The hotfix is landed on the main branch. Stay tuned for a hotfix

imaNNeo commented 10 months ago

Fixed in 0.66.1