Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combine Bar Chart with Line + add secondary axis #499

Closed
gerripro opened this issue Nov 20, 2020 · 13 comments
Closed

Combine Bar Chart with Line + add secondary axis #499

gerripro opened this issue Nov 20, 2020 · 13 comments
Labels

Comments

@gerripro
Copy link

How can one combine bar chart and line chart? is it possible to make secondary axis for either?
Currently I can't find such features in the library and that will be awesome if you have those possibilities

@verscph
Copy link

verscph commented Dec 6, 2020

+1

I'm having the same requirement.

@jimbengtsson92
Copy link

I am doing this right now by adding a BarChartData and a LineChartData in a stack. To get them correctly aligned I show the left and right SideTitles of both charts, but set getTitles: (value) => '' in the axis of a chart which should not show any labels for the axis.

The only problem I see at the moment with this is responding to touch, since only the top chart will receive any touches.

@florianhenonin
Copy link

Same requirement for me.
To handle display tooltip item for bar and line charts, I've duplicate bar values in line chart and set a transparent color to dot and line.
It works fine : bar and line are displayed, and on touch, tooltip display bar values.
Hope this helps

@jimbengtsson92
Copy link

@florianhenonin Could you please further explain your solution? If you could copy some code I would be really grateful 😃

@florianhenonin
Copy link

I can't share my code because of company privacy...

But I can explain you how reproduce this code !
Stack( children: [ _BarChart(...), _LineChart(...), ], )

Do not display grid on the BarChart. Touch will not be available because LineChart is over, don't worry.
On the LineChart you should integrate BarChart data with transparent color for lines & dots + add your line data with normal lines & dot colors.
Doing this, on touch, because of transparent lines & dots corresponding to BarChart data, you can show the tooltip with BarChart & LineChart data !✌🏻

@jimbengtsson92
Copy link

Ok thank you for the explanation! I will try to do this for my chart as well :)

@gabcarneiro
Copy link

I have the same requirement

I will try @florianhenonin's solution for now

@Nolat
Copy link

Nolat commented Mar 11, 2021

Same here 👍🏻

1 similar comment
@dmlzj
Copy link

dmlzj commented Apr 1, 2021

Same here 👍🏻

@jingen11
Copy link

thanks @florianhenonin !

@imaNNeo
Copy link
Owner

imaNNeo commented Aug 18, 2021

@florianhenonin I appreciate your approach.
It will be great if you implement and add one example of combined BarChart/LineChart in our sample app.
Regards!

@imaNNeo
Copy link
Owner

imaNNeo commented Jan 30, 2023

There is an issue to follow up the secondary axis here: #429.

But about the combined bar chart and line chart, let's keep this issue.

@imaNNeo
Copy link
Owner

imaNNeo commented Apr 11, 2023

For the combined bar chart, there is an issue which has 16 thumbs up (more than this issue),
So I will close this issue, we can follow it here: #764

@imaNNeo imaNNeo closed this as completed Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants