Skip to content

[syncfusion_flutter_charts] Pie chart labels are not displayed when using builder #733

@s4k4tech

Description

@s4k4tech

Thanks for making such a nice package.
I am having trouble getting the label text to show up when using builder.
I attached screenshot and sample code.
From the screenshot you can see that 55555555555555 and 88888888888888 are not displayed.
I would appreciate it if you could help me with a solution.
Thank you in advance.

import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_charts/charts.dart';

class _ChartData {
  _ChartData(this.labelText, this.count, this.color);
  final String labelText;
  final int count;
  final Color color;
}

class Temp extends StatelessWidget {
  Temp({Key? key}) : super(key: key);

  final List<_ChartData> chartData = [
    _ChartData('11111111111111', 1, Colors.red),
    _ChartData('22222222222222', 1, Colors.blue),
    _ChartData('33333333333333', 1, Colors.yellow),
    _ChartData('44444444444444', 1, Colors.green),
    _ChartData('55555555555555', 1, Colors.orange),
    _ChartData('66666666666666', 1, Colors.purple),
    _ChartData('77777777777777', 1, Colors.pink),
    _ChartData('88888888888888', 1, Colors.brown),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: SfCircularChart(
        margin: EdgeInsets.zero,
        series: <CircularSeries>[
          PieSeries<_ChartData, String>(
            dataSource: chartData,
            animationDuration: 0,
            pointColorMapper: (_ChartData data, _) => data.color,
            xValueMapper: (_ChartData data, _) => data.labelText,
            yValueMapper: (_ChartData data, _) => data.count,
            dataLabelSettings: DataLabelSettings(
              isVisible: true,
              labelIntersectAction: LabelIntersectAction.none,
              margin: EdgeInsets.zero,
              builder: (data, point, series, pointIndex, seriesIndex) {
                return Text(chartData[pointIndex].labelText);
              },
            ),
          ),
        ],
      ),
    );
  }
}

Simulator Screen Shot - iPhone 11 - 2022-04-05 at 22 56 49

Metadata

Metadata

Assignees

No one assigned

    Labels

    chartsCharts componentwaiting for customer responseCannot make further progress until the customer responds.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions