线图以Int作为x轴,而不是日期

时间:2015-04-02 19:13:46

标签: morris.js

我想显示一个图表,它显示x轴上的整数而不是日期。

这是一个例子的小提琴:

http://jsfiddle.net/cs3vigny/srmqcfjh/

new Morris.Line({
    element: 'film-compare-chart',
    data: [
        { week: 0, a: 2, b: 4, c: 5, d: 3, e: 3 },
        { week: 1, a: 2, b: 3, c: 6, d: 3, e: 3 },
        { week: 2, a: 3, b: 5, c: 4, d: 2, e: 2 },
        { week: 3, a: 3, b: 6, c: 6, d: 3, e: 4 },
        { week: 4, a: 4, b: 4, c: 5, d: 4, e: 2 },
        { week: 5, a: 4, b: 6, c: 6, d: 3, e: 2 },
        { week: 6, a: 4, b: 7, c: 8, d: 5, e: 2 },
        { week: 7, a: 3, b: 5, c: 6, d: 5, e: 4 },
        { week: 8, a: 4, b: 8, c: 6, d: 4, e: 3 },
        { week: 9, a: 6, b: 10, c: 8, d: 7, e: 5 },
        { week: 10, a: 5, b: 12, c: 13, d: 7, e: 4 },
        { week: 11, a: 6, b: 10, c: 10, d: 7, e: 4 },
        { week: 12, a: 9, b: 10, c: 10, d: 10, e: 6 },
        { week: 13, a: 11, b: 15, c: 16, d: 12, e: 9 },
        { week: 14, a: 14, b: 15, c: 14, d: 13, e: 10 },
        { week: 15, a: 14, b: 20, c: 17, d: 15, e: 11 },
        { week: 16, a: 18, b: 26, c: 22, d: 16, e: 15 },
        { week: 17, a: 19, b: 22, c: 22, d: 18, e: 13 },
        { week: 18, a: 19, b: 21, c: 25, d: 20, e: 16 },
        { week: 19, a: 26, b: 26, c: 33, d: 24, e: 21 },
        { week: 20, a: 26, b: 26, c: 31, d: 24, e: 21 },
        { week: 21, a: 24, b: 28, c: 41, d: 26, e: 22 },
        { week: 22, a: 33, b: 32, c: 40, d: 29, e: 28 },
        { week: 23, a: 34, b: 37, c: 51, d: 34, e: 32 }
    ],
    xkey: 'week',
    ykeys: ['a','b','c','d','e'],
    labels: ['Cinderella (2015)', 'Maleficent', 'Oz: The Great and Powerful', 'Divergent', 'Big Hero 6']
});

Morris.js是否只在x轴上显示日期,无论是什么或可以改变?

2 个答案:

答案 0 :(得分:20)

尝试添加选项参数parseTime:false

答案 1 :(得分:4)

在Morrischart中,如果'parseTime'设置为false,那么它会跳过解析X值的时间/日期,否则将它们视为等间距系列;默认值为parseTime:true ..这就是为什么你会感到困惑。那么请你插入以下代码行

  

分析时:假

示例代码如下,

new Morris.Area({
             ------
             parseTime:false,
             ------
});

希望它的工作正常: - )