You must be logged in to post your query.
Home › Forums › Chart Support › Dynamic indexLabelOrientation
Tagged: Bar charts, indexLabelOrientation
I was wondering if it is possible to have a dynamically generated indexLabelOrientation. A customer uses bar charts that can have as many as 31 bars, one for each day of the month, or as low as 1, if there is data for one day only. When reaching a certain number of bars it is best to use vertical orientation, but when the quantity is low, the horizontal orientation is preferred.
It seems that indexLabelOrientation does not allow using functions to return different values depending on the data quantity. Is there any way to switch between vertical and horizontal orientation by having a threshold, say, 15 bars of data?
Thanks in advance.
You can set indexLabelOrientation property to “vertical” or “horizontal” depending on the number of datapoints and update the chart options. Please find the code snippet below,
if(chart.options.data.dataPoints.length > 15)
chart.options.data.indexLabelOrientation = "vertical";
chart.options.data.indexLabelOrientation = "horizontal";
Please take a look at this JSFiddle for working example.
Thank you so much, Adithya, it works like a charm!
You must be logged in to reply to this topic. Login/Register