Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Area chart hover reversed #534

Open
atimmer opened this issue Dec 6, 2014 · 3 comments
Open

Area chart hover reversed #534

atimmer opened this issue Dec 6, 2014 · 3 comments

Comments

@atimmer
Copy link

atimmer commented Dec 6, 2014

When displaying an area chart using morris the order of the labels in the hover is reversed in comparison to the actual data. So the item provided first in the ykeys and labels is at the top of the hover and at the bottom of the chart, they misalign.

For an example you can look at: http://wpcentral.io/version-usage/

A possible workaround would be using the hoverCallback to reverse the order in the DOM after it has been created. But this doesn't seem like the correct way to get this behaviour.

Is this a bug, or is this intended behaviour?

@JelteF
Copy link
Contributor

JelteF commented Dec 6, 2014

This is probably a bug, you can fix it with a pull request if you want.
On Dec 6, 2014 4:57 PM, "Anton Timmermans" [email protected] wrote:

When displaying an area chart using morris the order of the labels in the
hover is reversed in comparison to the actual data. So the item provided
first in the ykeys and labels is at the top of the hover and at the
bottom of the chart, they misalign.

For an example you can look at: http://wpcentral.io/version-usage/

A possible workaround would be using the hoverCallback to reverse the
order in the DOM after it has been created. But this doesn't seem like the
correct way to get this behaviour.

Is this a bug, or is this intended behaviour?


Reply to this email directly or view it on GitHub
#534.

@pierresh
Copy link

pierresh commented Jun 13, 2016

I solved this issue by modifying the file morris.js as follow (starting from line 942):

Line.prototype.hoverContentForRow = function(index) {
  var content, j, jj, row, 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) {
  for (jj = _i = 0, _len = _ref.length; _i < _len; jj = ++_i) {
    j = _len - 1 - jj;

And for stacked bar charts (starting from line 1798):

Bar.prototype.hoverContentForRow = function(index) {
  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 (jj = _i = 0, _len = _ref.length; _i < _len; jj = ++_i) {
    j = _len - 1 - jj;

pierresh pushed a commit to pierresh/morris.js that referenced this issue Dec 29, 2017
pierresh pushed a commit to pierresh/morris.js that referenced this issue Dec 29, 2017
@Demitrius
Copy link

Stacked bar looks good, but Line charts hover label order broken :(

Also, possible manually set lines "z order"? When two lines on the same position, one line color will above, second line will under.
Now this order depend on sequence colors/data in options, but I need choose my custom sequence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants