C3 그래프
[C3]자료를 초까지 나타내는 법
kyeongjun-dev
2020. 3. 8. 20:09
https://c3js.org/examples.html
C3.js | D3-based reusable chart library
Number Format Localization Number format localization using D3 locale settings. View details »
c3js.org
위의 사이트에서 간단하게 여러 그래프를 그릴 수있는데,
X축을 시간으로 하는데, 예시와는 다르게 해야한다.
xFormat을 추가해준다.
var chart = c3.generate({
data: {
x: 'x',
xFormat: '%Y-%m-%d %H:%M:%S',
// xFormat: '%Y%m%d', // 'xFormat' can be used as custom format of 'x'
columns: [
['x', '2017-01-01 12:13:20'],
// ['x', '20130101', '20130102', '20130103', '20130104', '20130105', '20140106'],
['data1', 3],
],
type: 'bar'
},
bar: {
width: {
ratio: 1.0
}
},
axis: {
x: {
type: 'timeseries',
tick: {
format: '%Y-%m-%d %H:%M:%S'
}
}
}
});
위와같이 입력해주면,
년, 월, 일, 시간, 분, 초까지 나타낼 수 있다.