88 lines
2.7 KiB
Plaintext
88 lines
2.7 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" />
|
|
|
|
<div class="row">
|
|
<div class="col-6 text-right">Periodo</div>
|
|
<div class="col-6">
|
|
<asp:DropDownList runat="server" ID="ddlMaxNum" AutoPostBack="true">
|
|
<asp:ListItem Text="1 mese" Value="30"></asp:ListItem>
|
|
<asp:ListItem Text="2 mesi" Value="60"></asp:ListItem>
|
|
<asp:ListItem Text="3 mesi" Value="90"></asp:ListItem>
|
|
<asp:ListItem Text="6 mesi" Value="180"></asp:ListItem>
|
|
<asp:ListItem Text="1 anno" Value="366"></asp:ListItem>
|
|
<asp:ListItem Text="Tutto" Value="0"></asp:ListItem>
|
|
</asp:DropDownList>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
// funzione eseguita se successo al caricamento
|
|
function OnSuccess_(reponse) {
|
|
|
|
// recupero dati restituiti
|
|
var dataTS = reponse;
|
|
|
|
|
|
var myOptions = {
|
|
scales: {
|
|
xAxes: [{
|
|
type: 'time',
|
|
distribution: 'linear',
|
|
}]
|
|
}
|
|
//responsive: true,
|
|
//maintainAspectRatio: true,
|
|
, animation: {
|
|
duration: 200
|
|
},
|
|
//legend: {
|
|
// display: false
|
|
//}
|
|
};
|
|
|
|
//console.log('Recieved our data', dataTS);
|
|
|
|
// recupero obj chart
|
|
var ctx = document.getElementById('myChart').getContext('2d');
|
|
var chart = new Chart(ctx, {
|
|
type: 'line',
|
|
data: {
|
|
datasets: [{
|
|
//backgroundColor: 'rgb(180,180,180)',
|
|
borderColor: 'rgb(60, 180, 120)',
|
|
lineTension: 0,
|
|
label: 'Temperatura Rilevata',
|
|
data: dataTS
|
|
}]
|
|
},
|
|
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 %>?date=<%=hfData.Value%>&numRec=<%=ddlMaxNum.SelectedValue%>",
|
|
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>
|