2016-04-26 6 views
0

私はMorris.js折れ線グラフに人間が読める日付を表示しようとしていますが、代わりにタイムスタンプを表示しています。私はhoverCallbackエリアに見えたが、変更内容が不明だしました:Morris.jsの人間の日付値ホバーコールバック

update_host_info.js.erb

new Morris.Line({ 
    element: 'device_security_trend', 
    data: $('#device_security_trend').data('security-trend'), 
    smooth: false, 
    ymax: 'auto[99]', 
    xkey: 'created_at', 
    ykeys: ['security_percentage'], 
    labels: ['Security Percentage'], 
    postUnits: '%', 
    resize: true, 
    hoverCallback: function(index, options, content) { 
    return(content); 
    } 
}); 

device_security_trend要素

<div data-security-trend="[{"created_at":"2016-02-23T13:28:05.160-04:00", "security_percentage" :0},{"created_at":"2016-02-23T16:24:56.128-04:00","security_percentage":99},{"created_at":"2016-02-23T16:24:57.560-04:00","security_percentage":0}" id="device_security_trend" style="width: 100%; position: relative; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);" class="selected"><div class="morris-hover-row-label">2016-02-23T13:28:05.160-04:00</div><div class="morris-hover-point" style="color: #689bc3"> 
 
    Security Percentage: 
 
    0% 
 
</div></div>

右ちょうど変えてしまった

4/19/2016 - 9:30am

+0

'#device_security_trend'要素の内容を表示する必要があります。 – Uzbekjon

+0

あなたは@Uzbekjonに行く – Godzilla74

+0

@Uzbekjonよく、私はちょうど最初の場所で日付形式を変更することについて考えています...だから、私はヘルパーで何をしたのですか。 – Godzilla74

答えて

0

代わりenter image description here

が、私は、日付/時刻が読みやすくするような何かが欲しい:今、これは私のホバーツールチップは、次のようになります時間を人間が読める何かに変換するヘルパーメソッドによって、日付がMorris.jsにどのように供給されていたかを示します。