Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change time series module previews #428

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions frontend/src/modules/SimulationTimeSeries/preview.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 2 additions & 31 deletions frontend/src/modules/SimulationTimeSeries/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,6 @@
import { DrawPreviewFunc } from "@framework/Preview";
import previewImg from "./preview.svg";

export const preview: DrawPreviewFunc = function (width: number, height: number) {
const paths: { x1: number; y1: number; x2: number; y2: number; x3: number; y3: number; xc: number; yc: number }[] =
[];
const numPaths = 10;
for (let i = 0; i < numPaths; i++) {
const x1 = 0;
const y1 = height - (i / numPaths) * height;
const x2 = width / 2;
const y2 = height - ((i - 1) / numPaths) * height;
const x3 = width;
const y3 = height - (((i - 1) / numPaths) * height) / 1.2;
const xc = width / 4;
const yc = height - (i / numPaths) * height - height / 12;
paths.push({ x1, y1, x2, y2, x3, y3, xc, yc });
}
return (
<svg width={width} height={height} viewBox={`0 0 ${width} ${height}`}>
<path d={`M 0 ${height} L 0 0`} stroke="black" strokeWidth={1} />
<path d={`M 0 ${height} L ${width} ${height}`} stroke="black" strokeWidth={1} />
{paths.map((path, index) => {
return (
<path
key={index}
d={`M ${path.x1} ${path.y1} Q ${path.xc} ${path.yc} ${path.x2} ${path.y2} T ${path.x3} ${path.y3}`}
fill="none"
stroke="green"
strokeWidth={1}
/>
);
})}
</svg>
);
return <img src={previewImg} style={{width, height}} />
};
9 changes: 9 additions & 0 deletions frontend/src/modules/SimulationTimeSeriesMatrix/preview.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 2 additions & 44 deletions frontend/src/modules/SimulationTimeSeriesMatrix/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,48 +1,6 @@
import { DrawPreviewFunc } from "@framework/Preview";
import previewImg from "./preview.svg";

export const preview: DrawPreviewFunc = function (width: number, height: number) {
const paths: {
x1: number;
y1: number;
x2: number;
y2: number;
x3: number;
y3: number;
xc: number;
yc: number;
color: string;
}[] = [];
const numPaths = 9;
for (let i = 0; i < numPaths; i++) {
const x1 = 0;
const y1 = height - (i / numPaths) * height;
const x2 = width / 2;
const y2 = height - ((i - 1) / numPaths) * height;
const x3 = width;
const y3 = height - (((i - 1) / numPaths) * height) / 1.2;
const xc = width / 4;
const yc = height - (i / numPaths) * height - height / 12;

// Assign colors based on position
const color = i < 3 ? "green" : i < 6 ? "red" : "blue";

paths.push({ x1, y1, x2, y2, x3, y3, xc, yc, color });
}
return (
<svg width={width} height={height} viewBox={`0 0 ${width} ${height}`}>
<path d={`M 0 ${height} L 0 0`} stroke="black" strokeWidth={1} />
<path d={`M 0 ${height} L ${width} ${height}`} stroke="black" strokeWidth={1} />
{paths.map((path, index) => {
return (
<path
key={index}
d={`M ${path.x1} ${path.y1} Q ${path.xc} ${path.yc} ${path.x2} ${path.y2} T ${path.x3} ${path.y3}`}
fill="none"
stroke={path.color} // Set stroke color
strokeWidth={1}
/>
);
})}
</svg>
);
return <img src={previewImg} style={{width, height}} />
};