Skip to content

Commit 51ef6bd

Browse files
committed
padding fix
1 parent 276775e commit 51ef6bd

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

example/lib/presentation/samples/line/line_chart_sample8.dart

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,18 +125,23 @@ class _LineChartSample8State extends State<LineChartSample8> {
125125
color: AppColors.contentColorBlue.withValues(alpha: 0.2),
126126
),
127127
VerticalRangeAnnotation(
128-
x1: 8,
129-
x2: 9,
130-
color: AppColors.contentColorBlue.withValues(alpha: 0.2),
131-
text: "This is a text",
132-
),
128+
x1: 8,
129+
x2: 9,
130+
color: AppColors.contentColorBlue.withValues(alpha: 0.2),
131+
text: "This is a text",
132+
verticalPadding: -10,
133+
style: const TextStyle(
134+
color: Colors.amber,
135+
fontSize: 18,
136+
)),
133137
],
134138
horizontalRangeAnnotations: [
135139
HorizontalRangeAnnotation(
136140
y1: 2,
137141
y2: 3,
138142
color: AppColors.contentColorGreen.withValues(alpha: 0.3),
139143
text: "This is a text",
144+
horizontalPadding: -30,
140145
),
141146
],
142147
),

lib/src/chart/base/axis_chart/axis_chart_painter.dart

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,10 @@ abstract class AxisChartPainter<D extends AxisChartData>
195195

196196
drawAnnotationText(
197197
canvasWrapper,
198-
offset: rect.centerLeft,
198+
offset: rect.centerLeft -
199+
Offset(annotation.horizontalPadding, annotation.verticalPadding),
199200
text: annotation.text,
200201
style: annotation.style,
201-
verticalPadding: annotation.verticalPadding,
202-
horizontalPadding: annotation.horizontalPadding,
203202
rotation: annotation.rotation ?? -90,
204203
);
205204
}
@@ -226,11 +225,10 @@ abstract class AxisChartPainter<D extends AxisChartData>
226225

227226
drawAnnotationText(
228227
canvasWrapper,
229-
offset: rect.centerLeft,
228+
offset: rect.centerLeft -
229+
Offset(annotation.horizontalPadding, annotation.verticalPadding),
230230
text: annotation.text,
231231
style: annotation.style,
232-
verticalPadding: annotation.verticalPadding,
233-
horizontalPadding: annotation.horizontalPadding,
234232
rotation: annotation.rotation ?? 0,
235233
);
236234
}
@@ -242,8 +240,6 @@ abstract class AxisChartPainter<D extends AxisChartData>
242240
String? text,
243241
required Offset offset,
244242
TextStyle? style,
245-
double verticalPadding = 0,
246-
double horizontalPadding = 0,
247243
double rotation = 0,
248244
}) {
249245
if (text == null) {

0 commit comments

Comments
 (0)