86 lines
2.4 KiB
Plaintext
86 lines
2.4 KiB
Plaintext
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="cmp_chart.ascx.cs" Inherits="GPW_Smart.WebUserControls.cmp_chart" %>
|
|
|
|
<canvas id="myChart"></canvas>
|
|
<asp:HiddenField runat="server" ID="hfIdxDip" />
|
|
<asp:HiddenField runat="server" ID="hfData" />
|
|
|
|
<script>
|
|
// funzione eseguita se successo al caricamento
|
|
function OnSuccess_(reponse) {
|
|
|
|
// recupero dati restituiti
|
|
var dataTS = reponse.d;
|
|
|
|
|
|
var myOptions = {
|
|
scales: {
|
|
xAxes: [{
|
|
type: 'time',
|
|
distribution: 'series'
|
|
}]
|
|
}
|
|
//responsive: true,
|
|
//maintainAspectRatio: true,
|
|
//scale: {
|
|
// ticks: {
|
|
// beginAtZero: true,
|
|
// max: 42,
|
|
// min: 33
|
|
// }
|
|
//},
|
|
,animation: {
|
|
duration: 200
|
|
},
|
|
//legend: {
|
|
// display: false
|
|
//}
|
|
};
|
|
|
|
// recupero obj chart
|
|
var ctx = document.getElementById('myChart').getContext('2d');
|
|
var chart = new Chart(ctx, {
|
|
type: 'line',
|
|
//type: 'scatter',
|
|
|
|
data: {
|
|
datasets: [{
|
|
label: 'Temperatura Rilevata',
|
|
//data = dataTS
|
|
data: [
|
|
{ x: '2020-08-10T00:00:00', y: 36.5 },
|
|
{ x: '2020-08-15T00:00:00', y: 35.5 },
|
|
{ x: '2020-08-22T00:00:00', y: 36.1 },
|
|
{ x: '2020-08-23T00:00:00', y: 36.2 },
|
|
{ x: '2020-08-29T00:00:00', y: 36.0 }
|
|
]
|
|
}]
|
|
},
|
|
options: myOptions
|
|
});
|
|
|
|
}
|
|
// errore in reload!
|
|
function OnErrorCall_(repo) {
|
|
alert("Errore recupero dati grafico!");
|
|
}
|
|
// effettuo plotting grafico!
|
|
function plotTS() {
|
|
// caricamento pagina
|
|
$.ajax({
|
|
type: "GET",
|
|
url: "api/TempRil/<%=hfIdxDip.Value %>",
|
|
//data: "{ dataRif: '<%=hfData.Value%>', numRec: 0 }",
|
|
contentType: "application/json; charset=utf-8",
|
|
dataType: "json",
|
|
success: OnSuccess_,
|
|
error: OnErrorCall_
|
|
});
|
|
}
|
|
|
|
// funzione di drawing ad OGNI pageload!
|
|
function pageLoad() {
|
|
// chiamo recupero dati + plot
|
|
plotTS();
|
|
}
|
|
</script>
|