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
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletionsdraftlogs/7507_fix.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
Fix `histogram` autobin size for single-point traces in `overlay` mode on data updates via `Plotly.react` [[#7507](https://github.com/plotly/plotly.js/pull/7507)]
5 changes: 3 additions & 2 deletionssrc/traces/histogram/calc.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -308,10 +308,11 @@ function calcAllAutoBins(gd, trace, pa, mainData, _overlayEdgeCase) {

// Edge case: single-valued histogram overlaying others
// Use them all together to calculate the bin size for the single-valued one
// Don't re-calculate bin width if user manually specified it (checing in bingroup=='' or xbins is defined)
// Don't re-calculate bin width if user manually specified it
// Check if bingroup or bin size is defined
if(isOverlay && !Registry.traceIs(trace, '2dMap') && newBinSpec._dataSpan === 0 &&
pa.type !== 'category' && pa.type !== 'multicategory' &&
trace.bingroup === '' &&(typeoftrace.xbins ==='undefined')) {
trace.bingroup === '' && trace._input?.[binAttr]?.size === undefined) {
// Several single-valued histograms! Stop infinite recursion,
// just return an extra flag that tells handleSingleValueOverlays
// to sort out this trace too
Expand Down
37 changes: 37 additions & 0 deletionstest/jasmine/tests/histogram_test.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1335,6 +1335,43 @@ describe('Test histogram', function() {
})
.then(done, done.fail);
});

it('should correctly recalculate autobin size for single-value overlays on Plotly.react', function(done) {
var initialData = [
{x: ['1457'], type: 'histogram'},
{x: ['820'], type: 'histogram'},
{x: ['720'], type: 'histogram'}
];

var layout = {
barmode: 'overlay'
};

Plotly.newPlot(gd, initialData, layout)
.then(function() {
// minDiff = 820 - 720 = 100
console.log("gd._fullData=", gd._fullData);
expect(gd._fullData[0].xbins.size).toBe(100);
expect(gd._fullData[1].xbins.size).toBe(100);
expect(gd._fullData[2].xbins.size).toBe(100);

// Use a new trace data object
var newData = [
{x: ['1400'], type: 'histogram'},
{x: ['800'], type: 'histogram'},
{x: ['600'], type: 'histogram'}
];

return Plotly.react(gd, newData, layout);
})
.then(function() {
// minDiff = 800 - 600 = 200.
expect(gd._fullData[0].xbins.size).toBe(200);
expect(gd._fullData[1].xbins.size).toBe(200);
expect(gd._fullData[2].xbins.size).toBe(200);
})
.then(done, done.fail);
});
});
});

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp