Chart.js: Get bar width after render?

Created on 16 Aug 2017  路  5Comments  路  Source: chartjs/Chart.js

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

support

All 5 comments

You can get the bar width as follows:

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

That works perfectly thank you very much 馃憤
@simonbrunel

Thanks @nagix ;)

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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adriantombu picture adriantombu  路  3Comments

JAIOMP picture JAIOMP  路  3Comments

nanospeck picture nanospeck  路  3Comments

akashrajkn picture akashrajkn  路  3Comments

gabrieldesouza picture gabrieldesouza  路  3Comments