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

Line Chart with Int as x axis, not Date

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

下面是一个fiddle的例子:

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 轴上显示日期,不管怎样还是可以更改?

尝试添加选项参数 parseTime:false

在 Morrischart 中,如果 'parseTime' 设置为 false 则跳过 time/date 解析 X 值,否则将它们视为等距系列;默认值为 parseTime:true ..这就是你感到困惑的原因..那么你能不能插入下面的代码行

parseTime:false

示例代码如下,

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

希望一切顺利:-)