484 lines
14 KiB
JavaScript
484 lines
14 KiB
JavaScript
(async function () {
|
||
let positions
|
||
positions = await fetch('positions/').then(response => {
|
||
return response.json()
|
||
})
|
||
const locales = [{
|
||
"name": "ru",
|
||
"options": {
|
||
"months": ["Январь", "Февраль", "Март", "Апрель", "Май", "Июнь", "Июль", "Август", "Сентрябрь", "Октябрь", "Ноябрь", "Декабрь"],
|
||
"shortMonths": ["Янв", "Фев", "Мар", "Апр", "Май", "Июнь", "Июль ", "Авг", "Сент", "Окт", "Нояб", "Дек"],
|
||
"days": ["Понедельник", "Вторник", "Среда", "Четверг", "Пятница", "Суббота", "Воскресенье"],
|
||
"shortDays": ["Пн", "Вт", "Ср", "Чт", "Пт", "Сб", "Вс"],
|
||
"toolbar": {
|
||
"exportToSVG": "Скачать SVG",
|
||
"exportToPNG": "Скачать PNG",
|
||
"exportToCSV": "Скачать CSV",
|
||
"menu": "Меню",
|
||
"selection": "Выборка",
|
||
"selectionZoom": "Приближение выборки",
|
||
"zoomIn": "Приблизить",
|
||
"zoomOut": "Отдалить",
|
||
"pan": "Панорамирование",
|
||
"reset": "Сбросить приближение"
|
||
}
|
||
}
|
||
}]
|
||
|
||
const hoursBarOptions = {
|
||
series: [{
|
||
name: 'Текущая смена',
|
||
data: []
|
||
}, {
|
||
name: 'Предыдущая смена',
|
||
data: []
|
||
}],
|
||
colors: ['var(--success)', 'var(--primary)', 'var(--danger)'],
|
||
chart: {
|
||
type: 'bar',
|
||
height: 300,
|
||
locales: locales,
|
||
defaultLocale: "ru",
|
||
animations: {
|
||
enabled: true,
|
||
easing: 'easeinout',
|
||
speed: 800,
|
||
animateGradually: {
|
||
enabled: true,
|
||
delay: 150
|
||
},
|
||
dynamicAnimation: {
|
||
enabled: true,
|
||
speed: 350
|
||
}
|
||
}
|
||
},
|
||
plotOptions: {
|
||
bar: {
|
||
horizontal: true,
|
||
},
|
||
},
|
||
dataLabels: {
|
||
enabled: true,
|
||
textAnchor: 'start',
|
||
offsetX: -5,
|
||
dropShadow: {
|
||
enabled: false
|
||
},
|
||
formatter: function (val) {
|
||
return val;
|
||
},
|
||
},
|
||
stroke: {
|
||
show: true,
|
||
width: 2,
|
||
colors: ['transparent']
|
||
},
|
||
xaxis: {
|
||
categories: positions,
|
||
},
|
||
fill: {
|
||
opacity: 1
|
||
},
|
||
tooltip: {
|
||
y: {
|
||
formatter: function (val) {
|
||
return val + " тонн в час";
|
||
}
|
||
}
|
||
},
|
||
title: {
|
||
text: 'часовая нагрузка'
|
||
},
|
||
noData: {
|
||
text: 'Загрузка...'
|
||
}
|
||
};
|
||
|
||
const hoursBarChart = new ApexCharts(document.querySelector("#byHourScales"), hoursBarOptions);
|
||
hoursBarChart.render();
|
||
|
||
const DailyBarOptions = {
|
||
series: [],
|
||
colors: ['var(--success)', 'var(--primary)', 'var(--danger)'],
|
||
chart: {
|
||
type: 'bar',
|
||
height: 300,
|
||
stacked: true,
|
||
toolbar: {
|
||
show: true
|
||
},
|
||
locales: locales,
|
||
defaultLocale: "ru",
|
||
},
|
||
responsive: [{
|
||
breakpoint: 480,
|
||
options: {
|
||
legend: {
|
||
position: 'bottom',
|
||
offsetX: -10,
|
||
offsetY: 0
|
||
}
|
||
}
|
||
}],
|
||
plotOptions: {
|
||
bar: {
|
||
horizontal: false,
|
||
dataLabels: {
|
||
total: {
|
||
enabled: true,
|
||
style: {
|
||
fontSize: '13px',
|
||
fontWeight: 900
|
||
}
|
||
}
|
||
}
|
||
},
|
||
},
|
||
xaxis: {
|
||
type: 'category',
|
||
categories: positions,
|
||
},
|
||
legend: {
|
||
position: 'bottom',
|
||
},
|
||
fill: {
|
||
opacity: 1
|
||
},
|
||
title: {
|
||
text: 'тонн за сутки'
|
||
},
|
||
noData: {
|
||
text: 'Загрузка...'
|
||
}
|
||
};
|
||
|
||
const dailyScalesChart = new ApexCharts(document.querySelector("#dailyScales"), DailyBarOptions);
|
||
dailyScalesChart.render();
|
||
|
||
const monthlyBarOptions = {
|
||
series: [],
|
||
colors: ['var(--success)', 'var(--primary)', 'var(--danger)'],
|
||
chart: {
|
||
type: 'bar',
|
||
height: 300,
|
||
stacked: true,
|
||
toolbar: {
|
||
show: true
|
||
},
|
||
zoom: {
|
||
enabled: true
|
||
},
|
||
locales: locales,
|
||
defaultLocale: "ru",
|
||
},
|
||
responsive: [{
|
||
breakpoint: 480,
|
||
options: {
|
||
legend: {
|
||
position: 'bottom',
|
||
offsetX: -10,
|
||
offsetY: 0
|
||
}
|
||
}
|
||
}],
|
||
plotOptions: {
|
||
bar: {
|
||
dataLabels: {
|
||
position: 'top'
|
||
}
|
||
}
|
||
},
|
||
dataLabels: {
|
||
enabled: true,
|
||
style: {
|
||
colors: ['#000']
|
||
},
|
||
offsetY: -20,
|
||
textAnchor: 'start',
|
||
},
|
||
xaxis: {
|
||
type: 'category',
|
||
categories: positions,
|
||
},
|
||
legend: {
|
||
position: 'bottom',
|
||
},
|
||
fill: {
|
||
opacity: 1
|
||
},
|
||
title: {
|
||
text: 'тонн за месяц'
|
||
},
|
||
tooltip: {
|
||
y: {
|
||
formatter: function (val) {
|
||
return val + 'тонн'
|
||
}
|
||
}
|
||
},
|
||
noData: {
|
||
text: 'Загрузка...'
|
||
}
|
||
};
|
||
const monthlyScalesChart = new ApexCharts(document.querySelector("#monthlyScales"), monthlyBarOptions);
|
||
monthlyScalesChart.render();
|
||
|
||
function getChartsData() {
|
||
return fetch('scales/').then(response => {
|
||
return response.json()
|
||
})
|
||
}
|
||
|
||
|
||
function setChartsData(response) {
|
||
monthlyScalesChart.updateSeries([{
|
||
name: 'Месяц',
|
||
data: Object.values(response.monthly)
|
||
}], true)
|
||
|
||
hoursBarChart.updateSeries([{
|
||
name: 'Текущая смена',
|
||
data: Object.values(response.productivity.current_work_shift)
|
||
}, {
|
||
name: 'Предыдущая смена',
|
||
data: Object.values(response.productivity.previous_work_shift)
|
||
}], true)
|
||
|
||
dailyScalesChart.updateSeries([{
|
||
name: 'Текущая смена',
|
||
data: Object.values(response.daily.current_work_shift)
|
||
}, {
|
||
name: 'Предыдущая смена',
|
||
data: Object.values(response.daily.previous_work_shift)
|
||
}], true)
|
||
}
|
||
|
||
async function buildCharts() {
|
||
const response = await getChartsData()
|
||
setChartsData(response)
|
||
}
|
||
|
||
await buildCharts()
|
||
setInterval(buildCharts, 5000)
|
||
|
||
})();
|
||
|
||
|
||
(function () {
|
||
const optionsCircle = {
|
||
chart: {
|
||
type: 'radialBar',
|
||
height: '400px'
|
||
},
|
||
plotOptions: {
|
||
radialBar: {
|
||
size: undefined,
|
||
inverseOrder: false,
|
||
hollow: {
|
||
margin: 5,
|
||
size: '48%',
|
||
background: 'transparent',
|
||
},
|
||
track: {
|
||
show: true,
|
||
background: '#40475D',
|
||
strokeWidth: '10%',
|
||
opacity: 1,
|
||
margin: 3, // margin is in pixels
|
||
},
|
||
dataLabels: {
|
||
name: {
|
||
show: true,
|
||
color: '#888',
|
||
fontSize: '12px',
|
||
fontWeight: 400,
|
||
},
|
||
value: {
|
||
color: '#111',
|
||
offsetY: -2,
|
||
fontSize: '12px',
|
||
fontWeight: 400,
|
||
show: true,
|
||
}
|
||
}
|
||
},
|
||
},
|
||
series: [31, 53],
|
||
labels: ['т. смена ', 'пр. смена '],
|
||
colors: ['var(--success)', 'var(--primary)', 'var(--danger)'],
|
||
legend: {
|
||
show: true,
|
||
position: 'bottom',
|
||
formatter: function (val, opts) {
|
||
return val + " - " + opts.w.globals.series[opts.seriesIndex] + '%'
|
||
}
|
||
},
|
||
title: {
|
||
text: 'Y к-та %'
|
||
}
|
||
}
|
||
var chartCircle = new ApexCharts(document.querySelector('#HourCircle_1'), optionsCircle);
|
||
chartCircle.render();
|
||
})();
|
||
(function () {
|
||
const optionsCircle = {
|
||
chart: {
|
||
type: 'radialBar',
|
||
height: '400px'
|
||
|
||
},
|
||
plotOptions: {
|
||
radialBar: {
|
||
size: undefined,
|
||
inverseOrder: false,
|
||
hollow: {
|
||
margin: 5,
|
||
size: '48%',
|
||
background: 'transparent',
|
||
},
|
||
track: {
|
||
show: true,
|
||
background: '#40475D',
|
||
strokeWidth: '10%',
|
||
opacity: 1,
|
||
margin: 3, // margin is in pixels
|
||
},
|
||
dataLabels: {
|
||
name: {
|
||
show: true,
|
||
color: '#888',
|
||
fontSize: '12px',
|
||
fontWeight: 400,
|
||
},
|
||
value: {
|
||
color: '#111',
|
||
offsetY: -2,
|
||
fontSize: '12px',
|
||
fontWeight: 400,
|
||
show: true,
|
||
}
|
||
}
|
||
},
|
||
},
|
||
series: [32, 53],
|
||
labels: ['т. смена ', 'пр. смена '],
|
||
colors: ['var(--success)', 'var(--primary)', 'var(--danger)'],
|
||
legend: {
|
||
show: true,
|
||
position: 'bottom',
|
||
formatter: function (val, opts) {
|
||
return val + " - " + opts.w.globals.series[opts.seriesIndex] + '%'
|
||
}
|
||
},
|
||
title: {
|
||
text: 'Y отсева %'
|
||
}
|
||
}
|
||
var chartCircle = new ApexCharts(document.querySelector('#HourCircle_2'), optionsCircle);
|
||
chartCircle.render();
|
||
})();
|
||
(function () {
|
||
const optionsCircle = {
|
||
chart: {
|
||
type: 'radialBar',
|
||
},
|
||
plotOptions: {
|
||
radialBar: {
|
||
size: undefined,
|
||
inverseOrder: false,
|
||
hollow: {
|
||
margin: 5,
|
||
size: '48%',
|
||
background: 'transparent',
|
||
},
|
||
track: {
|
||
show: true,
|
||
background: '#40475D',
|
||
strokeWidth: '10%',
|
||
opacity: 1,
|
||
margin: 3, // margin is in pixels
|
||
},
|
||
dataLabels: {
|
||
name: {
|
||
show: true,
|
||
color: '#888',
|
||
fontSize: '12px',
|
||
fontWeight: 400,
|
||
},
|
||
value: {
|
||
color: '#111',
|
||
offsetY: -2,
|
||
fontSize: '12px',
|
||
fontWeight: 400,
|
||
show: true,
|
||
}
|
||
}
|
||
},
|
||
},
|
||
series: [41, 83],
|
||
labels: ['Y к-та', 'Y отсева'],
|
||
colors: ['var(--success)', 'var(--primary)', 'var(--danger)'],
|
||
legend: {
|
||
show: true,
|
||
position: 'left',
|
||
formatter: function (val, opts) {
|
||
return val + " - " + opts.w.globals.series[opts.seriesIndex] + '%'
|
||
}
|
||
},
|
||
}
|
||
var chartCircle = new ApexCharts(document.querySelector('#dailyCircle'), optionsCircle);
|
||
chartCircle.render();
|
||
})();
|
||
(function () {
|
||
const optionsCircle = {
|
||
chart: {
|
||
type: 'radialBar',
|
||
},
|
||
plotOptions: {
|
||
radialBar: {
|
||
size: undefined,
|
||
inverseOrder: false,
|
||
hollow: {
|
||
margin: 5,
|
||
size: '48%',
|
||
background: 'transparent',
|
||
},
|
||
track: {
|
||
show: true,
|
||
background: '#40475D',
|
||
strokeWidth: '10%',
|
||
opacity: 1,
|
||
margin: 3, // margin is in pixels
|
||
},
|
||
dataLabels: {
|
||
name: {
|
||
show: true,
|
||
color: '#888',
|
||
fontSize: '12px',
|
||
fontWeight: 400,
|
||
},
|
||
value: {
|
||
color: '#111',
|
||
offsetY: -2,
|
||
fontSize: '12px',
|
||
fontWeight: 400,
|
||
show: true,
|
||
}
|
||
}
|
||
},
|
||
},
|
||
series: [71, 63],
|
||
labels: ['Y к-та ', 'Y отсева '],
|
||
colors: ['var(--success)', 'var(--primary)', 'var(--danger)'],
|
||
legend: {
|
||
show: true,
|
||
position: 'left',
|
||
formatter: function (val, opts) {
|
||
return val + " - " + opts.w.globals.series[opts.seriesIndex] + '%'
|
||
}
|
||
},
|
||
}
|
||
var chartCircle = new ApexCharts(document.querySelector('#monthlyCircle'), optionsCircle);
|
||
chartCircle.render();
|
||
})(); |