$( 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 } } } }); }); $(".tank-data").each(function() { // Внутри каждого отдельного списка сортируем его пункты $(this).find("li").sort(function(a, b) { // Преобразуем строку в число и сравниваем порядок return parseInt($(a).attr("data-order"), 10) - parseInt($(b).attr("data-order"), 10); }).appendTo(this); // Перемещаем отсортированные пункты обратно в этот же список }); $('.full-info').click(function() { var id = $(this).data('id') if ($('#info'+id).hasClass('is-hidden')) { $('#info'+id).removeClass('is-hidden') } else { $('#info'+id).addClass('is-hidden') } }); if($('#climate1').length){ new Chart($('#climate1'), { type: 'bar', data: { labels: $('#climate1').data('labels'), datasets: [{ label: 'Температура воздуха', data: $('#climate1').data('vals'), borderWidth: 1, backgroundColor: [ 'rgb(255, 99, 132)', 'rgb(54, 162, 235)', 'rgb(255, 205, 86)' ], }] }, options: { scales: { y: { beginAtZero: true } } } }); new Chart($('#climate2'), { type: 'bar', data: { labels: $('#climate2').data('labels'), datasets: [{ label: 'Влажность', data: $('#climate2').data('vals'), borderWidth: 1, backgroundColor: [ 'rgb(255, 99, 132)', 'rgb(54, 162, 235)', 'rgb(255, 205, 86)' ], }] }, options: { scales: { y: { beginAtZero: true } } } }); } });