我正在尝试加载本地csv文件,并且还使用时间序列。我有很多数据,所以我要从csv(网址:“ data_testing.csv”)获取数据,但我也想使用间隔为12小时的时间序列,总间隔为5天。我尝试了很多事情,但是没有运气。似乎我要么必须使用同一脚本中的数据(而不是加载csv)才能使用时间序列。我可以加载CSV,但是一旦添加了时间序列,它便不再起作用。我还可以使用时间序列,但是仅当数据来自列而不是文件加载时。我需要同时处理时间序列和CSV文件中的数据。
C3版本:0.6.8- D3版本:5.7.0- 浏览器:Chrome- 操作系统:Mac OSX
var chart = c3.generate({
bindto: '#chart',
data: {
// this only works if I don't use time series
url: '../data_testing.csv',
x: 'x',
// this only works if I'm writing the data and not using local csv file
xFormat: '%Y-%m-%d',
columns: [
['x', '2016-8-10', '2016-8-10', '2016-8-10', '2016-8-10', '2016-8-10', '2016-8-10']
],
type: 'line'
},
axis: {
x: {
type: 'timeseries',
localtime: false,
tick: {
culling: true,
fit: true,
culling: {
max: window.innerWidth > 700 ? 8 : 5
},
format: '%Y-%m-%d' // %H:%M:%S
}
},
y: {
max: 55,
min: 6
}
}
});
require(["d3", "c3"], function (d3, c3) {
c3.generate({
});
});