Files
GPW/GPW_Smart/WebUserControls/cmp_chart.ascx
T

131 lines
4.0 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;
// recupero obj chart
var ctx = document.getElementById('myChart').getContext('2d');
var chart = new Chart(ctx, {
//type: 'line',
type: 'scatter',
data: {
datasets: [{
label: 'Temp Rilevata',
//data = dataTS
data: [
//{ x: 0, y: 36.5 },
//{ x: 1, y: 35.5 },
//{ x: 2, y: 36.1 },
//{ x: 3, y: 36.2 },
//{ x: 4, y: 36.0 }
{ x: new Date('2020-08-10T00:00:00'), y: 36.5 },
{ x: new Date('2020-08-15T00:00:00'), y: 35.5 },
{ x: new Date('2020-08-22T00:00:00'), y: 36.1 },
{ x: new Date('2020-08-23T00:00:00'), y: 36.2 },
{ x: new Date('2020-08-29T00:00:00'), y: 36.0 }
//{ x: '2020-08-20T00:00:00', y: 36.5 },
//{ x: '2020-08-21T00: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-24T00:00:00', y: 36.0 }
]
}]
},
options: {
scales: {
xAxes: [{
//type: 'time',
//time: {
// unit: 'day'
//}
}]
}
}
});
//var myOptions = {
// scales: {
// xAxes: [{
// type: 'time',
// distribution: 'series'
// }]
// }
// //responsive: true,
// //maintainAspectRatio: true,
// //scale: {
// // ticks: {
// // beginAtZero: true,
// // max: 42,
// // min: 33
// // }
// //},
// //animation: {
// // duration: 0
// //},
// //legend: {
// // display: false
// //}
//};
//var dataTS = reponse.d;
//var myLineChart = new Chart(ctx, {
// type: 'scatter',
// //type: 'line',
// //data: dataTS,
// data: [{
// x: -10,
// y: 0
// }, {
// x: 0,
// y: 10
// }, {
// x: 10,
// y: 5
// }],
// options: {
// scales: {
// xAxes: [{
// type: 'linear',
// position: 'bottom'
// }]
// }
// }
// //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>