@@ -6,6 +6,7 @@ import 'package:fl_chart/src/chart/base/axis_chart/axis_chart_painter.dart';
6
6
import 'package:fl_chart/src/chart/base/base_chart/base_chart_data.dart' ;
7
7
import 'package:fl_chart/src/utils/lerp.dart' ;
8
8
import 'package:flutter/material.dart' ;
9
+ import 'package:fl_chart/src/utils/utils.dart' ;
9
10
10
11
/// This is the base class for axis base charts data
11
12
/// that contains a [FlGridData] that holds data for showing grid lines,
@@ -27,6 +28,12 @@ abstract class AxisChartData extends BaseChartData with EquatableMixin {
27
28
/// A background color which is drawn behind th chart.
28
29
Color backgroundColor;
29
30
31
+ /// Difference of [maxY] and [minY]
32
+ double get verticalDiff => maxY - minY;
33
+
34
+ /// Difference of [maxX] and [minX]
35
+ double get horizontalDiff => maxX - minX;
36
+
30
37
AxisChartData ({
31
38
FlGridData gridData,
32
39
FlAxisTitleData axisTitleData,
@@ -243,8 +250,8 @@ class SideTitles with EquatableMixin {
243
250
/// [textStyle] determines the text style of them,
244
251
/// [margin] determines margin of texts from the border line,
245
252
///
246
- /// by default, texts are showing with 1.0 interval,
247
- /// you can change this value using [interval ] ,
253
+ /// texts are showing with provided [ interval] ,
254
+ /// or you can let it be null to be calculated using [getEfficientInterval ] ,
248
255
///
249
256
/// you can change rotation of drawing titles using [rotateAngle] .
250
257
SideTitles ({
@@ -264,7 +271,7 @@ class SideTitles with EquatableMixin {
264
271
fontSize: 11 ,
265
272
),
266
273
margin = margin ?? 6 ,
267
- interval = interval ?? 1.0 ,
274
+ interval = interval,
268
275
rotateAngle = rotateAngle ?? 0.0 ;
269
276
270
277
/// Lerps a [SideTitles] based on [t] value, check [Tween.lerp] .
@@ -352,7 +359,7 @@ class FlGridData with EquatableMixin {
352
359
/// Determines showing or hiding all horizontal lines.
353
360
final bool drawHorizontalLine;
354
361
355
- /// Determines interval between horizontal lines.
362
+ /// Determines interval between horizontal lines, left it null to be auto calculated .
356
363
final double horizontalInterval;
357
364
358
365
/// Gives you a y value, and gets a [FlLine] that represents specified line.
@@ -364,7 +371,7 @@ class FlGridData with EquatableMixin {
364
371
/// Determines showing or hiding all vertical lines.
365
372
final bool drawVerticalLine;
366
373
367
- /// Determines interval between vertical lines.
374
+ /// Determines interval between vertical lines, left it null to be auto calculated .
368
375
final double verticalInterval;
369
376
370
377
/// Gives you a x value, and gets a [FlLine] that represents specified line.
@@ -407,11 +414,11 @@ class FlGridData with EquatableMixin {
407
414
CheckToShowGrid checkToShowVerticalLine,
408
415
}) : show = show ?? true ,
409
416
drawHorizontalLine = drawHorizontalLine ?? true ,
410
- horizontalInterval = horizontalInterval ?? 1.0 ,
417
+ horizontalInterval = horizontalInterval,
411
418
getDrawingHorizontalLine = getDrawingHorizontalLine ?? defaultGridLine,
412
419
checkToShowHorizontalLine = checkToShowHorizontalLine ?? showAllGrids,
413
420
drawVerticalLine = drawVerticalLine ?? false ,
414
- verticalInterval = verticalInterval ?? 1.0 ,
421
+ verticalInterval = verticalInterval,
415
422
getDrawingVerticalLine = getDrawingVerticalLine ?? defaultGridLine,
416
423
checkToShowVerticalLine = checkToShowVerticalLine ?? showAllGrids;
417
424
0 commit comments