Back to amCharts.com

Display values as durations

Let's say your data represents some duration. In this case, instead of showing simple numbers on the Y axis and in the balloons (also legend of line chart) you might want to have a formatted duration which would be easier to understand. For example, instead of "190 s" (190 seconds) you can have "03:10" or "03m 10s".

To enable this feature, you should simply specify the unit of your durations of your data. If your data represents seconds, the unit will be "ss", minutes - "mm", hours - "hh", days - "DD".

The unit of the duration is set a bit differently for the different charts.

Line & area:

<values>
  <y_left>
    <duration>ss</duration>

(you can use y_right instead of y_left, depends on the axis you use).

Column & Bar

<values>
  <value>
    <duration>ss</duration>

Scatter & Bubble axis can also be formatted as date, so first, you have to set the type of the axis (it can be both x and y):

<values>
  <y>
    <type>duration</type>

Then you should set the duration unit at:

<date_formats>
  <duration_input>ss</duration_input>
</date_formats>

That might be enough if you are happy with the default formatting of the duration. If you want to change it, you should simply adjust values in the following settings:

<strings>
  <ss></ss>
  <mm></mm>
  <hh></hh>
  <DD></DD>    
</strings>
Back to top