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

_bullet measure and range bars have issues if the data set has negative values #4497

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ksheehy
Copy link

@ksheehy ksheehy commented Jan 26, 2024

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.
Screenshot 2024-01-26 130212

Here is a fix.
Screenshot 2024-01-26 130307

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.

@ksheehy ksheehy changed the title _bullet has an issue building measure and range bars if the data set … _bullet measure and range bars have bugs if the data set has negative values Jan 26, 2024
@ksheehy ksheehy changed the title _bullet measure and range bars have bugs if the data set has negative values _bullet measure and range bars have issues if the data set has negative values Jan 26, 2024
@Coding-with-Adam
Copy link
Contributor

Thank you for reporting this, @ksheehy

@Coding-with-Adam
Copy link
Contributor

Hi @archmoj
Here's the code pen for this issue:
https://codepen.io/charming-data/pen/ExJwxRY

@archmoj
Copy link
Contributor

archmoj commented Mar 28, 2024

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.

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

Successfully merging this pull request may close these issues.

None yet

3 participants