plotly.py
plotly.py copied to clipboard
_bullet measure and range bars have issues if the data set has negative values
The issue is with the method of sorting the data from highest to lowest. The data needs to be sorted so both, the largest positive and negative values are plotted first.
# Vertical Velocity
data = (
{"label": "Vertical Velocity", "sublabel": "[FPM]",
"range": sorted([-5000, -3000, 3000, 5000]), "performance": [-2000, -1000, 1000, 2000], "point": [500], 'command': [600]},
)
fig = ff.create_bullet(
data, titles='label', subtitles='sublabel', markers='point',
measures='performance', ranges='range', orientation='v',
title='Bullet Chart',
scatter_options={'marker': {'symbol': 'diamond'}},
width=300,
)
fig.show()
Here is the current implementation - you can see since the sort function puts the -5000 tick mark last and the bar on top of all less negative values.
Here is a fix.
I did a little search on this function and it looks like it is being depreciated. I appologize if I have butchered the PR process.
Thank you for reporting this, @ksheehy
Hi @archmoj Here's the code pen for this issue: https://codepen.io/charming-data/pen/ExJwxRY
Thanks very much for the PR.
This looks good.
Please add a test in packages/python/plotly/plotly/tests/test_optional/test_figure_factory/test_figure_factory.py to lock this bug.