Browse Source

update frontend dependencies

main
Milan 6 months ago
parent
commit
f7d6d1f465
Signed by: petabyteboy GPG Key ID: A6DC6A7CB0B97859
  1. 17
      frontend/src/main.js

17
frontend/src/main.js

@ -31,16 +31,17 @@ const showError = (text, descr) => {
errorDescr.innerHTML = descr;
};
const renderNode = isShadow => (node, ctx, globalScale) => {
const renderNode = (node, color, ctx, globalScale) => {
const label = node.label.split('\n');
if (label.length < 2) label.push('');
const fontSize = 4;
ctx.font = `${fontSize}px Sans-Serif`;
ctx.font = `${fontSize}px sans-serif`;
const textWidth = Math.max(ctx.measureText(label[0]).width, ctx.measureText(label[1]).width);
const bckgDimensions = [textWidth, fontSize * 2].map(n => n + fontSize * 0.6); // some padding
if (isShadow) {
ctx.fillStyle = node.__indexColor;
// shadow canvas
if (color) {
ctx.fillStyle = color;
ctx.fillRect(node.x - bckgDimensions[0] / 2, node.y - bckgDimensions[1] / 2, ...bckgDimensions);
return;
}
@ -64,8 +65,6 @@ let routeNodes = [];
let firstNode = true;
const renderLink = (link, ctx, globalScale) => {
if (isShadow) return;
const start = link.source;
const end = link.target;
@ -163,10 +162,10 @@ const initGraph = (cfg) => {
}
})
.onRenderFramePost((ctx, scale) => {
if (hoverNode) renderNode(hoverNode, ctx, scale);
if (hoverNode) renderNode(hoverNode, null, ctx, scale);
})
.nodeCanvasObject(renderNode(false))
.nodePointerAreaPaint(renderNode(true));
.nodeCanvasObject((node, ctx, globalScale) => renderNode(node, null, ctx, globalScale))
.nodePointerAreaPaint(renderNode);
if (cfg.dedup) {
graph

Loading…
Cancel
Save