Skip to content

Commit

Permalink
Support to sort series in legend naturally. (alphabetical reverted)
Browse files Browse the repository at this point in the history
  • Loading branch information
michelezanda committed Jun 4, 2020
1 parent 4a56f5c commit a779205
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 14 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG_ION.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# plotly.js ION changelog

## [1.33.1-ion39] -- 2020-06-04

### Support to sort series in legend naturally. (alphabetical reverted)


## [1.33.1-ion38] -- 2020-06-03

### Support to sort series in legend alphabetically.
Expand Down
12 changes: 6 additions & 6 deletions dist_ion/plotly-ion.js
Original file line number Diff line number Diff line change
Expand Up @@ -24748,7 +24748,7 @@ module.exports = {
},
traceorder: {
valType: 'flaglist',
flags: ['reversed', 'grouped', 'alphabetical'],
flags: ['reversed', 'grouped', 'natural', 'normal'],
extras: ['normal'],

editType: 'legend',
Expand Down Expand Up @@ -25772,13 +25772,13 @@ module.exports = function getLegendData(calcdata, opts) {
// needed in repositionLegend
opts._lgroupsLength = lgroupsLength;

if (opts.traceorder === "alphabetical") {
if (opts.traceorder === "natural") {
legendData[0].sort((a, b) => {
if (a[0] && a[0].label) {
return a[0].label.localeCompare(b[0].label);
return a[0].label.localeCompare(b[0].label, undefined, {numeric: true});
} else {
if (a[0] && a[0].trace && a[0].trace.name) {
return a[0].trace.name.localeCompare(b[0].trace.name);
return a[0].trace.name.localeCompare(b[0].trace.name, undefined, {numeric: true});
}
}
});
Expand Down Expand Up @@ -32823,7 +32823,7 @@ exports.svgAttrs = {
var Plotly = require('./plotly');

// package version injected by `npm run preprocess`
exports.version = '1.33.1-ion38';
exports.version = '1.33.1-ion39';

// inject promise polyfill
require('es6-promise').polyfill();
Expand Down Expand Up @@ -54825,7 +54825,7 @@ module.exports = overrideAll({
valType: 'color',

dflt: constants.waterColor,

description: 'Sets color of the rivers.'
},
riverwidth: {
valType: 'number',
Expand Down
2 changes: 1 addition & 1 deletion dist_ion/plotly-ion.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "plotly.js",
"version": "1.33.1-ion38",
"version": "1.33.1-ion39",
"description": "The open source javascript graphing library that powers plotly",
"license": "MIT",
"main": "./lib/index.js",
Expand Down
2 changes: 1 addition & 1 deletion src/assets/geo_assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ var saneTopojson = require('sane-topojson');


// package version injected by `npm run preprocess`
exports.version = '1.33.1-ion38';exports.topojson = saneTopojson;
exports.version = '1.33.1-ion39';exports.topojson = saneTopojson;
2 changes: 1 addition & 1 deletion src/components/legend/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module.exports = {
},
traceorder: {
valType: 'flaglist',
flags: ['reversed', 'grouped', 'alphabetical'],
flags: ['reversed', 'grouped', 'natural', 'normal'],
extras: ['normal'],
role: 'style',
editType: 'legend',
Expand Down
6 changes: 3 additions & 3 deletions src/components/legend/get_legend_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ module.exports = function getLegendData(calcdata, opts) {
// needed in repositionLegend
opts._lgroupsLength = lgroupsLength;

if (opts.traceorder === "alphabetical") {
if (opts.traceorder === "natural") {
legendData[0].sort((a, b) => {
if (a[0] && a[0].label) {
return a[0].label.localeCompare(b[0].label);
return a[0].label.localeCompare(b[0].label, undefined, {numeric: true});
} else {
if (a[0] && a[0].trace && a[0].trace.name) {
return a[0].trace.name.localeCompare(b[0].trace.name);
return a[0].trace.name.localeCompare(b[0].trace.name, undefined, {numeric: true});
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
var Plotly = require('./plotly');

// package version injected by `npm run preprocess`
exports.version = '1.33.1-ion38';
exports.version = '1.33.1-ion39';

// inject promise polyfill
require('es6-promise').polyfill();
Expand Down

0 comments on commit a779205

Please sign in to comment.