enable labels on separate line for horizontal bar charts
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 18.3k
- Forks
- 2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 28
Description
This feature would make horizontal bar charts readable with long tick labels and narrow screens. Other libraries have this feature.
Suggested option:
ticklabelposition="inside above".
Suggested output:

However, current subplot workaround fails due to memory heap size dramatically increasing with row numbers (100+). It's also challenging to get the label position and grid lines correct. Mirroring axes also not possible.
https://dkane.net/2020/better-horizontal-bar-charts-with-plotly/ by @drkane
There is a javascript workaround I have seen however, I cannot get this to work on my dashapp.
https://medium.com/@tbarrasso/plotly-tip-6-positioning-axis-titles-in-horizontal-bar-chart-56b0713f9745
var yAxisLabels = [].slice.call(document.querySelectorAll('[class^="yaxislayer"] .ytick text, [class*=" yaxislayer"] .ytick text'))
var bar = document.querySelector('.plot .barlayer .bars path')
var barHeight = bar.getBBox().height
var offset = 12
for (var i = 0; i < yAxisLabels.length; i++) {
var yAxisLabel = yAxisLabels[i];
yAxisLabel.setAttribute('text-anchor', 'start')
yAxisLabel.setAttribute('y', yAxisLabel.getAttribute('y') - (barHeight / 2) - offset)
}
})```
Any input appreciated.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing horizontal bar-chart axis and tick-label rendering in plotly.js, using the requested ticklabelposition="inside above" behavior as the target. Compare the existing subplot and JavaScript workarounds with the attached example. Done means long labels render on a separate line for narrow horizontal bar charts without the reported memory, positioning, grid-line, or axis-mirroring problems.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- data-visualization
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100