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

Get bar width after render? #4663

Closed
GreggOD opened this issue Aug 16, 2017 · 5 comments
Closed

Get bar width after render? #4663

GreggOD opened this issue Aug 16, 2017 · 5 comments

Comments

@GreggOD
Copy link

GreggOD commented Aug 16, 2017

Context

I have looked through the chart object and I am battling to find the bar width in pixel value anywhere.

Is this stored in the object? or is there anyway i can get this?

Thanks

@nagix
Copy link
Contributor

nagix commented Aug 16, 2017

You can get the bar width as follows:

var meta = myChart.getDatasetMeta(0);
var width = meta.data[0]._model.width;

@GreggOD
Copy link
Author

GreggOD commented Aug 17, 2017

That works perfectly thank you very much 👍
@simonbrunel

@simonbrunel
Copy link
Member

Thanks @nagix ;)

@TannSan
Copy link

TannSan commented Mar 31, 2018

For future readers....use the .height property if you are using a horizontal bar chart as .width will be undefined.

@curiousPup
Copy link

is there a way of getting both height and width of a bar in bar chart?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants