Skip to content

Commit

Permalink
Merge pull request #77 from imaNNeoFighT/hotfix/titles-interval
Browse files Browse the repository at this point in the history
added interval field in the SideTitles class, fixed issue #67
  • Loading branch information
imaNNeo authored Oct 3, 2019
2 parents 9b2cedb + cbace91 commit f15936d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/src/chart/bar_chart/bar_chart_painter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class BarChartPainter extends AxisChartPainter {
final leftTitles = data.titlesData.leftTitles;
if (leftTitles.showTitles) {
int verticalCounter = 0;
while (data.gridData.verticalInterval * verticalCounter <= data.maxY) {
while (leftTitles.interval * verticalCounter <= data.maxY) {
double x = 0 + getLeftOffsetDrawSize();
double y = getPixelY(
data.gridData.verticalInterval * verticalCounter, drawSize) +
Expand All @@ -270,7 +270,7 @@ class BarChartPainter extends AxisChartPainter {
final rightTitles = data.titlesData.rightTitles;
if (rightTitles.showTitles) {
int verticalCounter = 0;
while (data.gridData.verticalInterval * verticalCounter <= data.maxY) {
while (rightTitles.interval * verticalCounter <= data.maxY) {
double x = drawSize.width + getLeftOffsetDrawSize();
double y = getPixelY(
data.gridData.verticalInterval * verticalCounter, drawSize) +
Expand Down
3 changes: 3 additions & 0 deletions lib/src/chart/base/base_chart/base_chart_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ class SideTitles {
final double reservedSize;
final TextStyle textStyle;
final double margin;
final double interval;

const SideTitles({
this.showTitles = false,
Expand All @@ -134,6 +135,7 @@ class SideTitles {
fontSize: 11,
),
this.margin = 6,
this.interval = 1.0,
});

static SideTitles lerp(SideTitles a, SideTitles b, double t) {
Expand All @@ -143,6 +145,7 @@ class SideTitles {
reservedSize: lerpDouble(a.reservedSize, b.reservedSize, t),
textStyle: TextStyle.lerp(a.textStyle, b.textStyle, t),
margin: lerpDouble(a.margin, b.margin, t),
interval: lerpDouble(a.interval, b.interval, t),
);
}
}
Expand Down
8 changes: 4 additions & 4 deletions lib/src/chart/line_chart/line_chart_painter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ class LineChartPainter extends AxisChartPainter {
y -= tp.height / 2;
tp.paint(canvas, Offset(x, y));

verticalSeek += data.gridData.verticalInterval;
verticalSeek += leftTitles.interval;
}
}

Expand All @@ -507,7 +507,7 @@ class LineChartPainter extends AxisChartPainter {

tp.paint(canvas, Offset(x, y));

horizontalSeek += data.gridData.horizontalInterval;
horizontalSeek += topTitles.interval;
}
}

Expand All @@ -532,7 +532,7 @@ class LineChartPainter extends AxisChartPainter {
y -= tp.height / 2;
tp.paint(canvas, Offset(x, y));

verticalSeek += data.gridData.verticalInterval;
verticalSeek += rightTitles.interval;
}
}

Expand All @@ -558,7 +558,7 @@ class LineChartPainter extends AxisChartPainter {

tp.paint(canvas, Offset(x, y));

horizontalSeek += data.gridData.horizontalInterval;
horizontalSeek += bottomTitles.interval;
}
}
}
Expand Down
1 change: 1 addition & 0 deletions repo_files/documentations/base_chart.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
|reservedSize| a reserved space to show titles|22|
|textStyle| [TextStyle](https://api.flutter.dev/flutter/painting/TextStyle-class.html) to determine the style of texts |TextStyle(color: Colors.black, fontSize: 11)|
|margin| margin of horizontal the titles | 6|
|interval| interval between of showing titles in this side, | 1.0 |



Expand Down

0 comments on commit f15936d

Please sign in to comment.