Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added interval field in the SideTitles class, fixed issue #67 #77

Merged
merged 1 commit into from
Oct 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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