mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Commit realizando cambios en los roles de los usuarios
This commit is contained in:
10
httpdocs/themes/focus2/vendor/chart.heatmap.js/Chart.HeatMap.S.min.js
vendored
Normal file
10
httpdocs/themes/focus2/vendor/chart.heatmap.js/Chart.HeatMap.S.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
262
httpdocs/themes/focus2/vendor/chart.heatmap.js/Chart.HeatMap.js
vendored
Normal file
262
httpdocs/themes/focus2/vendor/chart.heatmap.js/Chart.HeatMap.js
vendored
Normal file
@ -0,0 +1,262 @@
|
||||
|
||||
|
||||
|
||||
// Return with commas in between
|
||||
var numberWithCommas = function (x) {
|
||||
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
||||
};
|
||||
|
||||
|
||||
var helpers = Chart.helpers;
|
||||
|
||||
|
||||
Chart.HeatMapPlugin = Chart.PluginBase.extend({
|
||||
beforeInit: function (chart) {
|
||||
if (chart.config.type === 'heatmap') {
|
||||
// Keep the y-axis in sync with the datasets
|
||||
chart.data.yLabels = chart.data.datasets.map(function (ds) {
|
||||
return ds.label;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
beforeUpdate: function (chart) {
|
||||
if (chart.config.type === 'heatmap') {
|
||||
// Keep the y-axis in sync with the datasets
|
||||
chart.data.yLabels = chart.data.datasets.map(function (ds) {
|
||||
return ds.label;
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Chart.plugins.register(new Chart.HeatMapPlugin());
|
||||
Chart.defaults.heatmap = {
|
||||
radiusScale: 0,
|
||||
paddingScale: 0,
|
||||
colorFunction: function (value, minVal, maxVal, colorScheme) {
|
||||
return getColorForPercentage(value, minVal, maxVal, colorScheme);
|
||||
},
|
||||
colorGradiant: 'YellowToRed',
|
||||
hover: {
|
||||
mode: 'single'
|
||||
},
|
||||
|
||||
legend: {
|
||||
display: false,
|
||||
displayCustom: true,
|
||||
position: 'right',
|
||||
},
|
||||
scales: {
|
||||
xAxes: [{
|
||||
type: 'category',
|
||||
position: 'bottom',
|
||||
gridLines: {
|
||||
display: false,
|
||||
offsetGridLines: true,
|
||||
drawBorder: false,
|
||||
drawTicks: false
|
||||
}
|
||||
}],
|
||||
yAxes: [{
|
||||
type: 'category',
|
||||
position: 'left',
|
||||
gridLines: {
|
||||
display: false,
|
||||
offsetGridLines: true,
|
||||
drawBorder: false,
|
||||
drawTicks: false
|
||||
}
|
||||
}]
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Chart.controllers.heatmap = Chart.DatasetController.extend({
|
||||
dataElementType: Chart.elements.Rectangle,
|
||||
minDataSetValue: function (){
|
||||
var returnValue = 0;
|
||||
var tmpValue = 0;
|
||||
var dataset = this.chart.data.datasets;
|
||||
for (var xx = 0; xx < dataset.length; xx++){
|
||||
if(xx == 0){
|
||||
returnValue = Math.min.apply(Math, dataset[xx].data);
|
||||
}
|
||||
else{
|
||||
tmpValue = Math.min.apply(Math, dataset[xx].data);
|
||||
if (tmpValue < returnValue) {
|
||||
returnValue = tmpValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
return returnValue;
|
||||
},
|
||||
maxDataSetValue: function () {
|
||||
var returnValue = 0;
|
||||
var tmpValue = 0;
|
||||
var dataset = this.chart.data.datasets;
|
||||
for (var xx = 0; xx < dataset.length; xx++) {
|
||||
if (xx == 0) {
|
||||
returnValue = Math.max.apply(Math, dataset[xx].data);
|
||||
}
|
||||
else {
|
||||
tmpValue = Math.max.apply(Math, dataset[xx].data);
|
||||
if (tmpValue > returnValue) {
|
||||
returnValue = tmpValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
return returnValue;
|
||||
},
|
||||
|
||||
update: function (reset) {
|
||||
var me = this;
|
||||
var meta = me.getMeta();
|
||||
var boxes = meta.data;
|
||||
|
||||
// Update Boxes
|
||||
helpers.each(boxes, function (box, index) {
|
||||
me.updateElement(box, index, reset);
|
||||
});
|
||||
},
|
||||
|
||||
updateElement: function (box, index) {
|
||||
var me = this;
|
||||
var meta = me.getMeta();
|
||||
var xScale = me.getScaleForId(meta.xAxisID);
|
||||
var yScale = me.getScaleForId(meta.yAxisID);
|
||||
var dataset = me.getDataset();
|
||||
var data = dataset.data[index];
|
||||
var datasetIndex = me.index;
|
||||
var radiusScale = me.chart.options.radiusScale;
|
||||
var paddingScale = me.chart.options.paddingScale;
|
||||
|
||||
var x = xScale.getPixelForValue(data, index, datasetIndex);
|
||||
var y = yScale.getPixelForValue(data, datasetIndex, datasetIndex);
|
||||
|
||||
var boxWidth = 0;
|
||||
if (dataset.data.length > 1) {
|
||||
var x0 = xScale.getPixelForValue(dataset.data[0], 0, datasetIndex);
|
||||
var x1 = xScale.getPixelForValue(dataset.data[1], 1, datasetIndex);
|
||||
boxWidth = x1 - x0;
|
||||
} else {
|
||||
boxWidth = xScale.width;
|
||||
}
|
||||
|
||||
var boxHeight = 0;
|
||||
if (me.chart.data.datasets.length > 1) {
|
||||
// We only support 'category' scales on the y-axis for now
|
||||
boxHeight = yScale.getPixelForValue(null, 1, 1) - yScale.getPixelForValue(null, 0, 0);
|
||||
} else {
|
||||
boxHeight = yScale.height;
|
||||
}
|
||||
|
||||
// Apply padding
|
||||
var horizontalPadding = paddingScale * boxWidth;
|
||||
var verticalPadding = paddingScale * boxHeight;
|
||||
boxWidth = boxWidth - horizontalPadding;
|
||||
boxHeight = boxHeight - verticalPadding;
|
||||
y = y + verticalPadding / 2;
|
||||
x = x + horizontalPadding / 2;
|
||||
|
||||
|
||||
var color = me.chart.options.colorFunction(data, me.minDataSetValue(), me.maxDataSetValue(), me.chart.options.colorGradiant);
|
||||
var cornerRadius = boxWidth * radiusScale;
|
||||
|
||||
helpers.extend(box, {
|
||||
// Utility
|
||||
_xScale: xScale,
|
||||
_yScale: yScale,
|
||||
_datasetIndex: datasetIndex,
|
||||
_index: index,
|
||||
_data: data,
|
||||
|
||||
// Desired view properties
|
||||
_model: {
|
||||
// Position
|
||||
x: x + boxWidth / 2,
|
||||
y: y,
|
||||
|
||||
// Appearance
|
||||
base: y + boxHeight,
|
||||
height: boxHeight,
|
||||
width: boxWidth,
|
||||
backgroundColor: color,
|
||||
cornerRadius: cornerRadius,
|
||||
|
||||
// Tooltip
|
||||
label: me.chart.data.labels[index],
|
||||
datasetLabel: dataset.label,
|
||||
},
|
||||
|
||||
// Override to draw rounded rectangles without any borders
|
||||
draw: function () {
|
||||
var ctx = this._chart.ctx;
|
||||
var vm = this._view;
|
||||
|
||||
var leftX = vm.x - (vm.width) / 2;
|
||||
|
||||
ctx.fillStyle = vm.backgroundColor;
|
||||
helpers.drawRoundedRectangle(ctx, leftX, vm.y, vm.width, vm.height, vm.cornerRadius);
|
||||
|
||||
ctx.fill();
|
||||
},
|
||||
|
||||
// Override to position the tooltip in the center of the box
|
||||
tooltipPosition: function () {
|
||||
var vm = this._view;
|
||||
return {
|
||||
x: vm.x,
|
||||
y: vm.y + vm.height / 2
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
box.pivot();
|
||||
},
|
||||
|
||||
setHoverStyle: function () {
|
||||
// TODO: Implement this
|
||||
},
|
||||
|
||||
removeHoverStyle: function () {
|
||||
// TODO: Implement this
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
function getYellowToRedColor(colorSelectionCount, value) {
|
||||
var incroment = 100 / colorSelectionCount;
|
||||
var colorIncroment = 255 / colorSelectionCount;
|
||||
for (var ii = 1; ii <= colorSelectionCount; ii++) {
|
||||
if ((ii * incroment) >= value) {
|
||||
return "rgb(255, " + Math.ceil(255 - (ii * colorIncroment)) + ", 0)";
|
||||
}
|
||||
}
|
||||
return "rgb(255, 255, 0)";
|
||||
}
|
||||
|
||||
function getGreenToBlueColor(colorSelectionCount, value) {
|
||||
var incroment = 100 / colorSelectionCount;
|
||||
var colorIncroment = 255 / colorSelectionCount;
|
||||
for (var ii = 1; ii <= colorSelectionCount; ii++) {
|
||||
if ((ii * incroment) >= value) {
|
||||
return "rgb(0, " + Math.ceil(255 - (ii * colorIncroment)) + ", 255)";
|
||||
}
|
||||
}
|
||||
return "rgb(0, 255, 255)";
|
||||
}
|
||||
|
||||
|
||||
//sets the chart background to white
|
||||
Chart.plugins.register({
|
||||
beforeDraw: function (chartInstance) {
|
||||
var ctx = chartInstance.chart.ctx;
|
||||
ctx.fillStyle = "white";
|
||||
ctx.fillRect(0, 0, chartInstance.chart.width, chartInstance.chart.height);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
48
httpdocs/themes/focus2/vendor/chart.heatmap.js/sampledata.js
vendored
Normal file
48
httpdocs/themes/focus2/vendor/chart.heatmap.js/sampledata.js
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
var getColorForPercentage = function (pct, minVal, maxVal, colorGradiant) {
|
||||
var finalColorPercent = pct;
|
||||
|
||||
if (minVal >= 0 && maxVal > 0 && maxVal > minVal) {
|
||||
finalColorPercent = (pct - minVal) / (maxVal - minVal) * 100;
|
||||
}
|
||||
|
||||
if (colorGradiant == "YellowToRed") {
|
||||
return getYellowToRedColor(20, finalColorPercent);
|
||||
} else if (colorGradiant == "GreenToBlue") {
|
||||
return getGreenToBlueColor(20, finalColorPercent);
|
||||
} else {
|
||||
return getGreenToBlueColor(20, finalColorPercent);
|
||||
}
|
||||
}
|
||||
|
||||
var stateList = ['AK', 'AL', 'AR', 'AZ', 'CA', 'CO', 'CT', 'DC', 'DE', 'FL', 'GA', 'HI', 'IA', 'ID', 'IL', 'IN', 'KS', 'KY', 'LA', 'MA', 'MD', 'ME', 'MI', 'MN', 'MO', 'MS', 'MT', 'NC', 'ND', 'NE', 'NH', 'NJ', 'NM', 'NV', 'NY', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VA', 'VT', 'WA', 'WI', 'WV', 'WY'];
|
||||
var globalXAxesTitle = "";
|
||||
var globalYAxesTitle = "";
|
||||
var globalRadiusRawData = [];
|
||||
|
||||
var myChartLabels = ["AK", "DE", "HI", "ME", "MT", "ND", "NH", "RI", "SD"];
|
||||
var myChartData = {
|
||||
labels: myChartLabels,
|
||||
datasets: [{
|
||||
label: ['American Indian','Alaska Native'],
|
||||
data: [30748, 694, 872, 1339, 17349, 9477, 790, 1991, 16099]
|
||||
}, {
|
||||
label: 'Asian',
|
||||
data: [8132, 4776, 59916, 2838, 1410, 1603, 5753, 4130, 2412]
|
||||
}, {
|
||||
label: 'Black',
|
||||
data: [4476, 42305, 3957, 5919, 1613, 3636, 3750, 11314, 3776]
|
||||
}, {
|
||||
label: 'Hispanic',
|
||||
data: [8632, 19247, 18285, 3189, 5592, 3648, 8940, 31871, 6110]
|
||||
}, {
|
||||
label: 'Multi Race',
|
||||
data: [11247, 3477, 18871, 2956, 3111, 1266, 3573, 5966, 3767]
|
||||
}, {
|
||||
label: ['Native Hawaiian', 'Pacific Islander'],
|
||||
data: [3260, 229, 60005, 304, 486, 414, 309, 308, 207]
|
||||
}, {
|
||||
label: 'White',
|
||||
data: [62945, 64673, 25635, 158810, 115704, 84611, 164485, 85364, 103293]
|
||||
}]
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user