Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can't use strings instead of integers in area charts in morris charts library

Bar Chart Example

Morris.Bar({
  element: 'bar-example',
  data: [
    { y: 'dddd', a: 100, b: 90 },
    { y: '2007', a: 75,  b: 65 },
    { y: '2008', a: 50,  b: 40 },
    { y: '2009', a: 75,  b: 65 },
    { y: '2010', a: 50,  b: 40 },
    { y: '2011', a: 75,  b: 65 },
    { y: '2012', a: 100, b: 90 }
  ],
  xkey: 'y',
  ykeys: ['a', 'b'],
  labels: ['Series A', 'Series B']
});

Area Chart Example

Morris.Area({
  element: 'area-example',
  data: [
    { y: 'dddd', a: 100, b: 90 },
    { y: '2007', a: 75,  b: 65 },
    { y: '2008', a: 50,  b: 40 },
    { y: '2009', a: 75,  b: 65 },
    { y: '2010', a: 50,  b: 40 },
    { y: '2011', a: 75,  b: 65 },
    { y: '2012', a: 100, b: 90 }
  ],
  xkey: 'y',
  ykeys: ['a', 'b'],
  labels: ['Series A', 'Series B']
});

In Morris Chart library Bar charts accepts strings for Y-AXIS but Area one doesn't.I can't understand why ?

THIS IS THE MORRIS LIBRARY

like image 947
underscore Avatar asked Dec 24 '13 15:12

underscore


1 Answers

Morris.js is trying to parse x-values as timestamp. But 'dddd' has invalid format. You can skip date parsing by using parseTime: false option (jsbin). In this case X values will be treated as an equally-spaced series. See docs

like image 67
Eugene Avatar answered Nov 07 '22 13:11

Eugene