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

1

8

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

Sloppy answered 24/12, 2013 at 15:50 Comment(0)
B
12

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

Berrios answered 24/12, 2013 at 16:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.