89 lines
2.4 KiB
Plaintext
89 lines
2.4 KiB
Plaintext
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="mod_graphLine.ascx.cs" Inherits="PUB.WebUserContols.mod_graphLine" %>
|
|
|
|
<canvas id="LineChart" 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 PlotLineOnSuccess_(reponse) {
|
|
// recupero obj chart
|
|
var ctxLine = document.getElementById("LineChart");
|
|
var aDataLine = reponse.d;
|
|
var titoloLine = aDataLine[0];
|
|
var maxValLine = aDataLine[1];
|
|
var aLabelsLine = aDataLine[2];
|
|
var aDataLinesetsLine = aDataLine[3];
|
|
|
|
var options = {
|
|
responsive: true,
|
|
maintainAspectRatio: true,
|
|
scales: {
|
|
yAxes: [{
|
|
ticks: {
|
|
beginAtZero: true
|
|
}
|
|
}]
|
|
},
|
|
animation: {
|
|
duration: 0
|
|
},
|
|
legend: {
|
|
display: false
|
|
}
|
|
};
|
|
var data = {
|
|
labels: aLabelsLine,
|
|
datasets: [{
|
|
label: 'Bar Dataset',
|
|
data: [-1, -2, -3, -0, -1, -1, -3, -1, -2, -0, -2, -1, -1, -0, -3, -1, -1, -3, -1, -2]
|
|
}, {
|
|
label: titoloLine,
|
|
backgroundColor: "rgba(54, 162, 235, 0.4)",
|
|
borderColor: "rgba(54, 162, 235, 1)",
|
|
borderWidth: 4,
|
|
data: aDataLinesetsLine,
|
|
// Changes this dataset to become a line
|
|
type: 'line'
|
|
}],
|
|
//datasets: [
|
|
// // valori effettivi!
|
|
// {
|
|
// label: titoloLine,
|
|
// backgroundColor: "rgba(54, 162, 235, 0.4)",
|
|
// borderColor: "rgba(54, 162, 235, 1)",
|
|
// borderWidth: 4,
|
|
// data: aDataLinesetsLine
|
|
// }
|
|
//]
|
|
};
|
|
|
|
var LineChart = new Chart(ctxLine, {
|
|
type: 'bar',
|
|
data: data,
|
|
options: options
|
|
});
|
|
}
|
|
// errore in reload!
|
|
function PlotLineOnErrorCall_(repo) {
|
|
alert("Errore recupero dati grafico!");
|
|
}
|
|
// effettuo plotting grafico!
|
|
function plotLine() {
|
|
// caricamento pagina
|
|
$.ajax({
|
|
type: "POST",
|
|
url: "../Services/WS_data.asmx/simData",
|
|
data: "{ dataType: '<%=hfDSetType.Value %>', dataRif: '<%=hfDataRif.Value%>', nLimit: 20 }",
|
|
contentType: "application/json; charset=utf-8",
|
|
dataType: "json",
|
|
success: PlotLineOnSuccess_,
|
|
error: PlotLineOnErrorCall_
|
|
});
|
|
}
|
|
|
|
//// funzione di drawing ad OGNI pageload!
|
|
//function pageLoad() {
|
|
// plotLine();
|
|
//}
|
|
</script>
|