Skip to content

Instantly share code, notes, and snippets.

@eunicekokor
Created January 22, 2024 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eunicekokor/65bed078742e94de491b8c881e542fe6 to your computer and use it in GitHub Desktop.
Save eunicekokor/65bed078742e94de491b8c881e542fe6 to your computer and use it in GitHub Desktop.
Chart JS bars
const config = {
type: 'scatter',
data: data,
options: {
scales: {
y: {
beginAtZero: true
},
x: {
type: 'time',
min: new Date('2019-01-01').valueOf(),
max: new Date('2019-12-31').valueOf()
}
}
}
};
const data = {
labels: [
'December',
'January',
'February',
'March',
'April'
],
datasets: [{
type: 'bar',
label: 'Bar Dataset',
data: [{x: new Date('2024-01-20T04:34:31.742Z'), y: 10}, {x: new Date('2023-01-19T04:34:31.742Z'), y: 40}],
borderColor: 'rgb(255, 99, 132)',
backgroundColor: 'rgba(255, 99, 132, 0.2)'
}, {
type: 'line',
label: 'Line Dataset',
data: [{x: new Date('2024-01-20T04:34:31.742Z'), y: 10}, {x: new Date('2023-01-19T04:34:31.742Z'), y: 40}],
fill: false,
borderColor: 'rgb(54, 162, 235)'
}]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment