1
0
forked from Tank/braga
braga/public/js/bulma.js

77 lines
2.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

$( document ).ready(function() {
$('input[name="datetimes"]').daterangepicker({
timePicker: true,
startDate: $('#dater').data('start'),
endDate: $('#dater').data('end'),
timePicker24Hour: true,
locale: {
format: 'YYYY-MM-DD HH:mm:ss',
separator: ' > ',
applyLabel: 'Применить',
cancelLabel: 'Отменить',
fromLabel: 'С',
toLabel: 'По',
weekLabel: 'Н',
daysOfWeek: [
'Вск',
'Пнд',
'Втр',
'Срд',
'Чтв',
'Птн',
'Сбт'
],
monthNames: [
'Январь',
'Февраль',
'Март',
'Апрель',
'Май',
'Июнь',
'Июль',
'Август',
'Сентябрь',
'Октябрь',
'Ноябрь',
'Декабрь'
],
firstDay: 1
}
});
Chart.defaults.color = '#FFF';
Chart.defaults.borderColor = '#555';
$('[id^="daystat"]').each(function() {
const chartElement = this;
let existingChart = Chart.getChart(chartElement); // Получаем ссылку на существующий экземпляр чарта
if (existingChart !== undefined) { // Проверяем наличие предыдущего чарта
existingChart.destroy(); // Уничтожаем предыдущий экземпляр чарта
}
new Chart(chartElement, { // Создаем новый график
type: 'bar',
data: {
labels: $(chartElement).data('labels'), // Используем данные, хранящиеся в атрибуте data-*
datasets: [{
label: 'Температура сусла',
data: $(chartElement).data('vals'),
borderWidth: 1,
backgroundColor: ['rgb(255, 99, 132)', 'rgb(54, 162, 235)', 'rgb(255, 205, 86)']
}]
},
options: {
scales: {
y: {
beginAtZero: true
}
}
}
});
});
});