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

data fetch bug hunting #8

Merged
merged 8 commits into from
Jan 19, 2024
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ To raise the sliders, you need to click on one of the examples that are displaye

## TODOS

- [x] New "blank" button
- [x] New "blank" button.
- [ ] Minor: Make keyboard short cut (option+up/down) for the z-direction
- [ ] Chore: Extract some common types into a top level location (like types.ts type thing)
- [x] Chore: Rearrange some of the colors in the color area eg make rg on xy and b on z etc, blocking polar stuff
- x] Polar stuff
- [x] Polar stuff
- [ ] Insert color theory options, eg insert opposing, inserting analogous color, etc, mine from the adobe picker
- [ ] Labels, tooltips, etc
- [ ] Nice to have: Rest of basic geometry manipulations: flip (horizontal, vertical), scale, Distribute radially
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"check": "svelte-check --tsconfig ./tsconfig.json",
"types": "tsc --noEmit --watch",
"prep-data": "cp node_modules/vega-datasets/data/* public/data/",
"build-data": "mkdir data && cp node_modules/vega-datasets/data/* ./data/",
"test": "vitest run",
"test:watch": "vitest"
},
Expand Down Expand Up @@ -51,4 +52,4 @@
"vega-embed": "^6.23.0",
"vega-lite": "^5.16.3"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
focusedColors.length >= 2 &&
open && {
...$colorStore.currentPal,
colors: createInterpolation(true),
colors: createInterpolation(),
}) as Palette;
function createInterpolatedPoints(pointA: Color, pointB: Color) {
const points: Color[] = [];
Expand Down
22 changes: 9 additions & 13 deletions src/lib/charts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,26 +191,22 @@ export async function getSVG(localSpec: string, pal: Palette) {
if (results[newKey]) return results[newKey];
const theme = buildTheme(pal);
let spec: any;

const cleanSpec = vegaDatasets.reduce((acc, x) => {
const breakKey = `url": "data/${x}`;
const joinKey = `url": "https://vega.github.io/editor/data/${x}`;
return acc.split(breakKey).join(joinKey);
}, localSpec);

try {
spec = JSON.parse(localSpec);
spec = JSON.parse(cleanSpec);
} catch (e) {
console.error(e, localSpec);
console.error(e, cleanSpec);
return "";
}
if (spec.$schema.includes("vega-lite")) {
spec = vegaLite.compile(spec, { config: theme }).spec;
}
// // url: !location.href.includes("localhost")
// ? "https://vega.github.io/editor/data/penguins.json"
// : "data/penguins.json",
const matchedDataset = vegaDatasets.find((x) => spec.data?.url?.includes(x));
if (matchedDataset) {
if (location.href.includes("localhost")) {
spec.data.url = `data/${matchedDataset}`;
} else {
spec.data.url = `https://vega.github.io/editor/data/${matchedDataset}`;
}
}

const runtime = vega.parse(spec, theme);
const view = await new vega.View(runtime, { renderer: "svg" }).runAsync();
Expand Down
Loading