Skip to content

Conversation

@PhilippHGerber
Copy link

Summary

This PR adds support for an optional horizontal indicator line in LineChart.

What's included

  • TouchedSpotIndicatorData:
    • showHorizontalLine: enables horizontal indicator line rendering
    • indicatorHorizontalLine: defines the horizontal line's appearance
    • Fallback: if indicatorHorizontalLine is null, indicatorBelowLine is used
  • Drawing logic in LineChartPainter.drawTouchedSpotsIndicator
  • Unit test for horizontal line rendering
  • Sample updated in line_chart_sample12.dart
  • Documentation updated in line_chart.md

Screenshot

Line Chart Sample 12 with horizontal indicator line

showHorizontalLine

Let me know if anything should be adjusted.

- Added `showHorizontalLine` and `indicatorHorizontalLine` to `TouchedSpotIndicatorData`
- Fallback: if `indicatorHorizontalLine` is null, it defaults to `indicatorBelowLine`
- Updated `LineChartPainter.drawTouchedSpotsIndicator` to render horizontal line
- Added unit test in `line_chart_painter_test.dart`
- Updated example in `line_chart_sample12.dart` to demonstrate new feature
@imaNNeo
Copy link
Owner

imaNNeo commented Apr 23, 2025

Hi, such a coincidence!
I was working on the CandlestickChart and I came up with the idea to implement this feature in a way that we can re-use it for other chart types.
You can find it here: #1897

So I suggest to use the same approach that we have in CandlestickChart

@codecov
Copy link

codecov bot commented Apr 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.46%. Comparing base (690c43c) to head (ccb3a4f).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1902      +/-   ##
==========================================
+ Coverage   92.43%   92.46%   +0.03%     
==========================================
  Files          46       46              
  Lines        3344     3358      +14     
==========================================
+ Hits         3091     3105      +14     
  Misses        253      253              
Flag Coverage Δ
flutter 92.46% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants