Files
fnx_web/res/include/script/dependencies/drawGraph.js

66 lines
1.5 KiB
JavaScript
Raw Normal View History

2020-08-11 19:52:03 +02:00
Chart.defaults.global.defaultFontColor = "#b3b3b3";
Chart.defaults.global.defaultFontSize = 15;
Chart.defaults.global.defaultFontFamily = "system-ui, sans-serif";
Chart.defaults.global.maintainAspectRatio = false;
Chart.defaults.global.elements.point.radius = 0;
Chart.defaults.global.tooltips.mode = "index";
Chart.defaults.global.tooltips.axis = "x";
Chart.defaults.global.tooltips.intersect = false;
Chart.defaults.global.animation.duration = 500;
Chart.defaults.global.animation.easing = "linear";
function drawGraph(element, label, dataType) {
return new Chart(
element,
{
type: 'line',
data: {
datasets: [
{
label: label,
2021-10-12 21:25:43 +02:00
backgroundColor: "#" + window.style.highlightColor,
2020-08-11 19:52:03 +02:00
borderWidth: 0,
lineTension: 0,
fill: true,
yAxisID: "ax_1"
}
]
},
options: {
legend: { display: false },
scales: {
yAxes: [
{
type: "linear",
display: true,
position: "left",
id: "ax_1",
ticks: {
2021-05-05 20:20:34 +02:00
callback: function (value, index, values) {
2020-08-11 19:52:03 +02:00
if (dataType == "bytes") {
return formatDataVolume(value, 3);
}
return formatNumber(value, 3);
},
beginAtZero: true
},
2021-05-05 20:20:34 +02:00
gridLines: { display: true },
2020-08-11 19:52:03 +02:00
}
],
xAxes: [
{
ticks: {
sampleSize: 1,
padding: 4,
minRotation: 0,
maxRotation: 0
},
gridLines: { display: false }
}
]
}
}
}
);
}