Bug description:
Area line widget is giving inconsistent and permanent margine on x axis even after removing margine/padding by args.
EdgeInsets.zero, in SfCartesianChart and plotOffset 0 in CategoryAxis.
I made sure no extra margine or padding is added by parent widget(column).
Tested on multiple devices.
Steps to reproduce
Just wrap this widget code in a height bounded sizebox under column parent with other children.
https://i.sstatic.net/v89sMGCo.jpg
return SfCartesianChart(
borderWidth: 0,
key: widget.key,
margin: EdgeInsets.zero,
plotAreaBorderWidth: 0,
borderColor: Colors.transparent,
plotAreaBorderColor: Colors.transparent,
title: ChartTitle(text: widget.title),
primaryXAxis: CategoryAxis(
minimum: 0,
initialVisibleMinimum: 0,
initialVisibleMaximum: widget.data.length - 1,
autoScrollingDelta: widget.data.length,
labelAlignment: LabelAlignment.center,
edgeLabelPlacement: EdgeLabelPlacement.none,
majorGridLines: MajorGridLines(color: Colors.transparent),
plotOffset: 0, // Ensure no padding
rangePadding: ChartRangePadding.none,
axisLabelFormatter: (axisLables) {
final int index = widget.data.indexWhere((data) => data.x == axisLables.text);
final bool isSelected = index == _selectedIndex;
return ChartAxisLabel(
axisLables.text.length > 3
? axisLables.text.substring(0, 3)
: axisLables.text,
TextStyle(
color: isSelected ? Colors.white : billiGrey600,
fontSize: 12,
fontFamily: 'Poppins',
fontWeight: isSelected?FontWeight.bold:FontWeight.w400,
height: 0.14,
),
);
},
labelPlacement: LabelPlacement.onTicks, // Adjust label placement
),
primaryYAxis: NumericAxis(
isVisible: true,
minimum: 0,
maximum: widget.data
.map<double>((data) => data.y!)
.reduce((current, next) => current > next ? current : next) *
1.2,
plotOffset: 0,
anchorRangeToVisiblePoints: true, // Anchor range to visible points
axisLine: AxisLine(width: 0), // Hide the axis line
majorTickLines: MajorTickLines(size: 0), // Hide the major ticks
minorTickLines: MinorTickLines(size: 0), // Hide the minor ticks
labelStyle: TextStyle(color: Colors.transparent), // Hide the labels
majorGridLines: MajorGridLines(width: 0),
plotBands: <PlotBand>[
PlotBand(
start: widget.medianValue,
end: widget.medianValue,
borderColor: Colors.white,
borderWidth: 1,
horizontalTextAlignment: TextAnchor.start,
verticalTextPadding: '-8%',
verticalTextAlignment: TextAnchor.end,
dashArray: <double>[2, 2],
text: blurNumber
? 'Avg: ***'
: 'Avg: $${widget.medianValue.toStringAsFixed(2)}', //using widgte is not supported here so dev had to use provider. ideal case is use SectionSum widget
textStyle: TextStyle(
textBaseline: TextBaseline.ideographic,
decorationStyle: TextDecorationStyle.solid,
color: Colors.white,
backgroundColor: Colors.black.withOpacity(0.4),
fontFamily: GoogleFonts.poppins().fontFamily,
fontSize: 12,
fontWeight: FontWeight.w700,
),
),
],
),
// tooltipBehavior: _tooltipBehavior,
trackballBehavior: _trackballBehavior,
series: <CartesianSeries>[
SplineAreaSeries<ChartData, String>(
borderColor: Color(0xFF7A8DFE),
markerSettings: MarkerSettings(
color: Colors.transparent,
borderColor: Colors.transparent,
isVisible: true,
),
isVisibleInLegend: true,
legendIconType: LegendIconType.image,
splineType: SplineType.natural,
dataSource: widget.data,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y,
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Color(0x457A8DFE),
Color(0x306090FF),
Color(0x788DFF),
],
stops: [0.0, 0.4, 1.0],
),
),
],
},
); ```
4