imaNNeo / imaNNeo/fl_chart

Line/Bar Chart should fill available width

Open
#483 4 comments 0 reactions 0 assignees View on GitHub
enhancement Fundamental
Dominant language
Dart
Stars
7.6k
Forks
2k
Avg merge
9d 1h
Merged PRs (30d)
2

Description

Line and bar charts are currently set to a square based on the screen size, which isn't ideal in a lot of situations. For instance in landscape mode this leaves charts with substantial margins on the left/right where the charts wold be much more readable if allowed to expand to fill their container. Another scenario is if say you want to view 2 charts on the screen at once. Since they take up 70% of the screen size, this kind of thing wouldn't be possible.

**Proposed solution**

I think 2 changes are probably warranted here:

- Accept an optional Size parameter which if given is used on the CustomPaint widget (if not getDefaultSize is still called as it is currently). This allows specifying specifying chart size as needed, for instance by using the constraints of a parent LayoutBuilder.
- Have getDefaultSize return just 0.7, rather than forcing it into a square. I probably don't quite understand the reasoning behind this decision, so maybe this isn't a good approach, but forcing to a square seems sub-optimal. At the very least it seems like in cases where the width is greater than the height (landscape) it should be allowed to expand to 70% of the width (rather than 70% of the height).

Happy to make a PR for either or both of these if this seems like a good change.

Contributor guide

Open the contributing guide

Research direction

Start by locating the chart widgets' CustomPaint usage and getDefaultSize implementation. Check how the current square dimensions are calculated, then verify how an optional Size and wider default layout would affect line and bar charts. Done means charts can use a supplied size and expand appropriately in landscape or multi-chart layouts.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter
Domain
data-visualization, frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.