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

Remove space from border to pie chart #107

Closed
haohmaruru opened this issue Nov 11, 2019 · 3 comments
Closed

Remove space from border to pie chart #107

haohmaruru opened this issue Nov 11, 2019 · 3 comments
Labels
question Further information is requested

Comments

@haohmaruru
Copy link

haohmaruru commented Nov 11, 2019

When i create piechart it has a space from chart to border ( i paint it red color). Can i remove that space.
Screenshot_20191111-173642

@imaNNeo imaNNeo added the question Further information is requested label Nov 11, 2019
@imaNNeo
Copy link
Owner

imaNNeo commented Nov 11, 2019

You should set the size manually,
wrap it in a SizedBox, and set the SizedBox's width and height.

width: (radius * 2) + (centerSpace * 2),
height: (radius * 2) + (centerSpace * 2),

check it out with this code:

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

class PieChartPage extends StatefulWidget {
  @override
  _PieChartPageState createState() => _PieChartPageState();
}

class _PieChartPageState extends State<PieChartPage> {

  double radius = 80;
  double centerSpace = 20;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      body: Center(
        child: SizedBox(
          width: (radius * 2) + (centerSpace * 2),
          height: (radius * 2) + (centerSpace * 2),
          child: PieChart(
            PieChartData(
              sectionsSpace: 12,
              centerSpaceRadius: centerSpace,
              sections: [
                PieChartSectionData(
                  color: const Color(0xff0293ee),
                  value: 25,
                  title: '',
                  radius: radius,
                  titleStyle: TextStyle(
                    fontSize: 18, fontWeight: FontWeight.bold, color: const Color(
                    0xff044d7c)),
                  titlePositionPercentageOffset: 0.55,
                ),
                PieChartSectionData(
                  color: const Color(0xfff8b250),
                  value: 25,
                  title: '',
                  radius: radius,
                  titleStyle: TextStyle(
                    fontSize: 18, fontWeight: FontWeight.bold, color: const Color(
                    0xff90672d)),
                  titlePositionPercentageOffset: 0.55,
                ),
                PieChartSectionData(
                  color: const Color(0xff845bef),
                  value: 25,
                  title: '',
                  radius: radius,
                  titleStyle: TextStyle(
                    fontSize: 18, fontWeight: FontWeight.bold, color: const Color(
                    0xff4c3788)),
                  titlePositionPercentageOffset: 0.6,
                ),
                PieChartSectionData(
                  color: const Color(0xff13d38e),
                  value: 25,
                  title: '',
                  radius: radius,
                  titleStyle: TextStyle(
                    fontSize: 18, fontWeight: FontWeight.bold, color: const Color(
                    0xff0c7f55)),
                  titlePositionPercentageOffset: 0.55,
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}

image

@imaNNeo imaNNeo closed this as completed Nov 11, 2019
@haohmaruru
Copy link
Author

Thanks so much. It verry useful.

@imaNNeo
Copy link
Owner

imaNNeo commented Nov 12, 2019

You're welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants