amcharts5
amcharts5 copied to clipboard
How to get the _contentHeight of a legend ?
Hello,
I want to retrieve the content height of a legend.
For example : https://codepen.io/Justinemlss/pen/jOzxWNZ
When i console.log legend, I can see a property named _contentHeight with the value 28. But I don't know how to retrieve this property. legend._contentHeight : doesn't work legend.get("._contentHeight") : doesn't work
In the legend documentation : https://www.amcharts.com/docs/v5/reference/legend/, there is the method height() which is supposed to Returns height of this element in pixels, but .. legend.height() returns 0 !
Can you help me please thanks
I guess you call legend.height()
without waiting for the legend to be built. You should do that on boundschanged
event:
legend.events.on("boundschanged", function(){
console.log(legend.height())
})
This will console the real height of a legend, not only visible part. And then you can update size of your legend div: https://codepen.io/team/amcharts/pen/poLKYRy
This issue is stale because it has been open 30 days with no activity. It will be closed in 5 days unless a new comment is added.