90 lines
2.5 KiB
JavaScript
90 lines
2.5 KiB
JavaScript
function chartBarentries(labels, data, amount){
|
|
|
|
// Set new default font family and font color to mimic Bootstrap's default styling
|
|
Chart.defaults.global.defaultFontFamily = 'Nunito', '-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif';
|
|
Chart.defaults.global.defaultFontColor = '#858796';
|
|
|
|
// Bar Chart Example
|
|
var ctx = document.getElementById("myBarChart");
|
|
var myBarChart = new Chart(ctx, {
|
|
type: 'bar',
|
|
data: {
|
|
labels: labels,
|
|
datasets: [{
|
|
label: "Entradas",
|
|
backgroundColor: "#00B22D",
|
|
hoverBackgroundColor: "#2e59d9",
|
|
borderColor: "#00B22D",
|
|
data: data,
|
|
}],
|
|
},
|
|
options: {
|
|
maintainAspectRatio: false,
|
|
layout: {
|
|
padding: {
|
|
left: 10,
|
|
right: 25,
|
|
top: 15,
|
|
bottom: 0
|
|
}
|
|
},
|
|
scales: {
|
|
xAxes: [{
|
|
time: {
|
|
unit: 'month'
|
|
},
|
|
gridLines: {
|
|
display: false,
|
|
drawBorder: false
|
|
},
|
|
ticks: {
|
|
maxTicksLimit: 6
|
|
},
|
|
maxBarThickness: 25,
|
|
}],
|
|
yAxes: [{
|
|
ticks: {
|
|
min: 0,
|
|
max: amount,
|
|
maxTicksLimit: 5,
|
|
padding: 10,
|
|
// Include a dollar sign in the ticks
|
|
callback: function(value, index, values) {
|
|
return 'R$ ' + number_format(value, 2, ',', '.');
|
|
}
|
|
},
|
|
gridLines: {
|
|
color: "rgb(234, 236, 244)",
|
|
zeroLineColor: "rgb(234, 236, 244)",
|
|
drawBorder: false,
|
|
borderDash: [2],
|
|
zeroLineBorderDash: [2]
|
|
}
|
|
}],
|
|
},
|
|
legend: {
|
|
display: false
|
|
},
|
|
tooltips: {
|
|
titleMarginBottom: 10,
|
|
titleFontColor: '#6e707e',
|
|
titleFontSize: 14,
|
|
backgroundColor: "rgb(255,255,255)",
|
|
bodyFontColor: "#858796",
|
|
borderColor: '#dddfeb',
|
|
borderWidth: 1,
|
|
xPadding: 15,
|
|
yPadding: 15,
|
|
displayColors: false,
|
|
caretPadding: 10,
|
|
callbacks: {
|
|
label: function(tooltipItem, chart) {
|
|
var datasetLabel = chart.datasets[tooltipItem.datasetIndex].label || '';
|
|
return datasetLabel + ': R$ ' + number_format(tooltipItem.yLabel, 2, ',', '.');
|
|
}
|
|
}
|
|
},
|
|
}
|
|
});
|
|
|
|
}
|