Skip to content

Conversation

@Shunt22
Copy link

@Shunt22 Shunt22 commented Feb 17, 2025

We can use something like this to add text for horizontal and vertical range annotations.
Refrering to: #522.
Usage:

VerticalRangeAnnotation(
  horizontalPadding: 0,
  verticalPadding: 0,
  text: "Hello world",
  style: TextStyle(),
  rotation: 90,
  x1: 0,
  x2: 10,
  color: Colors.red,
 )
                                   

@imaNNeo
Copy link
Owner

imaNNeo commented Apr 13, 2025

When I tried to add it in our line chart sample 8, it didn't work as I expected. So the text is somewhere else
image

@Shunt22
Copy link
Author

Shunt22 commented Apr 17, 2025

I've made it more clearer.
image
image

@Shunt22 Shunt22 force-pushed the annotation_labels branch from 4d95309 to 51ef6bd Compare April 17, 2025 09:35
@codecov
Copy link

codecov bot commented Apr 28, 2025

Codecov Report

Attention: Patch coverage is 59.09091% with 9 lines in your changes missing coverage. Please review.

Project coverage is 92.21%. Comparing base (195a41c) to head (c9a201e).
Report is 56 commits behind head on main.

Files with missing lines Patch % Lines
.../src/chart/base/axis_chart/axis_chart_painter.dart 59.09% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1865      +/-   ##
==========================================
- Coverage   92.51%   92.21%   -0.31%     
==========================================
  Files          46       46              
  Lines        3341     3366      +25     
==========================================
+ Hits         3091     3104      +13     
- Misses        250      262      +12     
Flag Coverage Δ
flutter 92.21% <59.09%> (-0.31%) ⬇️

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.

@imaNNeo
Copy link
Owner

imaNNeo commented Dec 6, 2025

Hi, thanks for the update. Functionality seems to work well! Good job.
But there are still some concerns that I'll write about in the further messages:

final TextStyle style;

/// Text rotation in degrees
final double? rotation;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to specifically mention that it is related to the text in it's name.
So I would go with textRotation (the same for textStyle)

final double? rotation;

/// Text text padding
final double horizontalPadding;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, padding is not what we have here. I think we can use offset name here.
And I would define a single property final Offset textOffset for both horizontal and vertical variables (dx and dy)

final double verticalPadding;

/// Lerps a [HorizontalRangeAnnotation] based on [t] value, check [Tween.lerp].
static HorizontalRangeAnnotation lerp(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And please don't forget to add the new properties in the lerp() function as well.
It helps us to have transition animation for these added properties!

@imaNNeo
Copy link
Owner

imaNNeo commented Dec 6, 2025

And my last comment:
Does it make sense to have a textAlignment property (which is Alignment) and defines the relative position of the text property inside the area?
I think at the moment we always draw on bottomLeft, but using this property we can make it customizable to allow people to draw it wherever they want. For example bottomCenter.

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