add the cluster visualisation to the server

This commit is contained in:
Andreas Zweili 2018-07-26 19:32:05 +02:00
parent a0b870d476
commit 156c488b9e
34 changed files with 61667 additions and 19 deletions

View File

@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Server.DB;
namespace Server.Models
{
public class ClusterData
{
private List<Person> Doctors { get; set; }
private List<City> Cities { get; set; }
public ClusterData()
{
DoctorDB doctorDB = new DoctorDB();
CityDB cityDB = new CityDB();
this.Doctors = new List<Person>(doctorDB.GetAllDoctors());
this.Cities = new List<City>(cityDB.GetAllCities());
}
public List<Node> GenerateNodes()
{
List<Node> Nodes = new List<Node>();
foreach (var doctor in this.Doctors)
{
Node node = new Node
{
id = doctor.PersonID,
label = doctor.FirstName + " " + doctor.LastName,
cid = doctor.City.ZipCode
};
Nodes.Add(node);
}
int counter = 0;
foreach (var city in this.Cities)
{
Node node = new Node
{
id = city.ZipCode,
label = city.Name,
cid = city.ZipCode
};
Nodes.Add(node);
counter++;
}
return Nodes;
}
public List<Edge> GenerateEdges()
{
List<Edge> Edges = new List<Edge>();
foreach (var doctor in this.Doctors)
{
Edge edge = new Edge
{
from = doctor.City.ZipCode,
to = doctor.PersonID
};
Edges.Add(edge);
}
return Edges;
}
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Server.Models
{
public class Edge
{
public int from { get; set; }
public int to { get; set; }
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Server.Models
{
public class Node
{
public int id { get; set; }
public string label { get; set; }
public int cid { get; set; }
}
}

View File

@ -55,6 +55,9 @@
<HintPath>..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Web.DynamicData" />
@ -116,11 +119,14 @@
</Compile>
<Compile Include="IService.cs" />
<Compile Include="Models\City.cs" />
<Compile Include="Helper\ClusterData.cs" />
<Compile Include="Models\Country.cs" />
<Compile Include="Models\Doctor.cs" />
<Compile Include="Models\Edge.cs" />
<Compile Include="Models\Exam.cs" />
<Compile Include="Models\FoodPlace.cs" />
<Compile Include="Models\Gender.cs" />
<Compile Include="Models\Node.cs" />
<Compile Include="Models\PatientAtFoodPlace.cs" />
<Compile Include="Models\Person.cs" />
<Compile Include="Models\Salutation.cs" />

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

47
Server/Server/Static/visjs/vis.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -3,13 +3,40 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<head>
<script type="text/javascript" src="Static/visjs/vis.js"></script>
<link href="Static/visjs/vis.css" rel="stylesheet" type="text/css" />
<style type="text/css">
#mynetwork {
width: 1500px;
height: 900px;
border: 1px solid lightgray;
background-color: black
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
<div id="mynetwork"></div>
<script type="text/javascript">
// create an array with nodes
var nodes = new vis.DataSet(<%=this.nodes%>);
// create an array with edges
var edges = new vis.DataSet(<%=this.edges%>);
// create a network
var container = document.getElementById('mynetwork');
// provide the data in the vis format
var data = {
nodes: nodes,
edges: edges
};
var options = {};
// initialize your network!
var network = new vis.Network(container, data, options);
</script>
</body>
</html>

View File

@ -1,11 +1,21 @@
using System;
using System.Collections.Generic;
using Server.DB;
using Server.Models;
using Server.Helper;
using Newtonsoft.Json;
namespace Server
{
public partial class home : System.Web.UI.Page
{
protected string nodes { get; set; }
protected string edges { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
ClusterData cd = new ClusterData();
this.nodes = JsonConvert.SerializeObject(cd.GenerateNodes());
this.edges = JsonConvert.SerializeObject(cd.GenerateEdges());
}
}

View File

@ -7,20 +7,9 @@
// </auto-generated>
//------------------------------------------------------------------------------
namespace Server
{
namespace Server {
public partial class home
{
/// <summary>
/// form1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
public partial class home {
}
}

View File

@ -3,4 +3,5 @@
<package id="EntityFramework" version="6.2.0" targetFramework="net461" />
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.8" targetFramework="net461" />
<package id="Microsoft.Net.Compilers" version="2.8.2" targetFramework="net461" developmentDependency="true" />
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net461" />
</packages>