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

Y Axis Lines display issue resolved. #105

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion lib/src/bezier_chart_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class BezierChartConfig {
final double contentWidth;

///`true` if you want to display a vertical line on each X data point, it only works when there is one `BezierLine`.
final bool displayLinesXAxis;
final bool displayLinesXAxis, displayLinesYAxis;

///Color for the vertical line in each X point, only works when `displayLinesXAxis` is true
final Color xLinesColor;
Expand Down Expand Up @@ -123,6 +123,7 @@ class BezierChartConfig {
this.verticalIndicatorFixedPosition = false,
this.startYAxisFromNonZeroValue = true,
this.displayLinesXAxis = false,
this.displayLinesYAxis = false,
this.stepsYAxis,
this.xLinesColor = Colors.grey,
this.displayDataPointWhenNoValue = true,
Expand Down
19 changes: 16 additions & 3 deletions lib/src/bezier_chart_widget.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import 'dart:math';
import 'dart:ui';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import 'bezier_line.dart';
import 'bezier_chart_config.dart';
import 'package:intl/intl.dart' as intl;

import 'bezier_chart_config.dart';
import 'bezier_line.dart';
import 'my_single_child_scroll_view.dart';

typedef FooterValueBuilder = String Function(double value);
Expand Down Expand Up @@ -1191,6 +1191,19 @@ class _BezierChartPainter extends CustomPainter {
canvas.drawLine(
Offset(valueX, height), Offset(valueX, valueY), paintXLines);
}
if (config.displayLinesYAxis) {
double yVal = valueY;
// Y axis Horizontal Line here.
double yHeight = height -
_getRealValue(
yVal - (config.startYAxisFromNonZeroValue ? minYValue : 0.0),
height,
_maxValueY,
);

canvas.drawLine(
Offset(0, yHeight), Offset(size.width, yHeight), paintXLines);
}

if (lastPoint == null) {
lastPoint = _AxisValue(x: valueX, y: valueY);
Expand Down