I'm using RadialBarSeries() inside SfCircularChart().
After calling Legend() (in the property legend in SfCircularChart()),
I got the following:
I want to change these circular icons to normal square icons.
This is my code:
child: SfCircularChart(
legend: Legend(
isVisible: true,
overflowMode: LegendItemOverflowMode.wrap,
position: LegendPosition.left,
),
series: <CircularSeries>[
RadialBarSeries<Qualification, String>(
dataLabelSettings: DataLabelSettings(isVisible: true),
dataSource: _qualifications,
xValueMapper: (Qualification data, _) => data.name,
yValueMapper: (Qualification data, _) => data.value
)
],
)
You can do it as follows.
child: SfCircularChart(
title: ChartTitle(text: 'Advances'),
palette: const <Color>[
Color(0xFFffc107),
Color(0xFF0386E8),
],
legend: Legend(
isVisible: true,
overflowMode: LegendItemOverflowMode.wrap,
position: LegendPosition.left,
),
tooltipBehavior: _tooltipData,
series: <CircularSeries>[
RadialBarSeries<ChartData, String>(
legendIconType: LegendIconType.seriesType,
dataSource: _chartData,
xValueMapper: (ChartData data, _) => data.name,
yValueMapper: (ChartData data, _) => data.value,
dataLabelSettings: const DataLabelSettings(
isVisible: true,
),
enableTooltip: true,
cornerStyle: CornerStyle.endCurve,
maximumValue: 100)
],
),
legendIconType: specifies the shape of the legend.
legendIconType: LegendIconType.seriesType,
legendIconType: LegendIconType.circle,
see more here
Documentation: here
Related
first time asking a question here. I would like to how to remove the extra spacing around the SfCircularChart from syncfusion_flutter_charts package.
Container(
// Wrapping around fixed size Container
width: 200,
height: 200,
color: Colors.red,
child: SfCircularChart(
// Setting the margin to zero
margin: EdgeInsets.zero,
series: <CircularSeries>[
PieSeries<Category, String>(
dataSource: dailyEarningList,
xValueMapper: (Category data, _) => data.name,
yValueMapper: (Category data, _) => data.value,
dataLabelSettings: DataLabelSettings(
isVisible: true,
),
),
],
),
)
Image
PieSeries<Category, String>(
radius: "100",
dataSource: [Category(["a", "b", "c"])],
xValueMapper: (Category data, _) => "d",
yValueMapper: (Category data, _) => 1,
dataLabelSettings: const DataLabelSettings(
isVisible: true,
),
),
The library has a radius parameter. It's a string. I do not understand why it's a string. In your example if you set it to "100", it will match the container.
Syncfuction Hilo Series has high and low values and it automatically shows values as high and low label names. I want to change these label names to another language. Here is part of code of my work and how it looks like tooltip.
SfCartesianChart(
title: ChartTitle(
text: 'En düşük ve en yüksek oranlar',
alignment: ChartAlignment.near,
textStyle: TextStyle(
color: blueLogo,
fontSize: 12.sp,
)),
legend: Legend(
isVisible: true,
position: LegendPosition.top,
overflowMode: LegendItemOverflowMode.wrap),
tooltipBehavior: TooltipBehavior(enable: true),
primaryXAxis: CategoryAxis(
labelIntersectAction:
AxisLabelIntersectAction.multipleRows),
primaryYAxis: NumericAxis(maximum: 150, plotBands: [
PlotBand(
start: 80,
end: 80,
borderColor: Colors.red,
borderWidth: 1,
),
PlotBand(
start: 120,
end: 120,
borderColor: Colors.red,
borderWidth: 1,
)
]),
series: <ChartSeries>[
HiloSeries<ChartData, String>(
markerSettings: const MarkerSettings(isVisible: true),
name: 'Oranlar',
enableTooltip: true,
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.unit,
lowValueMapper: (ChartData data, _) => data.low,
highValueMapper: (ChartData data, _) => data.high)
])
Output of this code sample
How can I change these high and low label names?
You can change the TooltipBehaviour of the chart and construct the tooltip widget yourself. Official syncfusion documentation is here.
how to flutter syncfusion bar chart background grid line delete?
use pub.dev // syncfusion_flutter_charts 19.4.56
https://pub.dev/packages/syncfusion_flutter_charts
< image grid line (grey color line) >
my code
return SfCartesianChart(
title: ChartTitle(text: totalTaxString, textStyle: const TextStyle(fontWeight: FontWeight.bold)),
primaryXAxis: CategoryAxis(
maximumLabelWidth: MediaQuery.of(context).size.width > 480 ? MediaQuery.of(context).size.width * 0.3 : 100,
labelStyle: const TextStyle(overflow: TextOverflow.ellipsis)
// isVisible: false
),
primaryYAxis: CategoryAxis(
isVisible: false
),
series: <BarSeries>[
BarSeries<ModelPioChartData, String>(
dataSource: listPioChartData,
pointColorMapper:(ModelPioChartData data, _) => data.color,
xValueMapper: (ModelPioChartData data, _) => data.x,
yValueMapper: (ModelPioChartData data, _) => data.y,
dataLabelMapper: (ModelPioChartData data, _) {
if(data.y.toStringAsFixed(0).length > 4) {
return "${data.y/10000}조 원";
} else {
return "${data.y.toStringAsFixed(0)}억 원";
}
},
dataLabelSettings: const DataLabelSettings(
isVisible: true
),
enableTooltip: true,
),
],
);
I suggest you use the majorGridLines property in the axis, you can customize the width, color, and size of the major grid line. We have attached the code snippet and UG below for your reference.
primaryXAxis:
CategoryAxis(
majorGridLines: const MajorGridLines(width: 0)
),
UG: https://help.syncfusion.com/flutter/cartesian-charts/axis-customization#grid-lines-customization
Now: My goal:
I am using the syncfusion_flutter_charts package to display the chart and that table view is so annoying. How to remove that? or how to do this kind of chart using custom widgets?
// child of some widgets like container
child: SfCartesianChart(
primaryXAxis: CategoryAxis(),
legend: Legend(isVisible: false),
tooltipBehavior: TooltipBehavior(enable: true),
series: <ChartSeries<_SalesData, String>>[
LineSeries<_SalesData, String>(
dataSource: data,
xValueMapper: (_SalesData sales, _) =>sales.year.toString(),
yValueMapper: (_SalesData sales, _) =>sales.value,
),
],
),
You can customize you chart, You can use this. I use map for test and date for example ({"val": 100, "year": 2000}), so you can use your favorite type, Set or anything else.
SfCartesianChart(
primaryXAxis: CategoryAxis(
isVisible: false,
),
primaryYAxis: CategoryAxis(
isVisible: false,
),
plotAreaBorderWidth: 0,
backgroundColor: Colors.grey[200],
legend: Legend(isVisible: false),
tooltipBehavior: TooltipBehavior(enable: true),
series: <ChartSeries<Map, String>>[
FastLineSeries<Map, String>(
width: 2,
dataSource: [{"val": 100, "year": 2000}, ...],
color: Colors.green,
yValueMapper: (Map sales, _) => sales['val'],
xValueMapper: (Map sales, _) => sales['year'].toString(),
),
],
),
I am using this plugin for creating a pie chart. The label are shown perfectly when there are only 2 divisions but when they increase only 2 labels are shown rest are not.
My Code:-
final List<ChartData> chartData=[ChartData('abc;, 15),ChartData('uvw', 15),ChartData('xyz', 15)];
class ChartData {
ChartData(this.x, this.y, [this.color]);
final String x;
final double y;
final Color color;
}
SfCircularChart(
series: <CircularSeries>[
DoughnutSeries<ChartData, String>(
dataSource: chartData,
pointColorMapper:(ChartData data, _) => data.color,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y,
startAngle: 90,
endAngle: 360,
dataLabelMapper: (ChartData data, _) => data.x,
radius: '45%',
dataLabelSettings: DataLabelSettings(
isVisible: true,
labelPosition: ChartDataLabelPosition.outside,
labelAlignment: ChartDataLabelAlignment.auto,
textStyle: GoogleFonts.gugi(
textStyle: TextStyle(
),
),
),
)
]
),