morris.js在x轴上有几个小时的问题 [英] morris.js probelm with hours on x-axis

查看:833
本文介绍了morris.js在x轴上有几个小时的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建类似Google Analytics(分析)的观众概览图表。我正在尝试将小时从午夜12:00到上午11点在x轴上

I am trying to create something like the google analytics Audience Overview graph. I am trying to put Hours starting from 12:00am midnight to 11:00pm on the x-axis

这是我目前使用的:

Morris.Line({

    element: 'chart_div_compare',

    data: [            
        { hours: '00:00', a: 793, b: 729},
        { hours: '01:00', a: 524, b: 537},
        { hours: '02:00', a: 337, b: 347},
        { hours: '03:00', a: 272, b: 213},
        { hours: '04:00', a: 176, b: 169},
        { hours: '05:00', a: 174, b: 147},
        { hours: '06:00', a: 212, b: 193},
        { hours: '07:00', a: 341, b: 294},
        { hours: '08:00', a: 551, b: 501},
        { hours: '09:00', a: 724, b: 692},
        { hours: '10:00', a: 880, b: 896},
        { hours: '11:00', a: 955, b: 1004},
        { hours: '12:00', a: 1053, b: 1142},
        { hours: '13:00', a: 1063, b: 1150},
        { hours: '14:00', a: 92, b: 1123},
        { hours: '15:00', a: 0, b: 1151},
        { hours: '16:00', a: 0, b: 1222},
        { hours: '17:00', a: 0, b: 1155},
        { hours: '18:00', a: 0, b: 1246},
        { hours: '19:00', a: 0, b: 1100},
        { hours: '20:00', a: 0, b: 1199},
        { hours: '21:00', a: 0, b: 1395},
        { hours: '22:00', a: 0, b: 1361},
        { hours: '23:00', a: 0, b: 1005},
    ],
    // The name of the data record attribute that contains x-values.
    xkey: 'hours',
    hideHover: 'auto',
    // A list of names of data record attributes that contain y-values.
    ykeys: ['a', 'b'],
    // Labels for the ykeys -- will be displayed when you hover over the
    // chart.
    labels: ['2014-04-16', '2014-04-14']
});

x轴变为1900年,1910年,1920年。
我的格式错误小时列?
我不明白如何得到这个图形,但最终我想要
12:00 AM,1:00 AM等等

The x-axis becomes 1900, 1910, 1920. Is my format wrong for the hours column? I cant figure how to get this to graph right but ultimately i would like 12:00 AM, 1:00 AM, etc

任何

推荐答案

我刚刚遇到同样的问题,也许您可​​以使用以下选项:

I just went into the same problem, maybe you can use the following option:

parseTime: false

或者你可以自定义xlabel的格式化方法。有关详细信息,请访问本网站 morris on github

Or you can customize the format method for xlabel. For further information, you can check this website and morris on github.

这篇关于morris.js在x轴上有几个小时的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