8784: Fix test for latest firefox.
[arvados.git] / apps / workbench / app / assets / javascripts / keep_disks.js.coffee
1 cache_age_in_days = (milliseconds_age) ->
2   ONE_DAY = 1000 * 60 * 60 * 24
3   milliseconds_age / ONE_DAY
4
5 cache_age_hover = (milliseconds_age) ->
6   'Cache age ' + cache_age_in_days(milliseconds_age).toFixed(1) + ' days.'
7
8 cache_age_axis_label = (milliseconds_age) ->
9   cache_age_in_days(milliseconds_age).toFixed(0) + ' days'
10
11 float_as_percentage = (proportion) ->
12   (proportion.toFixed(4) * 100) + '%'
13
14 $.renderHistogram = (histogram_data) ->
15   Morris.Area({
16     element: 'cache-age-vs-disk-histogram',
17     pointSize: 0,
18     lineWidth: 0,
19     data: histogram_data,
20     xkey: 'age',
21     ykeys: ['persisted', 'cache'],
22     labels: ['Persisted Storage Disk Utilization', 'Cached Storage Disk Utilization'],
23     ymax: 1,
24     ymin: 0,
25     xLabelFormat: cache_age_axis_label,
26     yLabelFormat: float_as_percentage,
27     dateFormat: cache_age_hover
28   })