usando la parte "on error" della lettura ajax DISEGNA CORRETTAMENTE...
This commit is contained in:
@@ -30,22 +30,40 @@ namespace MoonPro.WS
|
||||
Context.Response.Clear();
|
||||
Context.Response.ContentType = "application/json";
|
||||
// genero numVal valori random inizio/fine...
|
||||
int numVal = 10;
|
||||
int maxMinutes = 60;
|
||||
int numVal = 100;
|
||||
int maxMinutes = 30;
|
||||
Random random = new Random();
|
||||
visjsDsItem[] items = new visjsDsItem[numVal];
|
||||
DateTime lastDate = DateTime.Now.AddDays(-7);
|
||||
DateTime endDate;
|
||||
int lancio = 0;
|
||||
string currCSS = "sv";
|
||||
for (int i = 0; i < numVal; i++)
|
||||
{
|
||||
lancio = random.Next(10);
|
||||
if(lancio<=7)
|
||||
{
|
||||
currCSS = "sv";
|
||||
}
|
||||
else if (lancio <=8)
|
||||
{
|
||||
currCSS = "sg";
|
||||
}
|
||||
else
|
||||
{
|
||||
currCSS = "sr";
|
||||
}
|
||||
endDate = lastDate.AddHours(random.Next(maxMinutes));
|
||||
items[i] = new visjsDsItem()
|
||||
{
|
||||
id = i,
|
||||
content = string.Format("Random data {0}", i),
|
||||
start = lastDate.ToShortDateString(),
|
||||
end = lastDate.AddHours(random.Next(maxMinutes)).ToShortDateString(),
|
||||
start = lastDate.ToString("yyyy-MM-dd HH:mm"),
|
||||
end = endDate.ToString("yyyy-MM-dd HH:mm"),
|
||||
group = "1",
|
||||
className = ""
|
||||
className = currCSS
|
||||
};
|
||||
lastDate = endDate;
|
||||
}
|
||||
Context.Response.Write(js.Serialize(items));
|
||||
}
|
||||
@@ -65,8 +83,8 @@ namespace MoonPro.WS
|
||||
{
|
||||
id = i,
|
||||
content = string.Format("Random data {0}", i),
|
||||
start = lastDate.ToShortDateString(),
|
||||
end = lastDate.AddHours(random.Next(maxMinutes)).ToShortDateString(),
|
||||
start = lastDate.ToString("yyyy-MM-dd HH:mm"),
|
||||
end = lastDate.AddHours(random.Next(maxMinutes)).ToString("yyyy-MM-dd HH:mm"),
|
||||
group = "1",
|
||||
className = ""
|
||||
};
|
||||
|
||||
+30
-6
@@ -14,7 +14,7 @@
|
||||
type: "GET",
|
||||
url: "/WS/MPData.asmx/randomData",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "text",
|
||||
dataType: "json",
|
||||
success: ChartVis,
|
||||
error: OnError
|
||||
});
|
||||
@@ -45,11 +45,12 @@
|
||||
console.log(output);
|
||||
|
||||
|
||||
//var dataAfter = [];
|
||||
//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] });
|
||||
// dataAfter.push({ x: date, y: item[date] });
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -86,12 +87,35 @@
|
||||
var timeline = new vis.Timeline(container, items, groups, options);
|
||||
}
|
||||
function OnError(response) {
|
||||
//alert("Error !");
|
||||
console.log(response);
|
||||
console.log(response.responseText);
|
||||
var output = response.responseText.replace("{\"d\":null}", "");
|
||||
var items = JSON.parse(output);
|
||||
//console.log(items);
|
||||
|
||||
|
||||
//console.log(JSON.parse(response.responseText));
|
||||
var container = document.getElementById('visualization');
|
||||
container.append(response.responseText);
|
||||
|
||||
// gruppi
|
||||
var groups = [
|
||||
{
|
||||
id: 1
|
||||
, content: 'Macc 1'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
content: 'Macc 2'
|
||||
// Optional: a field 'className', 'style', 'order', [properties]
|
||||
}
|
||||
// more groups...
|
||||
];
|
||||
// Configuration for the Timeline
|
||||
var options = {
|
||||
stack: false
|
||||
};
|
||||
// Create a Timeline
|
||||
var timeline = new vis.Timeline(container, items, groups, options);
|
||||
|
||||
//container.append(response.responseText);
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user