drawChart(id: number, name: string, isMetric: boolean = false): void {
"use strict";
/// Get data from server
$.getJSON("/Api/PtPSiteData/" + id, function (data: any): void {
/// distance string
var hLabel: string = (isMetric ? "km" : "miles");
var vLabel: string = (isMetric ? "meters" : "feet");
var txLabel: string = data.report.TXSiteName;
var rxLabel: string = data.report.RXSiteName;
/// Build the chart data table
/*
* report
* Reference
* Profile
* Curvature
* Fresnal
* Fresnal60
*/
var table: google.visualization.DataTable = new google.visualization.DataTable();
table.addColumn("number", "x", "x");
table.addColumn("number", "Point-to-Point Profile", "Profile");
table.addColumn("number", "Line of Sight Path", "Reference");
table.addColumn("number", "First Fresnel Zone", "Fresnal");
table.addColumn("number", "60% of First Fresnel Zone", "Fresnal60");
table.addColumn({ type: "string", role: "annotation" });
for (var i: number = 0; i < data.Profile.length; i++) {
var label: string = null;
if (i === 0) {
label = txLabel;
} else if (i === data.Profile.length - 1) {
label = rxLabel;
}
table.addRow([data.Profile[i].X,
data.Profile[i].Y,
data.Reference[i].Y,
data.Fresnal[i].Y,
data.Fresnal60[i].Y,
label]);
}
/// Set chart options
var options: google.visualization.AreaChartOptions = {
title: "Path profile between TX and RX sites",
is3D: true,
hAxis: {
title: "Distance between Tx Site and Rx site (" + hLabel + ")",
titleTextStyle: { color: "#333" }
},
vAxis: {
title: "Normalized Height Referenced to LOS Path (" + vLabel + ")",
},
series: {
0: { color: "#6E9A3F" },
1: { color: "#DBAF00", areaOpacity: "0.0" },
2: { color: "#800080", areaOpacity: "0.0" },
3: { color: "#5895DB", areaOpacity: "0.0" }
},
annotation: {
5: { style: "letter" }
},
annotations: {
textStyle: {
bold: true,
italic: true,
color: "black"
}
}
};
/// Create the area chart
var chart: google.visualization.AreaChart = new google.visualization.AreaChart(document.getElementById(name));
/// Draw the chart
chart.draw(table, options);
}).fail(function (request: any, status: any, error: any): void {
alert(request.responseText);
});
}