Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hello, I fixed the NetworkCollection compatibility... #14

Merged
merged 13 commits into from
Sep 2, 2015
56 changes: 45 additions & 11 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,19 @@ Very basic:

.. code-block:: html

<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<script src="src/netjsongraph.js"></script>
<script>d3.netJsonGraph("./resources/netjson.json");</script>
<!DOCTYPE html>
<html>
<head>
<link href="src/netjsongraph.css" rel="stylesheet">
<!-- theme can be easily customized via css -->
<link href="src/netjsongraph-theme.css" rel="stylesheet">
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<script src="src/netjsongraph.js"></script>
<script>d3.netJsonGraph("./resources/netjson.json");</script>
</body>
</html>

Show graph in a container:

Expand All @@ -61,6 +71,9 @@ Show graph in a container:
<html>
<head>
<meta charset="utf-8">
<link href="src/netjsongraph.css" rel="stylesheet">
<!-- theme can be easily customized via css -->
<link href="src/netjsongraph-theme.css" rel="stylesheet">
<style type="text/css">
body {
font-family: Arial, sans-serif;
Expand Down Expand Up @@ -104,8 +117,9 @@ Manipulate the graph as you prefer:
Styling
-------

The library at comes with a default styling, but you can disable by passing the option
``defaultStyle: false`` and you can customize it with CSS.
The library comes with a default theme and a default style (color) for nodes,
you can disable this by passing the option
``defaultStyle: false`` and define your own CSS rules.

Here's a fulle example of how to show green links and dark green nodes:

Expand All @@ -115,36 +129,56 @@ Here's a fulle example of how to show green links and dark green nodes:
<html>
<head>
<meta charset="utf-8">
<link href="src/netjsongraph.css" rel="stylesheet">
<!-- custom theme example -->
<style type="text/css">
body {
font-family: Arial, sans-serif;
font-size: 13px;
}

.node {
.njg-overlay{
width: auto;
height: auto;
min-width: 200px;
max-width: 400px;
border: 1px solid #000;
border-radius: 2px;
background: rgba(0, 0, 0, 0.7);
top: 10px;
right: 10px;
padding: 0 15px;
font-family: Arial, sans-serif;
font-size: 14px;
color: #fff
}

.njg-node {
fill: #008000;
fill-opacity: 0.8;
stroke: #008000;
stroke-width: 1px;
cursor: pointer;
}
.node:hover {
.njg-node:hover,
.njg-node.njg-open{
fill-opacity: 1;
}

.link {
.njg-link {
stroke: #00ff00;
stroke-width: 2;
stroke-opacity: .5;
cursor: pointer;
}
.link:hover{
.njg-link:hover,
.njg-link.njg-open{
stroke-width: 3;
stroke-opacity: 1
}

.tooltip {
background: rgba(0, 0, 0, 0.75);
.njg-tooltip {
background: rgba(0, 0, 0, 0.6);
color: #fff;
padding: 5px 10px;
border-radius: 3px;
Expand Down
25 changes: 3 additions & 22 deletions examples/custom-attributes.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,9 @@
<head>
<title>netjsongraph.js: NetJSON properties</title>
<meta charset="utf-8">
<style type="text/css">
.node {
stroke: #fff;
stroke-width: 1px;
stroke-opacity: 0.5;
}
.node:hover {
stroke: rgba(0, 0, 0, 0.5);
}

.link:hover{
stroke: #9f9fa4 !important;
stroke-width: 3 !important;
}

.tooltip {
background: rgba(0, 0, 0, 0.5);
color: #fff;
padding: 5px 10px;
border-radius: 3px;
}
</style>
<link href="../src/netjsongraph.css" rel="stylesheet">
<!-- theme can be easily customized via css -->
<link href="../src/netjsongraph-theme.css" rel="stylesheet">
</head>
<body>
<div id="network-graph"></div>
Expand Down
17 changes: 10 additions & 7 deletions examples/dark.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
<head>
<title>netjsongraph.js: Dark Colors</title>
<meta charset="utf-8">
<link href="../src/netjsongraph.css" rel="stylesheet">
<style type="text/css">
body {
font-family: Arial, sans-serif;
font-size: 13px;
background: #9f9fa4;
}

.overlay, .metadata{
.njg-overlay, .njg-metadata{
width: auto;
height: auto;
min-width: 200px;
Expand All @@ -26,7 +27,7 @@
color: #fff
}

.metadata{
.njg-metadata{
left: 10px;
right: auto;
max-width: 500px;
Expand All @@ -40,28 +41,30 @@
background-color: #3e3e3e;
}

.node {
.njg-node {
fill: #fff5cc;
stroke: #f1ec14;
stroke-width: 1px;
cursor: pointer;
}
.node:hover {
.njg-node:hover,
.njg-node.njg-open{
fill: #ffee00;
}

.link {
.njg-link {
stroke: #00ff00;
stroke-width: 2;
stroke-opacity: .5;
cursor: pointer;
}
.link:hover{
.njg-link:hover,
.njg-link.njg-open{
stroke-width: 3;
stroke-opacity: 1
}

.tooltip {
.njg-tooltip {
background: rgba(0, 0, 0, 0.5);
color: #fff;
padding: 5px 10px;
Expand Down
15 changes: 9 additions & 6 deletions examples/green.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
<head>
<title>netjsongraph.js: Green theme</title>
<meta charset="utf-8">
<link href="../src/netjsongraph.css" rel="stylesheet">
<style type="text/css">
body {
font-family: Arial, sans-serif;
font-size: 13px;
}

.overlay{
.njg-overlay{
width: auto;
height: auto;
min-width: 200px;
Expand All @@ -32,29 +33,31 @@
border: 1px solid #ccc;
}

.node {
.njg-node {
fill: #008000;
fill-opacity: 0.8;
stroke: #008000;
stroke-width: 1px;
cursor: pointer;
}
.node:hover {
.njg-node:hover,
.njg-node.njg-open{
fill-opacity: 1;
}

.link {
.njg-link {
stroke: #00ff00;
stroke-width: 2;
stroke-opacity: .5;
cursor: pointer;
}
.link:hover{
.njg-link:hover,
.njg-link.njg-open{
stroke-width: 3;
stroke-opacity: 1
}

.tooltip {
.njg-tooltip {
background: rgba(0, 0, 0, 0.6);
color: #fff;
padding: 5px 10px;
Expand Down
3 changes: 3 additions & 0 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
<head>
<title>netjsongraph.js: basic example</title>
<meta charset="utf-8">
<link href="../src/netjsongraph.css" rel="stylesheet">
<!-- theme can be easily customized via css -->
<link href="../src/netjsongraph-theme.css" rel="stylesheet">
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
Expand Down
116 changes: 116 additions & 0 deletions examples/netjson_networkcollection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
{
"type": "NetworkCollection",
"collection": [
{
"type": "NetworkCollection",
"protocol": "olsr",
"version": "0.6.6",
"revision": "5031a799fcbe17f61d57e387bc3806de",
"metric": "etx",
"router_id": "172.16.40.24",
"nodes": [
{
"id": "172.16.40.24"
},
{
"id": "172.16.40.60"
}
],
"links": [
{
"source": "172.16.40.24",
"target": "172.16.40.60",
"cost": 1,
"properties": {
"lq": 1,
"nlq": 0.497
}
}
]
},
{
"type": "NetworkCollection",
"protocol": "olsrv2",
"version": "0.8.0",
"revision": "v0.8.0-0-g31b63ec-dirty",
"router_id": "192.168.0.101",
"metric": "ff_dat_metric",
"nodes": [
{
"id": "192.168.0.101"
},
{
"id": "192.168.0.102"
},
{
"id": "192.168.0.103"
},
{
"id": "192.168.0.104"
}
],
"links": [
{
"source": "192.168.0.101",
"target": "192.168.0.102",
"cost": 2105088,
"cost_text": "1020 bit/s",
"properties": {
"in": 2105088,
"in_txt": "1020 bit/s"
}
},
{
"source": "192.168.0.102",
"target": "192.168.0.101",
"cost": 2105088,
"cost_text": "1020 bit/s",
"properties": {
"in": 2105088,
"in_txt": "1020 bit/s"
}
},
{
"source": "192.168.0.102",
"target": "192.168.0.103",
"cost": 2105088,
"cost_text": "1020 bit/s",
"properties": {
"in": 2105088,
"in_txt": "1020 bit/s"
}
},
{
"source": "192.168.0.103",
"target": "192.168.0.102",
"cost": 2105088,
"cost_text": "1020 bit/s",
"properties": {
"in": 2105088,
"in_txt": "1020 bit/s"
}
},
{
"source": "192.168.0.103",
"target": "192.168.0.104",
"cost": 2105088,
"cost_text": "1020 bit/s",
"properties": {
"in": 2105088,
"in_txt": "1020 bit/s"
}
},
{
"source": "192.168.0.104",
"target": "192.168.0.103",
"cost": 2105088,
"cost_text": "1020 bit/s",
"properties": {
"in": 2105088,
"in_txt": "1020 bit/s"
}
}
]
}
]
}
15 changes: 15 additions & 0 deletions examples/networkcollection.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<title>netjsongraph.js: Network Collection example</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="../src/netjsongraph.css" />
<link href="../src/netjsongraph-theme.css" rel="stylesheet">
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<script src="http://labratrevenge.com/d3-tip/javascripts/d3.tip.v0.6.3.js"></script>
<script src="../src/netjsongraph.js"></script>
<script>d3.netJsonGraph("netjson_networkcollection.json");</script>
</body>
</html>