user502052 user502052 - 6 months ago 63
Javascript Question

How to customize the legend of a Morris graph?

I am using the morris.js library and I would like to customize my graphs so to properly format the date-time present in their legend. At this time, when I pass values as-like

2013-07-26T03:34:41+02:00
(ISO8601) to the
ykey
then the generated legend content is the following:

The morris legend

I would like to generate the content of legend so to display the
2013-07-26T03:34:41+02:00
in a user-friendly way, maybe something like
03:34:41 (2013-07-26)
or
just now
/
19 seconds ago
.

Is it possible? If so, how can I make that?

Answer

Use below function and change the body according to your need.

   hoverCallback: function (index, options, content) {
   var row = options.data[index];
   //here row has x and y values
   }
Comments