Remove the space between arcs in Pie Chart, charts_flutter package - flutter

I am using the charts_flutter package to display a Pie Chart. This is my code:
charts.PieChart<String>(
series,
animate: true,
defaultRenderer: charts.ArcRendererConfig(
strokeWidthPx: 0,
arcRendererDecorators: [
charts.ArcLabelDecorator(
labelPosition: charts.ArcLabelPosition.inside,
labelPadding: 3,
showLeaderLines: false,
insideLabelStyleSpec: const charts.TextStyleSpec(color: charts.Color.white, fontSize: 14, fontWeight: "HelveticaRegular"),
),
],
),
),
However, I want to remove this padding between the arcs. Is it possible?

Related

How can I provide different coloured plt points on my line graph in charts_flutter

I am creating a line graph in flutter and I would like the points to be different colours or even different icons depending on the position on the measure axis. Is this possible with this package.
The code below is my current Linechart
return new charts.LineChart(
widget.seriesList,
animate: widget.animate,
defaultRenderer: new charts.LineRendererConfig(
includePoints: true,
includeArea: false,
radiusPx: 5,
),
selectionModels: [
new charts.SelectionModelConfig(
type: charts.SelectionModelType.info,
changedListener: (num)=>{
widget.callback(num)
},
)
],
//this is the xaxis
domainAxis: new charts.NumericAxisSpec(
showAxisLine: true,
tickProviderSpec: new charts.BasicNumericTickProviderSpec(
zeroBound: false,
desiredMinTickCount: 12,
desiredMaxTickCount: 12
),
),
primaryMeasureAxis: new charts.NumericAxisSpec(
showAxisLine: true,
tickProviderSpec: new charts.BasicNumericTickProviderSpec(
desiredTickCount: 11,
desiredMinTickCount: 6,
desiredMaxTickCount: 11
),
),
);

Flutter: Syncfusion Chart Give Upper Limit to y-axis

I have a SfCartesianChart which displays a line chart of a list of values from 0 to 100, i.e. percentages. However, when there is a data point, for example, 99%, the upper limit of the y-axis seems like 120% which does not mean anything.
Here is my chart code
SfCartesianChart(
margin: EdgeInsets.all(0),
borderWidth: 0,
plotAreaBorderWidth: 0,
title: ChartTitle(text: 'Mood Tracks', textStyle: TextStyle(fontWeight: FontWeight.bold)),
tooltipBehavior: _tooltipBehavior,
series: <ChartSeries>[
LineSeries<MoodRecord, dynamic>(
name: 'Moods',
color: Colors.green[400],
dataSource: records,
xValueMapper: (MoodRecord record, _) => record.date,
yValueMapper: (MoodRecord record, _) => record.mood.toInt(),
dataLabelSettings: DataLabelSettings(isVisible: false),
enableTooltip: true,
animationDuration: 2000,
markerSettings: MarkerSettings(
isVisible: true,
shape: DataMarkerType.circle,
color: kPrimaryColor
)
)
],
primaryXAxis: CategoryAxis(
labelPlacement: LabelPlacement.onTicks,
labelStyle: TextStyle(fontWeight: FontWeight.bold)
),
primaryYAxis: NumericAxis(
labelFormat: '{value}%',
labelStyle: TextStyle(fontWeight: FontWeight.bold)
),
),
Is there any way to define an upper limit on the y-axis? I do not want my chart to display something like 120% on the y-axis.
If there any better way to display percentages, it would also be appreciated.
We have looked over the question and code and can inform you that the axis range is determined by the data source values. If you don't want values above 100 to be shown, use the maximum property in the axis and manually customize the range. For more details, see the help document. You may also use the numberFormat property to reflect percentage values, as seen in the example below.
https://www.syncfusion.com/kb/11519/how-to-apply-the-currency-format-to-the-axis-labels-sfcartesianchart
For 100 percent stacked charts, refer to the support document, which converts the given data to 100 percent.
SfCartesianChart(
primaryXAxis: CategoryAxis(labelStyle: const TextStyle(
color: Colors.white,
fontFamily: 'Roboto',
fontSize: 10,
)),
primaryYAxis: NumericAxis(
**minimum: 0, maximum: 100, interval: 25,**
labelFormat: '{value}%',
labelStyle: const TextStyle(
color: Colors.white,
fontFamily: 'Roboto',
fontSize: 10,
)),

Flutter: Show "No Data" message in Syncfusion CartesianChart

I am using the syncfusion library for Flutter and I can build a line chart when I have data. However, if the list is empty, it simply draws axes and that is all. Even though this is expected, I want to write a "No Data" message in the center of the chart.
Here is my chart widget:
SfCartesianChart(
margin: EdgeInsets.all(0),
borderWidth: 0,
plotAreaBorderWidth: 0,
title: ChartTitle(text: 'Mood Tracks', textStyle: TextStyle(fontWeight: FontWeight.bold)),
tooltipBehavior: _tooltipBehavior,
series: <ChartSeries>[
LineSeries<MoodRecord, dynamic>(
name: 'Moods',
color: Colors.green[400],
dataSource: [],
xValueMapper: (MoodRecord record, _) => record.date,
yValueMapper: (MoodRecord record, _) => record.mood.toInt(),
dataLabelSettings: DataLabelSettings(isVisible: true),
enableTooltip: true)
],
primaryXAxis: CategoryAxis(
labelPlacement: LabelPlacement.onTicks,
labelStyle: TextStyle(fontWeight: FontWeight.bold)
),
primaryYAxis: NumericAxis(
labelFormat: '{value}%',
labelStyle: TextStyle(fontWeight: FontWeight.bold)
),
),
Is there any way to show such message?
We have looked through the question and like to tell you that we can meet the requirement by using the chart's annotations property. We can position the Text Widget with ‘No Data' if the data source is empty, otherwise, we can allocate the empty container to the annotations. Using these annotations, we can place the necessary widget in the required position in the map, and for more detail, see the support document and we have attached the sample as a reference.
Sample: https://www.syncfusion.com/downloads/support/directtrac/326033/ze/I326033_no_data_text48946494

charts_flutter: how to do a line chart overlapping y-axis label using Flutter Chart?

can anyone help me out with this issue? I am using charts_flutter library, wanted the chart to be overlapping the y-axis label.
library: https://pub.dev/packages/charts_flutter
I wanted result like this:
This is my code:
TimeSeriesChart(
seriesList,
dateTimeFactory: const LocalDateTimeFactory(),
animate: animate,
domainAxis: DateTimeAxisSpec(
renderSpec: GridlineRendererSpec(
labelStyle: new TextStyleSpec(
fontSize: MyDimens.chart_text_size, //
color: labelColor),
lineStyle: LineStyleSpec(
thickness: 0, color: MaterialPalette.transparent)),
),
primaryMeasureAxis: new NumericAxisSpec(
tickFormatterSpec: simpleCurrencyFormatter,
tickProviderSpec: new BasicNumericTickProviderSpec(
zeroBound: false,
dataIsInWholeNumbers: false,
desiredTickCount: MyDimens.chart_desired_tick_count,
),
renderSpec: new GridlineRendererSpec(
// Tick and Label styling here.
labelStyle: new TextStyleSpec(
fontSize: MyDimens.chart_text_size, //
color: labelColor),
// Change the line colors to match text color.
lineStyle: new LineStyleSpec(color: lineColor),
labelAnchor: TickLabelAnchor.after,
labelJustification: TickLabelJustification.inside,
)),
)
Set zeroBound parameter to true
Just set a negative number to labelOffsetFromAxisPx in renderSpec
like this:
labelOffsetFromAxisPx = -15
to get a better result, change labelJustification to TickLabelJustification.outside
finally change your code to:
primaryMeasureAxis: new NumericAxisSpec(
tickFormatterSpec: simpleCurrencyFormatter,
tickProviderSpec: new BasicNumericTickProviderSpec(
zeroBound: false,
dataIsInWholeNumbers: false,
desiredTickCount: MyDimens.chart_desired_tick_count,
),
renderSpec: new GridlineRendererSpec(
// Tick and Label styling here.
labelStyle: new TextStyleSpec(
fontSize: MyDimens.chart_text_size, //
color: labelColor),
// Change the line colors to match text color.
lineStyle: new LineStyleSpec(color: lineColor),
labelAnchor: TickLabelAnchor.after,
labelJustification: TickLabelJustification.outside,
// Add offset herer
labelOffsetFromAxisPx: -15,
)),

Why does my flutter LineChart stop drawing in the middle of the chart?

so I've been writing my first flutter app lately and at some point I wanted to display a LineChart with the charts_flutter package. Most of the time it works perfectly, but sometimes the graph doesn't stretch until the end of the chart. Sadly I wasn't able to reproduce that error precisely, but I guess it happens when you enter around 10 entries (?).
That's how the graph looks when it doesn't work.
I really hope that someone can help me because I'm out of ideas.
Here's my code for the chart:
#override
Widget build(BuildContext context) {
final yTickFormatter = charts.BasicNumericTickFormatterSpec((num value) {
return value.toStringAsFixed(2) + SettingsUtil.currency;
});
final customTickFormatter =
charts.BasicNumericTickFormatterSpec((num value) {
if (value == 0 && SettingsUtil.savingEntries.length > 1) {
return SettingsUtil.savingEntries[1].getDateString();
} else if (value == 0 && SettingsUtil.savingEntries.length <= 1) {
return '';
} else {
return SettingsUtil.savingEntries[SettingsUtil.savingEntries.length - 1]
.getDateString();
}
});
return SizedBox(
width: MediaQuery.of(context).size.width - 20,
height: 200,
child: charts.LineChart(seriesList,
animate: animate,
primaryMeasureAxis: charts.NumericAxisSpec(
tickProviderSpec: charts.BasicNumericTickProviderSpec(
desiredMinTickCount: 2, desiredMaxTickCount: 3),
renderSpec: charts.GridlineRendererSpec(
// Tick and Label styling here.
labelStyle: charts.TextStyleSpec(
fontSize: 15, // size in Pts.
color: SettingsUtil.getChartTextColor())),
tickFormatterSpec: yTickFormatter,
),
domainAxis: charts.NumericAxisSpec(
renderSpec: charts.SmallTickRendererSpec(
// Tick and Label styling here.
labelStyle: charts.TextStyleSpec(
lineHeight: 3,
fontSize: 13, // size in Pts.
color: SettingsUtil.getChartTextColor())),
tickProviderSpec:
charts.BasicNumericTickProviderSpec(desiredTickCount: 2),
tickFormatterSpec: customTickFormatter,
),
customSeriesRenderers: [
charts.LineRendererConfig(
// ID used to link series to this renderer.
customRendererId: 'customArea',
includeArea: true,
stacked: true),
]),
);
}
In the domainAxis you need to set desiredTickCount: seriesList.length:
...
domainAxis: charts.NumericAxisSpec(
tickProviderSpec:
charts.BasicNumericTickProviderSpec(
desiredTickCount: seriesList.length,
),
),
...