-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
787 additions
and
348 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,77 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<head> | ||
<title>netjsongraph.js: basic example</title> | ||
<meta charset="utf-8"> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<!-- theme can be easily customized via css --> | ||
<link href="../src/css/netjsongraph-theme.css" rel="stylesheet"> | ||
<link href="../src/css/netjsongraph.css" rel="stylesheet"> | ||
</head> | ||
<body> | ||
<link href="../src/css/netjsongraph-theme.css" rel="stylesheet" /> | ||
<link href="../src/css/netjsongraph.css" rel="stylesheet" /> | ||
<style> | ||
.njg-date { | ||
height: fit-content; | ||
text-align: center; | ||
} | ||
|
||
@media only screen and (max-width: 650px) { | ||
.njg-date { | ||
bottom: 80px; | ||
width: 100vw; | ||
right: unset; | ||
} | ||
} | ||
|
||
@media only screen and (max-width: 850px) and (min-width: 650px) { | ||
.njg-date { | ||
bottom: 80px; | ||
} | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<script type="text/javascript" src="../dist/netjsongraph.min.js"></script> | ||
<script type="text/javascript"> | ||
/* | ||
The demo is used to show the use of the `dataParse` function. | ||
You can set the node or link property value `time`, we will call this function to parse the string in the element details defaultly. | ||
Of course you can also call directly. | ||
*/ | ||
// `graph` render defaultly. | ||
const graph = new NetJSONGraph("./data/netjsonmap.json", { | ||
// Convert to internal json format,add `time` field. | ||
prepareData: data => { | ||
data.nodes.map(node => { | ||
node.label = node.name; | ||
node.properties = node.properties || {}; | ||
node.properties.time = node.properties.time || "2000-01-01T00:00:00.000Z" | ||
}) | ||
data.links.map(link => { | ||
link.properties = link.properties || {}; | ||
link.properties.time = link.properties.time || "1999-12-31T23:59:59.999Z" | ||
}) | ||
}, | ||
}); | ||
|
||
graph.render(); | ||
/* | ||
The demo is used to show the use of the `dataParse` function. | ||
You can set the node or link property value `time`, we will call this function to parse the string in the element details defaultly. | ||
Of course you can also call directly. | ||
*/ | ||
// `graph` render defaultly. | ||
const graph = new NetJSONGraph("./data/netjsonmap.json", { | ||
// Convert to internal json format,add `time` field. | ||
prepareData: (data) => { | ||
data.nodes.map((node) => { | ||
node.label = node.name; | ||
node.properties = node.properties || {}; | ||
node.properties.time = | ||
node.properties.time || "2000-01-01T00:00:00.000Z"; | ||
}); | ||
data.links.map((link) => { | ||
link.properties = link.properties || {}; | ||
link.properties.time = | ||
link.properties.time || "1999-12-31T23:59:59.999Z"; | ||
}); | ||
}, | ||
}); | ||
|
||
graph.render(); | ||
|
||
(function addDateParse(_this) { | ||
const dateNode = document.createElement("span"), | ||
// Try to call the function directly. | ||
// The exec result must be [date, year, month, day, hour, minute, second, millisecond?] | ||
dateResult = _this.utils.dateParse({ | ||
dateString: "2019-04-03T05:06:54.000Z", | ||
parseRegular: | ||
/^([1-9]\d{3})-(\d{1,2})-(\d{1,2})T(\d{1,2}):(\d{1,2}):(\d{1,2})(?:\.(\d{1,3}))?Z$/, | ||
}); | ||
|
||
(function addDateParse(_this){ | ||
const dateNode = document.createElement("span"), | ||
// Try to call the function directly. | ||
// The exec result must be [date, year, month, day, hour, minute, second, millisecond?] | ||
dateResult = _this.utils.dateParse({ | ||
dateString: "2019-04-03T05:06:54.000Z", | ||
parseRegular: /^([1-9]\d{3})-(\d{1,2})-(\d{1,2})T(\d{1,2}):(\d{1,2}):(\d{1,2})(?:\.(\d{1,3}))?Z$/, | ||
}); | ||
|
||
dateNode.setAttribute("title", dateResult); | ||
dateNode.setAttribute("class", "njg-date"); | ||
dateNode.innerHTML = "Incoming Time: " + dateResult; | ||
_this.el.appendChild(dateNode); | ||
})(graph) | ||
dateNode.setAttribute("title", dateResult); | ||
dateNode.setAttribute("class", "njg-date"); | ||
dateNode.innerHTML = "Incoming Time: " + dateResult; | ||
_this.el.appendChild(dateNode); | ||
})(graph); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,29 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<head> | ||
<title>netjsongraph.js: basic example</title> | ||
<meta charset="utf-8"> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<!-- theme can be easily customized via css --> | ||
<link href="../src/css/netjsongraph-theme.css" rel="stylesheet"> | ||
<link href="../src/css/netjsongraph.css" rel="stylesheet"> | ||
</head> | ||
<body> | ||
<link href="../src/css/netjsongraph-theme.css" rel="stylesheet" /> | ||
<link href="../src/css/netjsongraph.css" rel="stylesheet" /> | ||
</head> | ||
|
||
<body> | ||
<script type="text/javascript" src="../dist/netjsongraph.min.js"></script> | ||
<script type="text/javascript"> | ||
/* | ||
/* | ||
The demo is used to show how to deal with the `multiple interfaces` in the NetJSON data. | ||
We provide a work file to process the data before rendering. | ||
This file provides functions to remove dirty data, deduplicate, handle multiple interfaces, add node links, add flatNodes and so on. | ||
You can also define related files yourself. | ||
*/ | ||
// `graph` render defaultly. | ||
const graph = new NetJSONGraph("./data/netjson-multipleInterfaces.json", { | ||
// Asynchronous processing of incoming data formats using WebWorker file. | ||
dealDataByWorker: "../src/js/netjsonWorker.js", | ||
}); | ||
graph.render(); | ||
// `graph` render defaultly. | ||
const graph = new NetJSONGraph("./data/netjson-multipleInterfaces.json", { | ||
// Asynchronous processing of incoming data formats using WebWorker file. | ||
dealDataByWorker: "../src/js/netjsonWorker.js", | ||
}); | ||
graph.render(); | ||
</script> | ||
</body> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.