Skip to content

Commit

Permalink
Merge 0bbfbed into 1606d69
Browse files Browse the repository at this point in the history
  • Loading branch information
totallynotvaishnav committed Aug 12, 2022
2 parents 1606d69 + 0bbfbed commit f4cae84
Show file tree
Hide file tree
Showing 30 changed files with 1,444 additions and 974 deletions.
2 changes: 1 addition & 1 deletion dist/netjsongraph.min.js

Large diffs are not rendered by default.

103 changes: 61 additions & 42 deletions examples/netjson-dateParse.html
Original file line number Diff line number Diff line change
@@ -1,51 +1,70 @@
<!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: 850px) {
.njg-date {
width: 100vw;
right: unset;
}
}
</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>
30 changes: 16 additions & 14 deletions examples/netjson-multipleInterfaces.html
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>
44 changes: 44 additions & 0 deletions examples/netjson-searchElements.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,55 @@
<html lang="en">
<head>
<title>netjsongraph.js: basic example</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta charset="utf-8" />
<!-- theme can be easily customized via css -->
<link href="../src/css/netjsongraph-theme.css" rel="stylesheet" />
<link href="../src/css/netjsongraph.css" rel="stylesheet" />
<style>
.njg-searchBtn {
border: none;
border-radius: 5px;
padding: 4px 8px;
}

.njg-searchInput {
padding: 4px;
border-radius: 5px;
border: none;
max-width: 70%;
}

.njg-searchContainer {
margin: 0 auto;
width: 80%;
text-align: center;
left: 0;
right: 0;
}

.njg-searchBtn {
border: none;
border-radius: 5px;
}

@media only screen and (max-width: 500px) {
.njg-searchInput {
width: 40%;
}
.njg-searchContainer {
width: 70%;
}
}

@media only screen and (max-width: 850px) and (min-width: 500px) {
.njg-searchInput {
width: 50%;
}
}
</style>
</head>

<body>
<script type="text/javascript" src="../dist/netjsongraph.min.js"></script>
<script type="text/javascript">
Expand Down
8 changes: 3 additions & 5 deletions examples/netjson-switchGraphMode.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<head>
<title>netjsongraph.js: basic example</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
rel="stylesheet"
href="https://unpkg.com/leaflet@1.8.0/dist/leaflet.css"
Expand All @@ -14,9 +15,6 @@
<link href="../src/css/netjsongraph-theme.css" rel="stylesheet" />
<link href="../src/css/netjsongraph.css" rel="stylesheet" />
<style type="text/css">
.njg-metadata {
left: 50px;
}
.leaflet-control-zoom {
top: 55px;
right: 1px;
Expand All @@ -27,8 +25,8 @@
<script type="text/javascript" src="../dist/netjsongraph.min.js"></script>
<script type="text/javascript">
/*
The demo is used to show how to switch the netjsongraph render mode -- `graph` or `map`.
*/
The demo is used to show how to switch the netjsongraph render mode -- `graph` or `map`.
*/
const map = new NetJSONGraph("./data/netjsonmap.json", {
render: "map",
switchMode: true,
Expand Down
24 changes: 22 additions & 2 deletions examples/netjson-switchRenderMode.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,36 @@
<head>
<title>netjsongraph.js: basic example</title>
<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" />
<style>
.switch-wrap input[type="checkbox"] {
height: 0;
width: 0;
left: unset;
pointer-events: none;
}

@media only screen and (max-width: 850px) {
.switch-wrap {
left: 0;
right: 0;
margin-left: auto;
margin-right: auto;
width: fit-content;
}
}
</style>
</head>

<body>
<script type="text/javascript" src="../dist/netjsongraph.min.js"></script>
<script type="text/javascript">
/*
The demo is used to show how to switch the netjsongraph render mode -- `svg` or `canvas`.
*/
The demo is used to show how to switch the netjsongraph render mode -- `svg` or `canvas`.
*/
const graph = new NetJSONGraph("./data/netjsonmap.json", {
onReady: function () {
switchRenderMode(this);
Expand Down
Loading

0 comments on commit f4cae84

Please sign in to comment.