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

PieChart not fully draw in ios devices when have only one section #1515

Closed
islavstan opened this issue Nov 30, 2023 · 8 comments · Fixed by #1523
Closed

PieChart not fully draw in ios devices when have only one section #1515

islavstan opened this issue Nov 30, 2023 · 8 comments · Fixed by #1523
Labels
bug Something isn't working Pie Chart

Comments

@islavstan
Copy link

PieChart not fully draw in ios devices when have only one section

Снимок экрана 2023-11-30 в 15 01 35

border doesn't help too
Снимок экрана 2023-11-30 в 15 02 20

@islavstan
Copy link
Author

I tried iphone 14 simulator

@imaNNeo
Copy link
Owner

imaNNeo commented Dec 3, 2023

I couldn't reproduce it.
Can you please share a reproducible code? (a main.dart file content)
Simulator Screenshot - iPhone 15 Pro Max - 2023-12-04 at 00 09 19

@islavstan
Copy link
Author

islavstan commented Dec 4, 2023

your have to add centerSpaceRadius
and increase PieChart size
I changed your sample, here is example

import 'package:fl_chart_app/presentation/resources/app_resources.dart';
import 'package:fl_chart_app/presentation/widgets/indicator.dart';
import 'package:fl_chart/fl_chart.dart';
import 'package:flutter/material.dart';

class PieChartSample1 extends StatefulWidget {
  const PieChartSample1({super.key});

  @override
  State<StatefulWidget> createState() => PieChartSample1State();
}

class PieChartSample1State extends State {
  int touchedIndex = -1;

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      height: 300,
      width: 300,
      child: PieChart(
        PieChartData(
          pieTouchData: PieTouchData(
            touchCallback: (FlTouchEvent event, pieTouchResponse) {
              setState(() {
                if (!event.isInterestedForInteractions ||
                    pieTouchResponse == null ||
                    pieTouchResponse.touchedSection == null) {
                  touchedIndex = -1;
                  return;
                }
                touchedIndex = pieTouchResponse
                    .touchedSection!.touchedSectionIndex;
              });
            },
          ),

          borderData: FlBorderData(
            show: false,
          ),
          sectionsSpace: 0,
          centerSpaceRadius: 80,
          sections: showingSections(),
        ),
      ),
    );
  }

  List<PieChartSectionData> showingSections() {
    return [
      PieChartSectionData(
        color:  AppColors.contentColorBlue,
        value: 100,
        title: '',
        radius: 80,
        titlePositionPercentageOffset: 0.55,
        borderSide: BorderSide(
            color: AppColors.contentColorWhite.withOpacity(0)),
      )
    ];
  }
}

@islavstan
Copy link
Author

Simulator Screenshot - iPhone 14 - 2023-12-04 at 14 26 12

@islavstan
Copy link
Author

I think problem in PieChartPainter
if (sectionDegree == 360) {
_sectionPaint
..color = section.color
..strokeWidth = section.radius
..style = PaintingStyle.stroke;
canvasWrapper.drawCircle(
center,
centerRadius + section.radius / 2,
_sectionPaint,
);

@imaNNeo
Copy link
Owner

imaNNeo commented Dec 15, 2023

Got it!

@imaNNeo
Copy link
Owner

imaNNeo commented Dec 15, 2023

Merged into master

This was referenced Dec 25, 2023
@imaNNeo
Copy link
Owner

imaNNeo commented Dec 25, 2023

Landed in 0.66.0

@imaNNeo imaNNeo reopened this Dec 25, 2023
@imaNNeo imaNNeo closed this as completed Dec 25, 2023
OlehSv pushed a commit to Oleh-Sv/fl_chart that referenced this issue May 14, 2024
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

Successfully merging a pull request may close this issue.

2 participants