tstor/torrent/assets/js/single_bar_chart.js
Antonio Navarro Perez ecd524ed3c First functional web interface version.
- Simplify by now all html and javascript.
- Added a simple interface using go templates and plain javascript.
- Improved REST interface for the use case.
- Changed some properties into the config file to make it suitable for
future use cases.

Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
2020-05-18 19:42:23 +02:00

48 lines
No EOL
1.2 KiB
JavaScript

function SingleBarChart(id, name) {
var ctx = document.getElementById(id).getContext('2d');
this._used = [];
this._free = [];
this._chart = new Chart(ctx, {
type: 'bar',
data: {
labels:[name],
datasets: [{
backgroundColor: "gray",
label: "used",
data: this._used,
},
{
backgroundColor: "green",
label: "free",
data: this._free,
}],
},
options: {
legend: {
display: false,
},
animation: false,
scales: {
xAxes: [{
stacked: true
}],
yAxes: [{
stacked: true,
display: true,
ticks: {
beginAtZero: true,
}
}]
}
},
});
this.update = function (used, free) {
this._used.shift();
this._free.shift();
this._used.push(used);
this._free.push(free);
this._chart.update();
};
}