From 9536295b5ef0c0ad550b44d773dcd753b06f28ac Mon Sep 17 00:00:00 2001 From: "hardi.jarvis@gmail.com" Date: Tue, 27 Oct 2020 00:27:03 +0530 Subject: [PATCH] Y Axis Lines display issue resolved. --- lib/src/bezier_chart_config.dart | 3 ++- lib/src/bezier_chart_widget.dart | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/src/bezier_chart_config.dart b/lib/src/bezier_chart_config.dart index d246e7a..3ab1f13 100644 --- a/lib/src/bezier_chart_config.dart +++ b/lib/src/bezier_chart_config.dart @@ -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; @@ -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, diff --git a/lib/src/bezier_chart_widget.dart b/lib/src/bezier_chart_widget.dart index a1032b5..c47a26f 100644 --- a/lib/src/bezier_chart_widget.dart +++ b/lib/src/bezier_chart_widget.dart @@ -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); @@ -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);