altre prove x conversione array json...
This commit is contained in:
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -41,8 +41,8 @@ namespace MoonPro.WS
|
||||
{
|
||||
id = i,
|
||||
content = string.Format("Random data {0}", i),
|
||||
start = lastDate,
|
||||
end = lastDate.AddHours(random.Next(maxMinutes)),
|
||||
start = lastDate.ToShortDateString(),
|
||||
end = lastDate.AddHours(random.Next(maxMinutes)).ToShortDateString(),
|
||||
group = "1",
|
||||
className = ""
|
||||
};
|
||||
@@ -65,8 +65,8 @@ namespace MoonPro.WS
|
||||
{
|
||||
id = i,
|
||||
content = string.Format("Random data {0}", i),
|
||||
start = lastDate,
|
||||
end = lastDate.AddHours(random.Next(maxMinutes)),
|
||||
start = lastDate.ToShortDateString(),
|
||||
end = lastDate.AddHours(random.Next(maxMinutes)).ToShortDateString(),
|
||||
group = "1",
|
||||
className = ""
|
||||
};
|
||||
|
||||
+54
-16
@@ -9,21 +9,54 @@
|
||||
<script type="text/javascript">
|
||||
// vedere: http://visjs.org/docs/timeline/
|
||||
|
||||
//$(document).ready(function () {
|
||||
// $.ajax({
|
||||
// type: "GET",
|
||||
// url: "/WS/MPData.asmx/randomData",
|
||||
// contentType: "application/json; charset=utf-8",
|
||||
// dataType: "json",
|
||||
// success: ChartVis,
|
||||
// error: OnError
|
||||
// });
|
||||
$(document).ready(function () {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/WS/MPData.asmx/randomData",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "text",
|
||||
success: ChartVis,
|
||||
error: OnError
|
||||
});
|
||||
|
||||
// function ChartVis(response) {
|
||||
// test conversione json
|
||||
//var dataBefore = [{ '2015-04-08T17:12:05+00:00': 103.7 }, { '2015-04-08T17:13:05+00:00': 109.5 }, { '2015-04-08T17:14:05+00:00': 106 }, { '2015-04-08T17:15:05+00:00': 112.6 }];
|
||||
|
||||
//var dataAfter = [];
|
||||
|
||||
//for (var i = 0; i < dataBefore.length; i++) {
|
||||
// var item = dataBefore[i];
|
||||
// for (date in item) {
|
||||
// dataAfter.push({ x: date, y: item[date] });
|
||||
// }
|
||||
//}
|
||||
|
||||
//console.log(dataAfter);
|
||||
|
||||
// var container = document.getElementById('visualization');
|
||||
////added below for display the output
|
||||
//container.append(JSON.stringify(dataAfter));
|
||||
|
||||
function ChartVis(response) {
|
||||
// DOM element where the Timeline will be attached
|
||||
var container = document.getElementById('visualization');
|
||||
//console.log(response);
|
||||
var output = response.replace("{\"d\":null}", "");
|
||||
console.log(output);
|
||||
|
||||
|
||||
//for (var i = 0; i < output.length; i++) {
|
||||
// var item = output[i];
|
||||
// for (date in item) {
|
||||
// console.log(item);
|
||||
//dataAfter.push({ x: date, y: item[date] });
|
||||
// }
|
||||
//}
|
||||
|
||||
//console.log(JSON.parse(output[0]));
|
||||
//console.log(response.responseText);
|
||||
// Create a DataSet (allows two way data-binding)
|
||||
//var items = new vis.DataSet(response);
|
||||
//var items = new vis.DataSet(JSON.parse(response.responseText));
|
||||
var items = new vis.DataSet([
|
||||
{ id: 1, content: 'item 1', start: '2018-04-20 00:00:00', end: '2018-04-24 23:59:59', group: '1', className: 'sv' }
|
||||
, { id: 2, content: 'item 2', start: '2018-04-14 00:00:00', end: '2018-04-15 23:59:59', group: '1', className: 'sg' }
|
||||
@@ -51,11 +84,16 @@
|
||||
};
|
||||
// Create a Timeline
|
||||
var timeline = new vis.Timeline(container, items, groups, options);
|
||||
// }
|
||||
// function OnError(response) {
|
||||
// alert("Error !");
|
||||
// }
|
||||
//})
|
||||
}
|
||||
function OnError(response) {
|
||||
//alert("Error !");
|
||||
console.log(response);
|
||||
console.log(response.responseText);
|
||||
//console.log(JSON.parse(response.responseText));
|
||||
var container = document.getElementById('visualization');
|
||||
container.append(response.responseText);
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
+2
-2
@@ -623,11 +623,11 @@ public class visjsDsItem
|
||||
/// <summary>
|
||||
/// Inizio dell'evento
|
||||
/// </summary>
|
||||
public DateTime start;
|
||||
public string start;
|
||||
/// <summary>
|
||||
/// Fine dell'evento
|
||||
/// </summary>
|
||||
public DateTime end;
|
||||
public string end;
|
||||
/// <summary>
|
||||
/// Gruppo dell'item
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user