-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4285 from GordonSmith/V3_GRAPH
feat: Upgrade graph, html and react to v3
- Loading branch information
Showing
86 changed files
with
3,023 additions
and
2,404 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,47 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Dev", | ||
"name": "test-browser", | ||
"type": "msedge", | ||
"request": "launch", | ||
"url": "file:///${workspaceRoot}/index.html", | ||
"runtimeArgs": [ | ||
"--allow-file-access-from-files", | ||
"--disable-web-security" | ||
"url": "http://localhost:8888", | ||
"webRoot": "${workspaceFolder}", | ||
"outFiles": [ | ||
"${workspaceFolder}/**/*.js", | ||
"!**/node_modules/**" | ||
], | ||
"webRoot": "${workspaceRoot}" | ||
}, | ||
{ | ||
"name": "lws", | ||
"type": "msedge", | ||
"name": "test-node", | ||
"type": "node", | ||
"request": "launch", | ||
"url": "http://localhost:8080/../packages/graph/index.html", | ||
"runtimeArgs": [ | ||
"--allow-file-access-from-files", | ||
"--disable-web-security" | ||
"run-script", | ||
"test-node" | ||
], | ||
"webRoot": "${workspaceRoot}" | ||
}, | ||
{ | ||
"type": "msedge", | ||
"request": "launch", | ||
"name": "index.md", | ||
"url": "${workspaceFolder}/../../website/index.html?debug=1#packages/graph/docs/index.md", | ||
"runtimeArgs": [ | ||
"--allow-file-access-from-files", | ||
"--disable-web-security" | ||
"runtimeExecutable": "npm", | ||
"skipFiles": [ | ||
"<node_internals>/**" | ||
], | ||
"outFiles": [ | ||
"${workspaceFolder}/**/*.js", | ||
"!**/node_modules/**" | ||
], | ||
"webRoot": "${workspaceFolder}/../../website" | ||
}, | ||
{ | ||
"type": "msedge", | ||
"name": "index.html", | ||
"request": "launch", | ||
"name": "http index.md", | ||
"url": "http://localhost:8080/${workspaceFolder}/../../website/index.html?debug=1#packages/graph/docs/index.md", | ||
"type": "msedge", | ||
"url": "file:///${workspaceFolder}/index.html", | ||
"runtimeArgs": [ | ||
"--allow-file-access-from-files", | ||
"--disable-web-security" | ||
], | ||
"webRoot": "${workspaceFolder}/../../website" | ||
"webRoot": "${workspaceFolder}", | ||
"outFiles": [ | ||
"${workspaceFolder}/**/*.js", | ||
"!**/node_modules/**" | ||
] | ||
} | ||
] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { browserTpl } from "@hpcc-js/esbuild-plugins"; | ||
import pkg from "./package.json" with { type: "json" }; | ||
|
||
// config --- | ||
await Promise.all([ | ||
browserTpl("src/index.ts", "dist/index", { | ||
keepNames: true, | ||
alias: { | ||
"d3-array": "@hpcc-js/common", | ||
"d3-brush": "@hpcc-js/common", | ||
"d3-collection": "@hpcc-js/common", | ||
"d3-color": "@hpcc-js/common", | ||
"d3-dispatch": "@hpcc-js/common", | ||
"d3-drag": "@hpcc-js/common", | ||
"d3-dsv": "@hpcc-js/common", | ||
"d3-ease": "@hpcc-js/common", | ||
"d3-format": "@hpcc-js/common", | ||
"d3-interpolate": "@hpcc-js/common", | ||
"d3-scale": "@hpcc-js/common", | ||
"d3-selection": "@hpcc-js/common", | ||
"d3-time-format": "@hpcc-js/common", | ||
"d3-transition": "@hpcc-js/common", | ||
"d3-zoom": "@hpcc-js/common" | ||
}, | ||
external: [ | ||
...Object.keys(pkg.dependencies), | ||
...Object.keys(pkg.peerDependencies), | ||
] | ||
}) | ||
]); |
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 |
---|---|---|
|
@@ -2,62 +2,149 @@ | |
<html> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<title>@hpcc-js/graph</title> | ||
|
||
<script> | ||
const isLocal = window.location.protocol === "file:" || window.location.origin.indexOf("http://localhost") === 0; | ||
if (isLocal) { | ||
document.write('<link rel="stylesheet" href="../../packages/common/font-awesome/css/font-awesome.min.css">'); | ||
document.write('<link rel="stylesheet" href="./src/Graph.css">'); | ||
document.write('<link rel="stylesheet" href="./src/Vertex.css">'); | ||
document.write('<link rel="stylesheet" href="./src/Edge.css">'); | ||
document.write('<link rel="stylesheet" href="./src/Subgraph.css">'); | ||
document.write('<script type="text/javascript" src="../../packages/loader/dist/index.js"><' + '/script>'); | ||
} else { | ||
document.write('<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@hpcc-js/common/font-awesome/css/font-awesome.min.css">'); | ||
document.write('<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@hpcc-js/loader"><' + '/script>'); | ||
<title>Home</title> | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
margin: 0; | ||
padding: 0; | ||
background-color: #f0f0f0; | ||
} | ||
</script> | ||
|
||
<script> | ||
var hpccLoader = window["@hpcc-js/loader"]; | ||
</script> | ||
h1 { | ||
text-align: center; | ||
margin-top: 50px; | ||
} | ||
|
||
<style> | ||
#placeholder, | ||
.placeholder { | ||
position: absolute; | ||
left: 8px; | ||
top: 8px; | ||
right: 8px; | ||
bottom: 8px; | ||
#placeholder2 { | ||
width: 100%; | ||
height: 500px; | ||
background-color: #fff; | ||
margin-top: 20px; | ||
} | ||
</style> | ||
|
||
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@hpcc-js/[email protected]/dist/index.min.js"></script> | ||
<script type="importmap"> | ||
{ | ||
"imports": { | ||
"@hpcc-js/util": "../util/dist/index.js", | ||
"@hpcc-js/common": "../common/dist/index.js", | ||
"@hpcc-js/api": "../api/dist/index.js", | ||
"@hpcc-js/chart": "../chart/dist/index.js", | ||
"@hpcc-js/codemirror": "../codemirror/dist/index.js", | ||
"@hpcc-js/comms": "../comms/dist/index.js", | ||
"@hpcc-js/dgrid": "../dgrid/dist/index.js", | ||
"@hpcc-js/react": "../react/dist/index.js", | ||
"@hpcc-js/html": "../html/dist/index.js", | ||
"@hpcc-js/graph": "../graph/dist/index.js", | ||
"xreact":"../../node_modules/preact/compat/dist/compat.module.js", | ||
"xreact-dom/client":"../../node_modules/preact/compat/client.mjs", | ||
"xpreact":"../../node_modules/preact/dist/preact.module.js", | ||
"xpreact/compat":"../../node_modules/preact/compat/dist/compat.module.js", | ||
"xpreact/hooks":"../../node_modules/preact/hooks/dist/hooks.module.js" | ||
} | ||
} | ||
</script> | ||
<link rel="stylesheet" href="../api/dist/index.css"> | ||
<link rel="stylesheet" href="../common/dist/index.css"> | ||
<link rel="stylesheet" href="../html/dist/index.css"> | ||
<link rel="stylesheet" href="../react/dist/index.css"> | ||
<link rel="stylesheet" href="./dist/index.css"> | ||
</head> | ||
|
||
<body onresize="doResize()"> | ||
<div id="placeholder"> | ||
</div> | ||
<script> | ||
var app; | ||
hpccLoader.amd().then(function (require) { | ||
require(["lib-umd/__tests__/index.js"], function (testMod) { | ||
<h1>ESM Quick Test</h1> | ||
<div id="placeholder"></div> | ||
<script type="module"> | ||
import { SankeyGraph } from "@hpcc-js/graph"; | ||
|
||
new SankeyGraph() | ||
.vertexColumns(["category", "id", "label"]) | ||
.vertices([ | ||
[0, 0, "Year 1"], | ||
[0, 1, "Year 2"], | ||
[0, 2, "Year 3"], | ||
[0, 3, "Year 4"], | ||
[1, 4, "Math"], | ||
[1, 5, "English"], | ||
[1, 6, "Geometry"], | ||
[1, 7, "Science"], | ||
]) | ||
.edgeColumns(["source", "target", "weight"]) | ||
.edges([ | ||
[0, 4, 1], | ||
[1, 4, 1], | ||
[2, 4, 1], | ||
[3, 4, 1], | ||
[0, 5, 1], | ||
[1, 5, 1], | ||
[2, 6, 1], | ||
[3, 6, 1], | ||
[1, 7, 1], | ||
[2, 7, 1], | ||
[3, 7, 1], | ||
]) | ||
.target("placeholder") | ||
.render() | ||
; | ||
</script> | ||
<div id="placeholder2"></div> | ||
<script type="module"> | ||
import { Graph2 } from "@hpcc-js/graph"; | ||
const nodeCount = 500; | ||
|
||
app = new testMod.Test() | ||
.target("placeholder") | ||
.wasmFolder(isLocal ? "https://cdn.jsdelivr.net/npm/@hpcc-js/wasm/dist" : "./dist") | ||
.render(); | ||
const categories = [ | ||
{ id: 0, imageChar: "fa-user" }, | ||
{ id: 1, imageChar: "fa-home" } | ||
]; | ||
|
||
new Graph2() | ||
.categories(categories) | ||
.data(createData()) | ||
.target("placeholder2") | ||
.layout("ForceDirected") | ||
.applyScaleOnLayout(true) | ||
.allowDragging(false) | ||
.render() | ||
; | ||
|
||
function createData() { | ||
const rawData = { | ||
"nodes": Array.from({ length: nodeCount }, (_, i) => { | ||
return { "name": i + 1, "type": "number" } | ||
}), | ||
"links": Array.from({ length: nodeCount }, (_, i) => { | ||
return { "source": Math.floor(Math.sqrt(i)), "target": i }; | ||
}).slice(1) | ||
}; | ||
const vertices = rawData.nodes.map(function (node, idx) { | ||
return { | ||
categoryID: 0, | ||
id: idx, | ||
text: "" + node.name, | ||
textFontFamily: "monospace" | ||
}; | ||
}); | ||
}); | ||
return { | ||
vertices: vertices, | ||
edges: rawData.links.map(function (link, idx) { | ||
return { | ||
id: idx, | ||
source: vertices[link.source], | ||
target: vertices[link.target], | ||
label: link.name, | ||
fontFamily: "monospace" | ||
}; | ||
}), | ||
}; | ||
} | ||
|
||
</script> | ||
<script> | ||
function doResize() { | ||
if (app) { | ||
app | ||
.resize() | ||
.lazyRender(); | ||
} | ||
window.__widget?.resize()?.render(); | ||
} | ||
</script> | ||
</body> | ||
|
Oops, something went wrong.