Files
GPW/GPW_Smart/WebUserControls/cmp_chart.ascx
T

111 lines
3.0 KiB
Plaintext

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="cmp_chart.ascx.cs" Inherits="GPW_Smart.WebUserControls.cmp_chart" %>
<script src="https://cdn.jsdelivr.net/npm/chart.js@2.8.0"></script>
<canvas id="myChart"></canvas>
<asp:HiddenField runat="server" ID="hfIdxDip" />
<asp:HiddenField runat="server" ID="hfData" />
<script>
var ctx = document.getElementById('myChart').getContext('2d');
var chart = new Chart(ctx, {
// The type of chart we want to create
type: 'line',
// The data for our dataset
data: {
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
datasets: [{
label: 'My First dataset',
//backgroundColor: 'rgb(255, 99, 132)',
borderColor: 'rgb(255, 99, 132)',
data: [0, 10, 5, 2, 20, 30, 45]
}]
},
// Configuration options go here
options: {}
});
</script>
<%--<script>
// funzione eseguita se successo al caricamento
function OnSuccess_(reponse) {
// recupero obj chart
var ctx = document.getElementById("myChart");
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/1",
////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() {
plotTS();
}
</script>--%>