Skip to content

Commit f60f8c2

Browse files
authored
Merge pull request #14 from aarkue/fix/weird-ocel-graph-font
Fix font rendering bug in AppImage built in GH Action/Docker Container
2 parents f99fd27 + 0b86c9b commit f60f8c2

File tree

3 files changed

+58
-28
lines changed

3 files changed

+58
-28
lines changed

frontend/src/routes/OcelGraphViewer.tsx

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { OcelInfoContext } from "@/App";
22
import { BackendProviderContext } from "@/BackendProviderContext";
33
import { Button } from "@/components/ui/button";
4-
import { Checkbox } from "@/components/ui/checkbox";
54
import { Input } from "@/components/ui/input";
65
import { Label } from "@/components/ui/label";
76
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
@@ -15,10 +14,9 @@ import ForceGraph2D, {
1514
type NodeObject,
1615
} from "react-force-graph-2d";
1716
import toast from "react-hot-toast";
18-
import { CgUndo } from "react-icons/cg";
19-
import { LuAsterisk, LuClipboardCopy, LuUndo, LuUndo2 } from "react-icons/lu";
17+
import { LuClipboardCopy, LuUndo2 } from "react-icons/lu";
2018
import { MdOutlineZoomInMap } from "react-icons/md";
21-
import { PiInfoBold, PiInfoFill } from "react-icons/pi";
19+
import { PiInfoBold } from "react-icons/pi";
2220
import { TbFocusCentered } from "react-icons/tb";
2321

