【问题标题】:c3 failed to parse when using .toString()c3 使用 .toString() 时解析失败
【发布时间】:2016-10-07 16:32:32
【问题描述】:

here 提到了一个类似的问题,但是,它并没有解决我的问题。在var dates = ["2015-03-07", "2015-03-09"] 上使用.toString() 方法时,一个简单的c3 脚本无法加载数据

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'
        }
    }
}

我在这里遗漏了什么吗?错误如下

Failed to parse x '2015-03-07,2015-03-09' to Date object

【问题讨论】:

    标签: javascript jquery d3.js c3.js


    【解决方案1】:

    .toString 将数组变成一个字符串,在 columns 属性中使用它

    ['x'].concat(dates),
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-19
      • 1970-01-01
      • 2021-06-09
      相关资源
      最近更新 更多