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

Hiding or showing the legend doesn't adjust the chart to the available dimensions #25

Closed
darlesson opened this issue May 15, 2018 · 6 comments
Assignees
Milestone

Comments

@darlesson
Copy link

hide, show and setVisibility methods don't re-position or resize the chart.

https://codepen.io/team/amcharts/pen/e2b0557b22dd819159a5ff5dc82d255d/

@dswitzer
Copy link

Also, the documentation for the legend.disabled property states:

Controls if element is disabled.

A disabled element is hidden, and is removed from any processing, layout calculations, and generally treated like if it does not existed.

The element itself is not destroyed, though. Setting this back to false, will "resurrect" the element.

I read this as that setting disabled=true should be like setting the CSS display:none on an HTML element, in that the element should be treated as it does not exist.

However, I'm not finding this behavior is true. None of the items that I've tried setting disabled=true to that inherit from a Sprite actually cause the canvas to re-layout the element. It's acting more like CSS visibility: hidden and visibility: visible.

@zeroin zeroin added the in next release Implemented. Available soon. label Jun 5, 2018
@martynasma martynasma added this to the 4.0.0-beta.28 milestone Jun 5, 2018
@martynasma
Copy link
Collaborator

Solved in 4.0.0-beta.28 (changelog).

@dswitzer
Copy link

dswitzer commented Jun 5, 2018

Should hiding and showing a legend cause the chart to reposition to occupy the space the legend was using?

If so, it's not working properly.

It does work if I use chart.legend.disabled to toggle the legend, but using show() or hide() just toggle visibility without the chart reclaiming the space.

@martynasma
Copy link
Collaborator

Hm, that's a functional question. Should toggling item visibility also remove it from the layout tree? I tend to think it should not. Sort of like visibility: hidden equivalent.

While, disabled = true is display: none.

@dswitzer
Copy link

dswitzer commented Jun 5, 2018

For me, I would expect show() and hide() to work like display: none, but that might just be because that's the behavior of the common JS frameworks (e.g. jQuery). That doesn't mean I'm right, it was just my expectation. Usually showing or hiding an object removes it from the layout.

I certainly would expect setVisibility() to just be the equivalent of the CSS visibility property.

I would recommend that the documentation makes it very clear that the show() and hide() methods don't effect layout and point the user to using disabled if they require it be removed from layout.

Anyway, based on expectation, things seem to be working correctly now.

@martynasma
Copy link
Collaborator

Gotcha. Makes sense.

However, in SVG CSS works a lot differently than in HTML. And we - being SVG charts - are operating under SVG defaults.

In any case, we will discuss if this one more time.

Thanks!

@martynasma martynasma removed the in next release Implemented. Available soon. label Jul 6, 2018
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

No branches or pull requests

4 participants