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

Expose width/height of VictoryLegend? #854

Closed
rudasoftware opened this issue Nov 21, 2017 · 2 comments · Fixed by FormidableLabs/victory-core#325
Closed

Expose width/height of VictoryLegend? #854

rudasoftware opened this issue Nov 21, 2017 · 2 comments · Fixed by FormidableLabs/victory-core#325

Comments

@rudasoftware
Copy link
Contributor

I'd like to be able to compute the width and height of a VictoryLegend component, based on the current values of its labels to make sure I have enough padding allotted for it in the wrapping VictoryChart.

Is there a way to expose the relevant calculations as static methods?

@ghost
Copy link

ghost commented Jun 28, 2019

@boygirl Could you explain how to use this?

I try to use it in the following fiddle but I am getting a width: NaN, height: NaN

https://jsfiddle.net/803xmr24/4/

@malutanpetronel
Copy link

it looks I still get NAN

const legendData = [
{ name: 'one' }, { name: 'two' }, { name: 'three' }
];
const legendDimensions = VictoryLegend.getDimensions(
{
data: legendData,
style: {
fontSize: '12px'
}
}
)
useEffect(() => {
console.warn(legendDimensions)
}, [])

image

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 a pull request may close this issue.

2 participants