Skip to content

Commit

Permalink
add legend.inverseOrder - fixes #850, fixes #858
Browse files Browse the repository at this point in the history
  • Loading branch information
junedchhipa committed Aug 21, 2019
1 parent 7d308de commit 0c4bec7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/modules/Legend.js
Expand Up @@ -97,7 +97,13 @@ class Legend {
}
let legendFormatter = w.globals.legendFormatter

for (let i = 0; i <= legendNames.length - 1; i++) {
let isLegendInversed = w.config.legend.inverseOrder

for (
let i = isLegendInversed ? legendNames.length - 1 : 0;
isLegendInversed ? i >= 0 : i <= legendNames.length - 1;
isLegendInversed ? i-- : i++
) {
let text = legendFormatter(legendNames[i], { seriesIndex: i, w })

let collapsedSeries = false
Expand Down
1 change: 1 addition & 0 deletions src/modules/settings/Options.js
Expand Up @@ -588,6 +588,7 @@ export default class Options {
position: 'bottom', // whether to position legends in 1 of 4
// direction - top, bottom, left, right
horizontalAlign: 'center', // when position top/bottom, you can specify whether to align legends left, right or center
inverseOrder: false,
fontSize: '12px',
fontFamily: undefined,
width: undefined,
Expand Down

0 comments on commit 0c4bec7

Please sign in to comment.