javascript - (C3 js) 加载 CSV 文件并使用时间序列
问题描述
我正在尝试加载本地 csv 文件并使用时间序列。我有很多数据,所以我从 csv (url: '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({
});
});
解决方案
推荐阅读
- ios - IOS Sign In with apple using swift crash on iPad only on apple review
- android - 如何解决包含模块 Gradle 6.x?
- reactjs - redux 状态更新时如何更新本地状态(react-redux)
- html - 我正在努力在 CSS 中制作线性动画
- ruby-on-rails - 运行 rake db 时出现未知的 Ruby 错误:创建我在运行最新版本操作系统的树莓派上
- c# - Try Catch 中的返回值与泛型
- python-3.x - 将现有 Python3 方法转换为使用多处理
- security - 谷歌将我的密码保存到我使用 gmail 注册的其他网站是否正常?
- group-by - ABAP 字符串模板 - 带有 GROUP BY 的嵌入式表达式
- axon - 轴突事件处理超时