Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Line Chart with Int as x axis, not Date

Tags:

morris.js

I would like to display a chart which shows integers on the x axis instead of dates.

Here is a fiddle of the example:

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']
});

Does Morris.js only display dates on the x-axis no matter what or can that be changed?

like image 288
Camille Sévigny Avatar asked Apr 02 '15 19:04

Camille Sévigny


1 Answers

Try adding option parameter parseTime:false.

like image 174
Edwin Chen Avatar answered Oct 23 '22 13:10

Edwin Chen