File tree Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -31,8 +31,7 @@ class PieChartData extends BaseChartData with EquatableMixin {
3131    PieTouchData ?  pieTouchData,
3232    FlBorderData ?  borderData,
3333    bool ?  titleSunbeamLayout,
34-   })  :  sections =  sections? .where ((element) =>  element.value !=  0 ).toList () ?? 
35-             const  [],
34+   })  :  sections =  sections ??  const  [],
3635        centerSpaceRadius =  centerSpaceRadius ??  double .infinity,
3736        centerSpaceColor =  centerSpaceColor ??  Colors .transparent,
3837        sectionsSpace =  sectionsSpace ??  2 ,
Original file line number Diff line number Diff line change @@ -60,6 +60,10 @@ class PieChartPainter extends BaseChartPainter<PieChartData> {
6060    List <PieChartSectionData > sections,
6161    double  sumValue,
6262  ) {
63+     if  (sumValue ==  0 ) {
64+       return  List <double >.filled (sections.length, 0 );
65+     }
66+ 
6367    return  sections.map ((section) {
6468      return  360  *  (section.value /  sumValue);
6569    }).toList ();
@@ -100,6 +104,9 @@ class PieChartPainter extends BaseChartPainter<PieChartData> {
100104
101105    for  (var  i =  0 ; i <  data.sections.length; i++ ) {
102106      final  section =  data.sections[i];
107+       if  (section.value ==  0 ) {
108+         continue ;
109+       }
103110      final  sectionDegree =  sectionsAngle[i];
104111
105112      if  (sectionDegree ==  360 ) {
@@ -358,6 +365,9 @@ class PieChartPainter extends BaseChartPainter<PieChartData> {
358365
359366    for  (var  i =  0 ; i <  data.sections.length; i++ ) {
360367      final  section =  data.sections[i];
368+       if  (section.value ==  0 ) {
369+         continue ;
370+       }
361371      final  startAngle =  tempAngle;
362372      final  sweepAngle =  360  *  (section.value /  data.sumValue);
363373      final  sectionCenterAngle =  startAngle +  (sweepAngle /  2 );
Original file line number Diff line number Diff line change @@ -143,7 +143,20 @@ class RenderPieChart extends RenderBaseChart<PieTouchResponse>
143143      paintHolder,
144144    );
145145    canvas.restore ();
146-     defaultPaint (context, offset);
146+     badgeWidgetPaint (context, offset);
147+   }
148+ 
149+   void  badgeWidgetPaint (PaintingContext  context, Offset  offset) {
150+     RenderObject ?  child =  firstChild;
151+     var  counter =  0 ;
152+     while  (child !=  null ) {
153+       final  childParentData =  child.parentData!  as  MultiChildLayoutParentData ;
154+       if  (data.sections[counter].value >  0 ) {
155+         context.paintChild (child, childParentData.offset +  offset);
156+       }
157+       child =  childParentData.nextSibling;
158+       counter++ ;
159+     }
147160  }
148161
149162  @override 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments