-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
xFormat cannot parse unixtime #805
Comments
i fixed it myself.
|
I just tried doing this without modifying C3 and couldn't manage to get it to parse unixtime. It doesn't help D3's time formatting doesn't provide such an option. Considering a very possible use case for C3 is building charts from server logfiles, having some ability to parse unixtime would be helpful. I see one of two options:
@masayuki0812 Any thoughts? |
Thanks for your reporting. This is because the date values are string when loading from |
v0.4.8 has been released, so please let me close. |
Is this documented somewhere in the reference? I am unable to get json data working with unix time. I'm using chart.load:
and:
|
@keyscores Here's a fiddle showing it in use. Key things:
|
Thanks Andrew its very clear now. Can I suggest adding this to the official
docs?
Lucas Geiger
|
@keyscores Most definitely, definitely took me a minute to figure it out. Please comment on the above issue if you find documentation lacking anywhere else! Thanks! |
the fiddle errors. Is there an updated example? I have javascript formatted times (with ms) I also have multiple axes, here is my code: let model = this.get('model');
let incomes = model.get('incomes');
// these start out as unixtimes
let registrationTimes = model.get('registrationTimes');
let incomeTimes = model.get('incomeTimes');
let registrations = model.get('registrations');
let regTimes = [];
let incTimes = [];
registrationTimes.forEach(function (e) {
regTimes.push(new Date(e * 1000));
});
incomeTimes.forEach(function (e) {
incTimes.push(new Date(e * 1000));
});
let data = {
xs: {
Registrations: 'x1',
Income: 'x2',
},
columns: [
['x1'].concat(regTimes), ['x2'].concat(incTimes), [
'Registrations',
].concat(registrations), ['Income'].concat(incomes),
],
axes: {
Registrations: 'y',
Income: 'y2',
},
};
let config = {
bindto: 'income-registrations-chart',
size: {
height: 700,
},
zoom: {
enabled: true,
rescale: true,
},
grid: {
x: {
show: true,
},
},
axis: {
y: {
label: 'Total Number of Registrants',
},
y2: {
show: true,
label: 'Revenue',
tick: {
format: d3.format('$,'),
},
},
x: {
type: 'timeseries',
tick: {
culling: {
max: 100,
},
count: 20,
fit: true,
rotate: 45,
format: '%Y-%m-%d %H:%M:%S',
// format: function (x) { return new Date(x).toString(); },
},
},
},
};
this.set('config', config);
this.set('data', data); and then using {{c3-chart data=data config=config}} I'm using: c3: 0.4.11 |
got it working: http://jsfiddle.net/DerNalia/kfz2eb60/ |
=====my html
var chart = c3.generate({
data: {
x: 'date',
url: 'test.csv'
},
axis: {
x : {
type : 'timeseries',
tick : {
format : "%m-%d %H:%M"
}
}
},
zoom: {
enabled: true
}
});
========test.csv
date, eth0-rx, eth0-tx, eth1-rx, eth1-tx
1417622461000, 37, 2, 68, 33
1417622522000, 39, 2, 57, 23
1417622581000, 41, 3, 61, 23
The text was updated successfully, but these errors were encountered: