Files
Samuele E. Locatelli 0689267c12 Continuo fix grafici
2018-05-05 11:12:25 +02:00

146 lines
4.0 KiB
Plaintext

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="mod_graphRadar.ascx.cs" Inherits="PUB.WebUserContols.mod_graphRadar" %>
<canvas id="radarChart" width="200" height="200"></canvas>
<asp:HiddenField runat="server" ID="hfDSetType" />
<asp:HiddenField runat="server" ID="hfDataRif" />
<script>
// funzione eseguita se successo al caricamento
function OnSuccess_(reponse) {
// recupero obj chart
var ctx = document.getElementById("radarChart");
var aData = reponse.d;
var titolo = aData[0];
var maxVal = aData[1];
var aLabels = aData[2];
var aDatasets1 = aData[3];
var options = {
responsive: true,
maintainAspectRatio: true,
scale: {
ticks: {
beginAtZero: true,
max: maxVal,
min: -0.5
}
},
animation: {
duration: 0
},
legend: {
display: false
}
};
var data = {
labels: aLabels,
datasets: [
// valori effettivi!
{
label: titolo,
backgroundColor: "rgba(54, 162, 235, 0.4)",
borderColor: "rgba(54, 162, 235, 1)",
borderWidth: 4,
pointBackgroundColor: "rgba(54, 100, 165, 1)",
pointRadius: 8,
data: aDatasets1
},
// verde scuro
{
backgroundColor: "rgba(34, 255, 34, 0.35)",
borderColor: "rgba(34, 255, 34, 1)",
borderWidth: 1,
data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
},
// verde
{
backgroundColor: "rgba(54, 255, 54, 0.35)",
borderColor: "rgba(54, 255, 54, 1)",
borderWidth: 1,
data: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
},
// giallo
{
backgroundColor: "rgba(255, 255, 54, 0.25)",
borderColor: "rgba(255, 255, 54, 1)",
borderWidth: 1,
data: [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]
},
// arancione
{
backgroundColor: "rgba(255, 135, 54, 0.15)",
borderColor: "rgba(255, 135, 54, 1)",
borderWidth: 1,
data: [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]
},
// rosso esterno
{
backgroundColor: "rgba(255, 54, 54, 0.05)",
borderColor: "rgba(255, 54, 54, 1)",
borderWidth: 1,
data: [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]
}
//// rosso
//{
// label: "",
// backgroundColor: "rgba(255, 54, 54, 0.35)",
// borderColor: "rgba(255, 54, 54, 1)",
// borderWidth: 1,
// data: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
//},
//// arancione
//{
// label: "",
// backgroundColor: "rgba(255, 135, 54, 0.25)",
// borderColor: "rgba(255, 135, 54, 1)",
// borderWidth: 1,
// data: [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]
//},
//// giallo
//{
// label: "",
// backgroundColor: "rgba(255, 255, 54, 0.15)",
// borderColor: "rgba(255, 255, 54, 1)",
// borderWidth: 1,
// data: [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]
//},
//// verde esterno
//{
// label: "",
// backgroundColor: "rgba(54, 255, 54, 0.05)",
// borderColor: "rgba(54, 255, 54, 1)",
// borderWidth: 1,
// data: [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]
//}
]
};
var radarChart = new Chart(ctx, {
type: 'radar',
data: data,
options: options
});
}
// errore in reload!
function OnErrorCall_(repo) {
alert("Errore recupero dati grafico!");
}
// effettuo plotting grafico!
function plotRadar() {
// caricamento pagina
$.ajax({
type: "POST",
url: "../Services/WS_data.asmx/simData",
data: "{ dataType: '<%=hfDSetType.Value %>', dataRif: '<%=hfDataRif.Value%>', nLimit: 10 }",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess_,
error: OnErrorCall_
});
//alert("Loaded 01!");
}
//// funzione di drawing ad OGNI pageload!
//function pageLoad() {
// plotRadar();
//}
</script>