0

Original C3.js example:

https://c3js.org/samples/chart_stanford.html

I am getting the following console log error in my C3.js Stanford Chart:

c3.js:2349 Failed to parse x '2019-09-10 08:15:51' to Date object

in all of my JSON values.

I know this has something to do with xFormat, which I have added in the keys: area of Data:, but I am still receiving the same error.

var data = [
  {
    "Time": "2019-09-10 08:15:51",
    "Range Gate": 26,
    "Velocity": 44
  },
  {
    "Time": "2019-09-10 08:16:51",
    "Range Gate": 46,
    "Velocity": 47
  },
  {
    "Time": "2019-09-10 08:17:51",
    "Range Gate": 55,
    "Velocity": 50
  },
  {
    "Time": "2019-09-10 08:18:51",
    "Range Gate": 1,
    "Velocity": 54
  },
  {
    "Time": "2019-09-10 08:19:51",
    "Range Gate": 11,
    "Velocity": 54
  }
];

Same occurs with this dataset:

var data = [
  {
    "Time": "08:15:51",
    "Range Gate": 26,
    "Velocity": 44
  },
  {
    "Time": "08:16:51",
    "Range Gate": 46,
    "Velocity": 47
  },
  {
    "Time": "08:17:51",
    "Range Gate": 55,
    "Velocity": 50
  },
  {
    "Time": "08:18:51",
    "Range Gate": 1,
    "Velocity": 54
  },
  {
    "Time": "08:19:51",
    "Range Gate": 11,
    "Velocity": 54
  }
];

  var chart = c3.generate({
    size: {
      height: 600,
      width: 800 * 1.12
    },
    data: {
      json: data,
      mimeType: 'json',
      epochs: 'Velocity',
      keys: {
        x: 'Time',
        xFormat: '%H:%M:%S',
        value: ['Range Gate', 'Velocity']
      },
      type: 'stanford'
    },
    legend: {
      hide: true
    },
    point: {
      focus: {
        expand: {
          r: 5
        }
      },
      r: 2.5
    },
    axis: {
      x: {
        type: 'timeseries',
        tick: {
          format: '%H:%M:%S'
        },
        show: true,
        label: {
          text: 'Time',
          position: 'outer-center'
        },
        min: 0,
        max: 61,
        padding: {
          top: 0,
          bottom: 0,
          left: 0,
          right: 0
        },
      },
      y: {
        show: true,
        label: {
          text: 'Range Gate',
          position: 'outer-middle'
        },
        min: 0,
        max: 60,
        tick: {
          values: d3.range(0, 65, 10)
        },
        padding: {
          top: 5,
          bottom: 0,
          left: 0,
          right: 0
        },
      }
    },
    stanford: {
      scaleMin: 1,
      scaleMax: 10000,
      scaleFormat: 'pow10',
      padding: {
        top: 15,
        right: 0,
        bottom: 0,
        left: 0
      }
    }
  });

c3.js:2349 Failed to parse x '2019-09-10 08:15:51' to Date object

c3.js:2349 Failed to parse x '2019-09-10 08:16:51' to Date object

etc.

mcook16
  • 67
  • 5
  • Possible duplicate of [C3.js - Timeseries with time fails to parse](https://stackoverflow.com/questions/32642089/c3-js-timeseries-with-time-fails-to-parse) – Peter B Sep 10 '19 at 18:26
  • Your values contain full date+time, but you don't have parsing placeholders for the y-m-d elements. – Peter B Sep 10 '19 at 18:29
  • Hi Peter, I've tried using just h-m-s dataset as well with the same result. – mcook16 Sep 10 '19 at 18:31

1 Answers1

0

I have the same problem with a simple data (like examples) as '26-12-2018' with xFormat: '%Y-%m-%d'

Work only if I adding also the hours and use slash, like '26/12/2018 00:00:00' and with corrispondent xFormat: '%Y/%m/%d %H:%M:%S'

Angelo Vit
  • 83
  • 8