2422
import AutoSizer from "react-virtualized-auto-sizer";
@@ -83,8 +81,8 @@ export default function OcelGraphViewer({
8381

8482
useEffect(() => {
8583
setTimeout(() => {
86-
graphRef.current?.zoomToFit();
87-
// graphRef.current?.zoomToFit(200, 100);
84+
// graphRef.current?.zoomToFit();
85+
graphRef.current?.zoomToFit(200, 100);
8886
}, 300);
8987
}, [data]);
9088

@@ -161,7 +159,23 @@ export default function OcelGraphViewer({
161159
<GraphOptions options={options} setOptions={setOptions} initialGrapOptions={initialGrapOptions}
162160
setGraphData={(gd) => {
163161
prevGraphDataRef.current = undefined;
164-
graphRef.current!.d3Force("link")!.distance(10);
162+
const link = graphRef.current!.d3Force("link")!;
163+
const charge =
164+
graphRef.current!.d3Force("charge")!;
165+
166+
// link.distance(100);
167+
// link.strength(0.6);
168+
charge.strength(-5000);
169+
// charge.distanceMax(500);
170+
// charge.distanceMin(10);
171+
172+
// graphRef.current!.d3Force("link")!.distance(300);
173+
174+
// graphRef.current!.d3Force('charge')!.strength(-1);
175+
// graphRef.current!.d3Force('charge')!.distanceMax(1010);
176+
// graphRef.current!.d3Force('charge')!.distanceMin(110);
177+
178+
console.log(graphRef.current!.d3Force);
165179

166180
if (gd === undefined) {
167181
setGraphData({ nodes: [], links: [] });
@@ -239,14 +253,18 @@ export default function OcelGraphViewer({
239253
graphData={data}
240254
width={width}
241255
height={height}
256+
// d3AlphaMin={0.01}
257+
// d3AlphaDecay={0.025}
258+
warmupTicks={5}
259+
// cooldownTicks={100}
242260
nodeAutoColorBy={"type"}
243261
linkColor={() => "#d6d6d6"}
244262
backgroundColor="white"
245-
linkWidth={(link) => (highlightLinks.has(link) ? 5 : 2)}
263+
linkWidth={(link) => (highlightLinks.has(link) ? 4 : 3)}
246264
linkDirectionalParticleColor={() => "#556166"}
247265
linkDirectionalParticles={4}
248266
linkDirectionalParticleWidth={(link) =>
249-
highlightLinks.has(link) ? 4 : 0
267+
highlightLinks.has(link) ? 8 : 0
250268
}
251269
onNodeHover={handleNodeHover}
252270
onLinkHover={handleLinkHover}
@@ -259,24 +277,25 @@ export default function OcelGraphViewer({
259277
} (${"time" in x ? "Event" : "Object"})</span></div>`
260278
}
261279
nodeCanvasObject={(node, ctx) => {
280+
262281
if (node.x === undefined || node.y === undefined) {
263282
return;
264283
}
265284
const isFirstNode = node.id === graphData?.nodes[0].id;
266-
let width = 4;
267-
let height = 4;
285+
let width = 40;
286+
let height = 40;
268287
const fillStyle = isFirstNode
269288
? node.color
270289
: node.color + "74";
271-
ctx.lineWidth = isFirstNode ? 0.4 : 0.2;
290+
ctx.lineWidth = 10 * (isFirstNode ? 0.4 : 0.2);
272291
ctx.strokeStyle = highlightNodes.has(node)
273292
? "black"
274293
: isFirstNode
275294
? "#515151"
276295
: node.color;
277296
if ("time" in node) {
278-
width = 7;
279-
height = 7;
297+
width = 70;
298+
height = 70;
280299
ctx.beginPath();
281300
ctx.fillStyle = "white";
282301
ctx.roundRect(
@@ -314,11 +333,10 @@ export default function OcelGraphViewer({
314333
// Maybe because of the very small font size?
315334

316335
// if ((window as any).__TAURI__ === undefined) {
317-
let fontSize = 1;
318-
ctx.font
319-
ctx.font = `${fontSize}px Inter, system-ui, Avenir, Helvetica, Arial, sans-serif`;
336+
let fontSize = 10;
337+
ctx.font = `${fontSize}px Inter`;
320338
const label = node.id;
321-
const maxLength = 13;
339+
const maxLength = 12;
322340
const text =
323341
label.length > maxLength
324342
? label.substring(0, maxLength - 3) + "..."
@@ -327,8 +345,9 @@ export default function OcelGraphViewer({
327345

328346
ctx.textAlign = "center";
329347
ctx.textBaseline = "bottom";
348+
ctx.fontKerning = "none";
330349
ctx.fillText(text, node.x, node.y);
331-
fontSize = 0.8;
350+
fontSize = 8;
332351
ctx.font = `${fontSize}px Inter, system-ui, Avenir, Helvetica, Arial, sans-serif`;
333352
ctx.fillStyle = "#3f3f3f";
334353
const typeText =

frontend/tsconfig.json

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,41 @@
11
{
22
"compilerOptions": {
3-
"target": "ES2020",
3+
"target": "ESNext",
44
"useDefineForClassFields": true,
5-
"lib": ["es2021", "DOM", "DOM.Iterable"],
5+
"lib": [
6+
"es2021",
7+
"DOM",
8+
"DOM.Iterable",
9+
"ESNext"
10+
],
611
"module": "ESNext",
712
"skipLibCheck": true,
813
"rootDir": "./",
9-
1014
/* Bundler mode */
1115
"moduleResolution": "bundler",
1216
"allowImportingTsExtensions": true,
1317
"resolveJsonModule": true,
1418
"isolatedModules": true,
1519
"noEmit": true,
1620
"jsx": "react-jsx",
17-
1821
/* Linting */
1922
"strict": true,
2023
"noUnusedLocals": false,
2124
"noUnusedParameters": false,
2225
"noFallthroughCasesInSwitch": true,
2326
"baseUrl": "./",
2427
"paths": {
25-
"@/*": ["./src/*"]
28+
"@/*": [
29+
"./src/*"
30+
]
2631
}
2732
},
28-
"include": ["src"],
29-
"references": [{ "path": "./tsconfig.node.json" }]
30-
}
33+
"include": [
34+
"src"
35+
],
36+
"references": [
37+
{
38+
"path": "./tsconfig.node.json"
39+
}
40+
]
41+
}

tauri/src-tauri/tauri.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "https://schema.tauri.app/config/2",
33
"productName": "OCPQ",
44
"mainBinaryName": "OCPQ",
5-
"version": "0.9.4",
5+
"version": "0.9.5",
66
"identifier": "eu.aarkue.ocpq",
77
"build": {
88
"beforeBuildCommand": "cross-env NODE_OPTIONS=\"--max_old_space_size=4096\" npm run build",

0 commit comments

Comments
 (0)