Skip to content

Commit

Permalink
Order colors in hover according to stacked bar
Browse files Browse the repository at this point in the history
See original bug here morrisjs#534
  • Loading branch information
Pierre Clavequin committed Dec 29, 2017
1 parent 6013f41 commit 59ee270
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
5 changes: 3 additions & 2 deletions lib/morris.bar.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class Morris.Bar extends Morris.Grid
Math.min(@data.length - 1,
Math.floor((pos - @xStart) / (@xSize / @data.length)))
#/
# click on grid event handler
#
# @private
Expand Down Expand Up @@ -286,7 +286,8 @@ class Morris.Bar extends Morris.Grid
row = @data[index]
content = $("<div class='morris-hover-row-label'>").text(row.label)
content = content.prop('outerHTML')
for y, j in row.y
for y, jj in row.y
j = row.y.length - 1 - jj
if @options.labels[j] is false
continue

Expand Down
7 changes: 4 additions & 3 deletions morris.js
Original file line number Diff line number Diff line change
Expand Up @@ -1990,13 +1990,14 @@ Licensed under the BSD-2-Clause License.
};

Bar.prototype.hoverContentForRow = function(index) {
var content, j, row, x, y, _i, _len, _ref;
var content, j, jj, row, x, y, _i, _len, _ref;
row = this.data[index];
content = $("<div class='morris-hover-row-label'>").text(row.label);
content = content.prop('outerHTML');
_ref = row.y;
for (j = _i = 0, _len = _ref.length; _i < _len; j = ++_i) {
y = _ref[j];
for (jj = _i = 0, _len = _ref.length; _i < _len; jj = ++_i) {
y = _ref[jj];
j = row.y.length - 1 - jj;
if (this.options.labels[j] === false) {
continue;
}
Expand Down
Loading

0 comments on commit 59ee270

Please sign in to comment.