Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix bin size becomes 1 (very thin) when data changes with barmode: 'overlay' for histogram#7507

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Lexachoc wants to merge3 commits intoplotly:master
base:master
Choose a base branch
Loading
fromLexachoc:fix_autobin_size_overlay

Conversation

@Lexachoc
Copy link
Contributor

@LexachocLexachoc commentedAug 3, 2025
edited
Loading

This PRfixes#7506

Description

When usingPlotly.react to update the data of a histogram withbarmode: 'overlay', if the traces contain single data points (one point per trace), the calculatedbin.size could incorrectly set to1. This results in the histogram bars becoming visually very thin after a data update.

This issue is particularly noticeable for react-plotly users, where data mutations are frequent.

Changes

This new logic ensures that auto-binning is correctly triggered when usingPlotly.react (for data mutations).

Before/After

See the fixed look in#7506 (comment).

Note onPlotly.react andlayout object

This PR directly fixes the incorrect histogram auto-binning size calculation for single-point traces inoverlay mode on data updates. However, it's worth noting that this issue is often triggered by a deeper behavior withinPlotly.react concerning layout object reuse. See the Note in#7506.

I found that if the samelayout object is reused inPlotly.react calls while the data's axis type (xaxis.type inlayout) changes (e.g., fromlinear tocategory), the layout object can become "stuck" (stale) with the last-used axis type. For instance, after switching from numeric to string data, the axis type becomescategory. When switching back to numeric data, the axis type incorrectly remainscategory, leading to rendering issues.

The long-term solution might involve changes to howPlotly.react handles the layout object. For now, the good practice for users might be:if your data update might change the axis type (i.e., change the layout), you should also provide a new layout object (or a deep copy) toPlotly.react to ensure correct rendering.

The test case added in this PR (histogram_test.js) intentionally uses data of the same type (linear, auto-detected by Plotly) to specifically test theauto-binning fix when data changes, without being affected by the separate layout reuse behavior.

@gvwilsongvwilson added communitycommunity contribution P2considered for next cycle fixfixes something broken labelsAug 11, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@camdecostercamdecosterAwaiting requested review from camdecoster

At least 1 approving review is required to merge this pull request.

Assignees

@camdecostercamdecoster

Labels

communitycommunity contributionfixfixes something brokenP2considered for next cycle

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

bin size becomes 1 (very thin) when data changes withbarmode: 'overlay' for histogram

3 participants

@Lexachoc@camdecoster@gvwilson

[8]ページ先頭

©2009-2025 Movatter.jp