Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 6, 2024
1 parent 0ea45b5 commit 4a86104
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 97 deletions.
2 changes: 1 addition & 1 deletion visualizer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ It works as any React app in terms of building, running etc. If you just want to
1. Ensure that you have Node >=16 and npm installed. See https://docs.npmjs.com/downloading-and-installing-node-js-and-npm.
2. From the directory `conspiracies/visualizer`, run `npm install`.
3. Then run `npm start` which will open a development server on `localhost:3000`.
4. Load in the file `graph.json` from your output via the GUI.
4. Load in the file `graph.json` from your output via the GUI.
1 change: 0 additions & 1 deletion visualizer/electron-main.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const { app, BrowserWindow } = require("electron");
const path = require("path");


function createWindow() {
const mainWindow = new BrowserWindow();

Expand Down
7 changes: 2 additions & 5 deletions visualizer/public/index.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta
name="Visualizer"
content="Visualization of narrative graphs"
/>
<meta name="Visualizer" content="Visualization of narrative graphs" />

<title>Visualizer</title>
</head>
Expand Down
3 changes: 1 addition & 2 deletions visualizer/public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"short_name": "Visualizer",
"name": "Narrative Graphs Visualizer",
"icons": [
],
"icons": [],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
Expand Down
26 changes: 13 additions & 13 deletions visualizer/src/common/LogarithmicRangeSlider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,19 @@ const LogarithmicRangeSlider: React.FC<LogarithmicRangeSliderProps> = ({
];

return (
<MultiRangeSlider
min={linearMin}
max={linearMax}
minValue={realValueToLinearScale(minValue)}
maxValue={realValueToLinearScale(maxValue)}
onInput={handleSliderInput}
onChange={handleSliderChange}
minCaption={String(minCaption)} // Use the updated caption state
maxCaption={String(maxCaption)} // Use the updated caption state
labels={labels}
{...rest}
ruler={ruler || false}
/>
<MultiRangeSlider
min={linearMin}
max={linearMax}
minValue={realValueToLinearScale(minValue)}
maxValue={realValueToLinearScale(maxValue)}
onInput={handleSliderInput}
onChange={handleSliderChange}
minCaption={String(minCaption)} // Use the updated caption state
maxCaption={String(maxCaption)} // Use the updated caption state
labels={labels}
{...rest}
ruler={ruler || false}
/>
);
};
export default LogarithmicRangeSlider;
135 changes: 75 additions & 60 deletions visualizer/src/graph/GraphOptionsControlPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,69 +1,84 @@
import React from "react";
import './graph.css'
import {Options} from "react-vis-graph-wrapper";

import "./graph.css";
import { Options } from "react-vis-graph-wrapper";

interface GraphOptionsControlPanelProps {
options: Options;
setOptions: React.Dispatch<React.SetStateAction<Options>>;

options: Options;
setOptions: React.Dispatch<React.SetStateAction<Options>>;
}

function getSmoothEnabled(options: Options): boolean {
if (typeof options.edges?.smooth === 'boolean') {
return options.edges.smooth;
} else if (typeof options.edges?.smooth === 'object' && 'enabled' in options.edges.smooth) {
return options.edges.smooth.enabled;
} else {
return false;
}
if (typeof options.edges?.smooth === "boolean") {
return options.edges.smooth;
} else if (
typeof options.edges?.smooth === "object" &&
"enabled" in options.edges.smooth
) {
return options.edges.smooth.enabled;
} else {
return false;
}
}

export const GraphOptionsControlPanel = ({options, setOptions}: GraphOptionsControlPanelProps) => {


return <div className={"flex-container"}>
<div className={"flex-container__element"}>
Physics enabled:
<input type={"checkbox"} checked={options.physics.enabled}
onChange={(event) => setOptions(
{
...options,
physics: {
...options.physics,
enabled: event.target.checked
}
})
}/>
</div>
<div className={"flex-container__element"}>
Rounded edges:
<input type={"checkbox"} checked={getSmoothEnabled(options)}
onChange={(event) => setOptions(
{
...options,
edges: {
...options.edges,
smooth: !options.edges?.smooth
}
})
}/>
</div>
<div className={"flex-container__element"}>
Edge length:
<input type="range" min="50" max="1000" value={options.physics.barnesHut.springLength}
onChange={(event) => setOptions(
{
...options,
physics: {
...options.physics,
barnesHut: {
springLength: Number(event.target.value)
}
}
})
}
step="1"/>
</div>
export const GraphOptionsControlPanel = ({
options,
setOptions,
}: GraphOptionsControlPanelProps) => {
return (
<div className={"flex-container"}>
<div className={"flex-container__element"}>
Physics enabled:
<input
type={"checkbox"}
checked={options.physics.enabled}
onChange={(event) =>
setOptions({
...options,
physics: {
...options.physics,
enabled: event.target.checked,
},
})
}
/>
</div>
<div className={"flex-container__element"}>
Rounded edges:
<input
type={"checkbox"}
checked={getSmoothEnabled(options)}
onChange={(event) =>
setOptions({
...options,
edges: {
...options.edges,
smooth: !options.edges?.smooth,
},
})
}
/>
</div>
<div className={"flex-container__element"}>
Edge length:
<input
type="range"
min="50"
max="1000"
value={options.physics.barnesHut.springLength}
onChange={(event) =>
setOptions({
...options,
physics: {
...options.physics,
barnesHut: {
springLength: Number(event.target.value),
},
},
})
}
step="1"
/>
</div>
</div>
}
);
};
6 changes: 3 additions & 3 deletions visualizer/src/index.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
monospace;
}
6 changes: 2 additions & 4 deletions visualizer/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import "./index.css";
import App from "./App";

const root = ReactDOM.createRoot(
document.getElementById("root") as HTMLElement
);
root.render(
<App />
document.getElementById("root") as HTMLElement,
);
root.render(<App />);
10 changes: 2 additions & 8 deletions visualizer/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
Expand All @@ -20,7 +16,5 @@
"noEmit": true,
"jsx": "react-jsx"
},
"include": [
"src"
]
"include": ["src"]
}

0 comments on commit 4a86104

Please sign in to comment.