simedkom/resources/views/dashboard/media-monitorings/statistics/media-monitoring-statistics.blade.php

148 lines
4.8 KiB
PHP

<script>
"use strict";
!function (NioApp, $) {
"use strict"; //////// for developer - barchart ////////
// Avilable options to pass from outside
// labels: array,
// stacked: false - boolean,
// legend: false - boolean,
// dataUnit: string, (Used in tooltip or other section for display)
// datasets: [{label : string, color: string (color code with # or other format), data: array}]
var barChartData = {
labels: ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30"],
dataUnit: 'People',
datasets: [{
label: "join",
color: "#b695ff",
data: [110, 80, 125, 55, 95, 75, 90, 110, 80, 125, 55, 95, 75, 90, 110, 80, 125, 55, 95, 75, 90, 110, 80, 125, 55, 95, 75, 90, 75, 90]
}, {
label: "join",
color: "#b695ff",
data: [110, 80, 125, 55, 95, 75, 90, 110, 80, 125, 55, 95, 75, 90, 110, 80, 125, 55, 95, 75, 90, 110, 80, 125, 55, 95, 75, 90, 75, 90]
}]
};
var barChartMultiple = {
labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
dataUnit: 'Data',
datasets: [{
label: "Monitoring Media",
color: "#3ABEF9",
data: @json($mediaMonitoringMonthly)
}, {
label: "Manajemen Isu",
color: "#FFEB00",
data: @json($issueManagementMonthly)
}]
};
function barChart(selector, set_data) {
var $selector = selector ? $(selector) : $('.bar-chart');
$selector.each(function () {
var $self = $(this),
_self_id = $self.attr('id'),
_get_data = typeof set_data === 'undefined' ? eval(_self_id) : set_data,
_d_legend = typeof _get_data.legend === 'undefined' ? false : _get_data.legend;
var selectCanvas = document.getElementById(_self_id).getContext("2d");
var chart_data = [];
for (var i = 0; i < _get_data.datasets.length; i++) {
chart_data.push({
label: _get_data.datasets[i].label,
data: _get_data.datasets[i].data,
// Styles
backgroundColor: _get_data.datasets[i].color,
borderWidth: 2,
borderColor: 'transparent',
hoverBorderColor: 'transparent',
borderSkipped: 'bottom',
barPercentage: .6,
categoryPercentage: .7
});
}
var chart = new Chart(selectCanvas, {
type: 'bar',
data: {
labels: _get_data.labels,
datasets: chart_data
},
options: {
legend: {
display: _get_data.legend ? _get_data.legend : false,
rtl: NioApp.State.isRTL,
labels: {
boxWidth: 30,
padding: 20,
fontColor: '#6783b8'
}
},
maintainAspectRatio: false,
tooltips: {
enabled: true,
rtl: NioApp.State.isRTL,
callbacks: {
title: function title(tooltipItem, data) {
return data.datasets[tooltipItem[0].datasetIndex].label;
},
label: function label(tooltipItem, data) {
return data.datasets[tooltipItem.datasetIndex]['data'][tooltipItem['index']] + ' ' + _get_data.dataUnit;
}
},
backgroundColor: '#eff6ff',
titleFontSize: 13,
titleFontColor: '#6783b8',
titleMarginBottom: 6,
bodyFontColor: '#9eaecf',
bodyFontSize: 12,
bodySpacing: 4,
yPadding: 10,
xPadding: 10,
footerMarginTop: 0,
displayColors: false
},
scales: {
yAxes: [{
display: true,
stacked: _get_data.stacked ? _get_data.stacked : false,
position: NioApp.State.isRTL ? "right" : "left",
ticks: {
beginAtZero: true,
fontSize: 12,
fontColor: '#9eaecf'
},
gridLines: {
color: NioApp.hexRGB("#526484", .2),
tickMarkLength: 0,
zeroLineColor: NioApp.hexRGB("#526484", .2)
}
}],
xAxes: [{
display: true,
stacked: _get_data.stacked ? _get_data.stacked : false,
ticks: {
fontSize: 12,
fontColor: '#9eaecf',
source: 'auto',
reverse: NioApp.State.isRTL
},
gridLines: {
color: "transparent",
tickMarkLength: 10,
zeroLineColor: 'transparent'
}
}]
}
}
});
});
} // init bar chart
barChart(); //////// for developer - linechart ////////
}(NioApp, jQuery);
</script>