We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 7a7b412 + 00d46f6 commit 630b092Copy full SHA for 630b092
3 files changed
draftlogs/6718_fix.md
@@ -0,0 +1 @@
1
+- Column order changes on hover [[#6718](https://github.com/plotly/plotly.js/pull/6718)]
src/plots/plots.js
@@ -3207,6 +3207,14 @@ function sortAxisCategoriesByValue(axList, gd) {
3207
median: function(values) {return Lib.median(values);}
3208
};
3209
3210
+ function sortAscending(a, b) {
3211
+ return a[1] - b[1];
3212
+ }
3213
+
3214
+ function sortDescending(a, b) {
3215
+ return b[1] - a[1];
3216
3217
3218
for(i = 0; i < axList.length; i++) {
3219
var ax = axList[i];
3220
if(ax.type !== 'category') continue;
@@ -3328,9 +3336,7 @@ function sortAxisCategoriesByValue(axList, gd) {
3328
3336
}
3329
3337
3330
3338
// Sort by aggregated value
3331
- categoriesAggregatedValue.sort(function(a, b) {
3332
- return a[1] - b[1];
3333
- });
3339
+ categoriesAggregatedValue.sort(order === 'descending' ? sortDescending : sortAscending);
3334
3340
3335
3341
ax._categoriesAggregatedValue = categoriesAggregatedValue;
3342
@@ -3339,11 +3345,6 @@ function sortAxisCategoriesByValue(axList, gd) {
3345
return c[0];
3346
});
3347
- // Reverse if descending
3343
- if(order === 'descending') {
3344
- ax._initialCategories.reverse();
- }
-
3348
// Sort all matching axes
3349
affectedTraces = affectedTraces.concat(ax.sortByInitialCategories());
3350
test/jasmine/tests/calcdata_test.js
@@ -1074,8 +1074,14 @@ describe('calculated data and points', function() {
1074
if(categoryorder === 'total descending') finalOrder.reverse();
1075
var expectedAgg = [['a', 7], ['b', 2], ['c', 3]];
1076
1077
- if(trace.type === 'ohlc' || trace.type === 'candlestick') expectedAgg = [['a', 14], ['b', 4], ['c', 6]];
1078
- if(trace.type.match(/histogram/)) expectedAgg = [['a', 2], ['b', 1], ['c', 1]];
+ if(trace.type === 'ohlc' || trace.type === 'candlestick') {
+ expectedAgg = [['a', 14], ['b', 4], ['c', 6]];
1079
+ if(categoryorder === 'total descending') finalOrder = ['a', 'c', 'b'];
1080
1081
+ if(trace.type.match(/histogram/)) {
1082
+ expectedAgg = [['a', 2], ['b', 1], ['c', 1]];
1083
+ if(categoryorder === 'total descending') finalOrder = ['a', 'b', 'c'];
1084
1085
1086
checkAggregatedValue(baseMock, expectedAgg, finalOrder, done);
1087
0 commit comments