I want to use c3 to show device information with timeseries. Here is my json data.
json: [
{datetime: '2016-01-02 12:00:01.001', wifi: 1},
{datetime: '2016-01-02 12:00:01.999', wifi: 0},
{datetime: '2016-01-02 12:00:03.000', GPS: 0},
{datetime: '2016-01-02 12:00:04.003', wifi: 1},
{datetime: '2016-01-02 12:00:05.959', GPS: 1},
{datetime: '2016-01-02 12:00:06.006', wifi: 0},
],
I find it can't show continuous line for each wifi / gps. Is it a bug or any method can show continuous line?
var chart = c3.generate({
data: {
xFormat: '%Y-%M-%d %H:%M:%S.%L',
json: [
{datetime: '2016-01-02 12:00:01.001', wifi: 1},
{datetime: '2016-01-02 12:00:01.999', wifi: 0},
{datetime: '2016-01-02 12:00:03.000', GPS: 0},
{datetime: '2016-01-02 12:00:04.003', wifi: 1},
{datetime: '2016-01-02 12:00:05.959', GPS: 1},
{datetime: '2016-01-02 12:00:06.006', wifi: 0},
],
keys: {
x: 'datetime',
value: ['wifi','GPS'],
},
types: {
wifi: 'line',
GPS:'line',
},
},
axis: {
x: {
type: 'timeseries',
tick: {
format: '%Y-%m-%d %H:%M:%S'
}
},
},
zoom: {
enabled: true
},
});
I found that it's an old issue and the solution is "connectNull: true".
var chart = c3.generate({
data: {
xFormat: '%Y-%M-%d %H:%M:%S.%L',
json: [
{datetime: '2016-01-02 12:00:01.001', wifi: 1},
{datetime: '2016-01-02 12:00:01.999', wifi: 0},
{datetime: '2016-01-02 12:00:04.003', wifi: 1},
{datetime: '2016-01-02 12:00:06.006', wifi: 0},
{datetime: '2016-01-02 12:00:03.000', GPS: 0},
{datetime: '2016-01-02 12:00:05.959', GPS: 1},
],
keys: {
x: 'datetime',
value: ['wifi','GPS'],
},
types: {
wifi: 'step',
GPS:'step',
},
},
axis: {
x: {
type: 'timeseries',
tick: {
format: '%Y-%m-%d %H:%M:%S'
}
},
},
zoom: {
enabled: true
},
line: {
connectNull: true
}
});