Skip to content

Conversation

@alettsy
Copy link
Contributor

@alettsy alettsy commented Jul 19, 2025

Hello! 👋

First of all, thank you for an awesome chart package 😊

This contribution is to resolve #1946.

What I did

I added an optional Boolean property for the AxisTitles class to allow each side title to be overlayed on the chart area if the user so desires.

For example, in Line Chart Sample 9, I added the property to the left titles and now it is placed on the chart area.

You can see the example use here:
image

With the result:
image

@imaNNeo imaNNeo requested a review from Copilot August 1, 2025 22:24
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds the ability to overlay axis titles on the chart area instead of positioning them outside the chart boundaries. This addresses issue #1946 by introducing an optional overlayOnChart boolean property to the AxisTitles class.

  • Added overlayOnChart property to AxisTitles class with default value of false
  • Modified padding calculation logic to exclude reserved space when titles are overlayed
  • Added test coverage for the new overlay functionality

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
lib/src/chart/base/axis_chart/axis_chart_data.dart Added overlayOnChart boolean property to AxisTitles class
lib/src/extensions/fl_titles_data_extension.dart Updated padding calculation to consider overlay flag
test/chart/base/axis_chart/side_titles/side_titles_test.dart Added test for overlay functionality

Repository owner deleted a comment from Copilot AI Aug 1, 2025
@imaNNeo
Copy link
Owner

imaNNeo commented Aug 1, 2025

Sorry, I just decided to test the copilot review feature in your branch for the first time. But I liked the result actually xD

I also like the feature you added. I think it is needed by some users. And there might be a similar issue.
So I have a suggestion to have extra customizability (as it is one of our core values)
Can you add a concept like Alignment here? For example, it can be a value between -1 and 1
If it is -1, it is fully outside the chart (default)
If it is 1, it is fully inside the chart
If it is 0, it is exactly on the borderline of the chart (half outside, half inside)

So this way, people have a high level of customization. For example, someone can pass 0.75 to have it mostly inside the chart (but 25% of it is outside)

@alettsy
Copy link
Contributor Author

alettsy commented Aug 2, 2025

Haha no problem! It looks like it did a good job code reviewing my pull requests.

I will take a look at adding this tomorrow 😊

@alettsy
Copy link
Contributor Author

alettsy commented Aug 7, 2025

Hi 👋

I have added changes to make the positions of the side titles changeable via the property sideTitleAlignment which accepts an enum:

SideTitleAlignment.inside   // for displaying inside the chart bounds
SideTitleAlignment.border   // for displaying on the borderline 
SideTitleAlignment.outside  // default, displays outside the chart

I am still looking at a different way to do that unit test 😊

@alettsy
Copy link
Contributor Author

alettsy commented Aug 10, 2025

I have pushed a test that finds the left side title labelled L-0 in order to check the positioning is correct.

Please let me know if there are any issues 😊

@codecov
Copy link

codecov bot commented Aug 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.47%. Comparing base (9e51b11) to head (199e4a4).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1959      +/-   ##
==========================================
+ Coverage   92.44%   92.47%   +0.02%     
==========================================
  Files          50       50              
  Lines        3681     3693      +12     
==========================================
+ Hits         3403     3415      +12     
  Misses        278      278              
Flag Coverage Δ
flutter 92.47% <100.00%> (+0.02%) ⬆️

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 Aug 21, 2025

Please also add the property to the base_chart.md file (our documentation)
You also need to do a rebase to get rid of the validation errors, I think.

After doing that, it looks good to get merged into the main!
Thanks for contributing.

@alettsy alettsy force-pushed the add_axis_title_overlaying branch from f92df20 to 199e4a4 Compare August 21, 2025 14:19
@alettsy
Copy link
Contributor Author

alettsy commented Aug 21, 2025

Hi, @imaNNeo 👋 I have updated the code with your requested changes and rebased for the main branch.

Please let me know if there are any other issues 😊

@imaNNeo imaNNeo merged commit e58b6b1 into imaNNeo:main Aug 24, 2025
4 checks passed
@imaNNeo
Copy link
Owner

imaNNeo commented Aug 24, 2025

Thanks for your valuable contribution!

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.

Is it possible to move x axis labels in chart area?

2 participants