0

There is a similar question mentioned here, however, it doesn't solve my problem. A trivial c3 script fails to load data when using .toString() method on var dates = ["2015-03-07", "2015-03-09"]

data: {
    x: 'x',
    xFormat: '%Y-%m-%d', // 'xFormat' can be used as custom format of 'x'
    columns: [
        ['x', dates.toString()],
        ['data1', 30, 200, 100, 400, 150, 250],
        ['data2', 130, 340, 200, 500, 250, 350]
    ]
},
axis: {
    x: {
        type: 'timeseries',
        tick: {
            format: '%Y-%m-%d'
        }
    }
}

Am I missing something here? The error is as follows

Failed to parse x '2015-03-07,2015-03-09' to Date object
Community
  • 1
  • 1
sitilge
  • 3,687
  • 4
  • 30
  • 56

1 Answers1

1

.toString turns the array into one string, use this in the columns property instead

['x'].concat(dates),
sitilge
  • 3,687
  • 4
  • 30
  • 56
mgraham
  • 6,147
  • 1
  • 21
  • 20