svelteplot 0.7.0-pr-269.0 → 0.7.0-pr-274.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md CHANGED
@@ -1,5 +1,23 @@
1
- Copyright 2024, Gregor Aisch
1
+ Copyright 2024-2025, Gregor Aisch
2
2
 
3
3
  Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
4
4
 
5
5
  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
6
+
7
+ ---
8
+
9
+ Portions of this library have been ported from Observable Plot, which is covered by the following license:
10
+
11
+ Copyright 2020-2025 Observable, Inc.
12
+
13
+ Permission to use, copy, modify, and/or distribute this software for any purpose
14
+ with or without fee is hereby granted, provided that the above copyright notice
15
+ and this permission notice appear in all copies.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
18
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
19
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
20
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
21
+ OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
22
+ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
23
+ THIS SOFTWARE.
@@ -1,3 +1,9 @@
1
+ /**
2
+ * This implementation is based on the waffle chart implementation in Observable Plot!
3
+ * https://github.com/observablehq/plot/blob/main/src/marks/waffle.js
4
+ *
5
+ * Kept the comments from the original implementation for clarity.
6
+ */
1
7
  import type { Snippet } from 'svelte';
2
8
  import type { StackOptions } from '../../transforms/stack';
3
9
  import type { BorderRadius, ConstantAccessor, PlotScales, ScaledDataRecord } from '../../types';
@@ -1,41 +1,9 @@
1
- // A waffle is approximately a rectangular shape, but may have one or two corner
2
- // cuts if the starting or ending value is not an even multiple of the number of
3
- // columns (the width of the waffle in cells). We can represent any waffle by
4
- // 8 points; below is a waffle of five columns representing the interval 2–11:
5
- //
6
- // 1-0
7
- // |•7-------6
8
- // |• • • • •|
9
- // 2---3• • •|
10
- // 4-----5
11
- //
12
- // Note that points 0 and 1 always have the same y-value, points 1 and 2 have
13
- // the same x-value, and so on, so we don’t need to materialize the x- and y-
14
- // values of all points. Also note that we can’t use the already-projected y-
15
- // values because these assume that y-values are distributed linearly along y
16
- // rather than wrapping around in columns.
17
- //
18
- // The corner points may be coincident. If the ending value is an even multiple
19
- // of the number of columns, say representing the interval 2–10, then points 6,
20
- // 7, and 0 are the same.
21
- //
22
- // 1-----0/7/6
23
- // |• • • • •|
24
- // 2---3• • •|
25
- // 4-----5
26
- //
27
- // Likewise if the starting value is an even multiple, say representing the
28
- // interval 0–10, points 2–4 are coincident.
29
- //
30
- // 1-----0/7/6
31
- // |• • • • •|
32
- // |• • • • •|
33
- // 4/3/2-----5
34
- //
35
- // Waffles can also represent fractional intervals (e.g., 2.4–10.1). These
36
- // require additional corner cuts, so the implementation below generates a few
37
- // more points.
38
- //
1
+ /**
2
+ * This implementation is based on the waffle chart implementation in Observable Plot!
3
+ * https://github.com/observablehq/plot/blob/main/src/marks/waffle.js
4
+ *
5
+ * Kept the comments from the original implementation for clarity.
6
+ */
39
7
  import { getPatternId } from '../../helpers/getBaseStyles';
40
8
  export function wafflePolygon(y, options, scales) {
41
9
  const x = y === 'y' ? 'x' : 'y';
@@ -0,0 +1,148 @@
1
+ <script lang="ts">
2
+ import { resolve } from '$app/paths';
3
+
4
+ const exampleImages = import.meta.glob('../../../static/examples/*/*.png', {
5
+ eager: true,
6
+ query: {
7
+ enhanced: true,
8
+ w: 440
9
+ }
10
+ });
11
+
12
+ let {
13
+ paths,
14
+ pages,
15
+ isDark
16
+ }: {
17
+ paths: Record<string, string[]>;
18
+ pages: Record<
19
+ string,
20
+ {
21
+ title: string;
22
+ description?: string;
23
+ sortKey?: number;
24
+ transforms?: string[];
25
+ }
26
+ >;
27
+ isDark: boolean;
28
+ } = $props();
29
+
30
+ function sortPages(a: string, b: string) {
31
+ const sortA = pages[a].sortKey ?? 10;
32
+ const sortB = pages[b].sortKey ?? 10;
33
+ return sortA - sortB;
34
+ }
35
+ </script>
36
+
37
+ <div class="column-container">
38
+ {#each Object.entries(paths).sort( (a, b) => a[0].localeCompare(b[0]) ) as [group, groupPages] (group)}
39
+ <div>
40
+ <h2 id={group}>
41
+ <a href={resolve(`/examples/${group}`)}
42
+ >{pages[groupPages.find((p) => p.endsWith('/_index.svelte'))]?.title ??
43
+ group}</a>
44
+ </h2>
45
+ <div class="example-grid">
46
+ {#each groupPages
47
+ .sort(sortPages)
48
+ .filter((p) => !p.endsWith('/_index.svelte')) as page (page)}
49
+ <a
50
+ animate:slide
51
+ href={resolve(page.replace('./', './examples/').replace('.svelte', ''))}
52
+ ><div>
53
+ <enhanced:img
54
+ title={pages[page].title}
55
+ src={exampleImages[
56
+ `../../../static/examples/${page
57
+ .replace('./', '')
58
+ .replace('.svelte', isDark ? '.dark.png' : '.png')}`
59
+ ].default}
60
+ alt={pages[page].title} />
61
+ <div class="title">{pages[page].title}</div>
62
+ </div></a>
63
+ {/each}
64
+ </div>
65
+ </div>
66
+ {/each}
67
+ </div>
68
+
69
+ <style>
70
+ :global(.content) h2 {
71
+ margin-top: 1rem !important;
72
+ margin-bottom: 1rem;
73
+ text-transform: capitalize;
74
+ border: 0;
75
+ a {
76
+ text-decoration: none;
77
+ color: inherit;
78
+ }
79
+ }
80
+
81
+ .column-container {
82
+ container-type: inline-size;
83
+
84
+ h3 {
85
+ break-before: avoid-column;
86
+ text-transform: capitalize;
87
+ }
88
+ }
89
+
90
+ .example-grid {
91
+ --example-grid-columns: 5;
92
+
93
+ /* width: 100%; */
94
+ display: grid;
95
+ /* overflow-x: clip; */
96
+ grid-template-columns: repeat(var(--example-grid-columns), 1fr);
97
+ grid-auto-rows: 1fr;
98
+ gap: 1.25rem;
99
+
100
+ a {
101
+ text-decoration: none;
102
+ color: inherit;
103
+ }
104
+
105
+ .title {
106
+ font-size: 0.75rem;
107
+ opacity: 0.8;
108
+ line-height: 1.2;
109
+ text-decoration: none;
110
+ }
111
+ }
112
+
113
+ @container (max-width: 800px) {
114
+ .example-grid {
115
+ --example-grid-columns: 4;
116
+ }
117
+ }
118
+ @container (max-width: 600px) {
119
+ .example-grid {
120
+ --example-grid-columns: 3;
121
+ }
122
+ }
123
+ @container (max-width: 500px) {
124
+ .example-grid {
125
+ --example-grid-columns: 2;
126
+ }
127
+ }
128
+
129
+ .example-grid :global(img) {
130
+ height: auto !important;
131
+ aspect-ratio: 4 / 3;
132
+ object-fit: cover;
133
+ width: 100%;
134
+ height: auto;
135
+
136
+ position: relative;
137
+ transition: transform 0.05s ease-out;
138
+ &:hover {
139
+ transform: scale(1.5);
140
+ object-fit: contain;
141
+ z-index: 1;
142
+
143
+ background: fixed var(--svelteplot-bg);
144
+
145
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
146
+ }
147
+ }
148
+ </style>
@@ -0,0 +1,13 @@
1
+ type $$ComponentProps = {
2
+ paths: Record<string, string[]>;
3
+ pages: Record<string, {
4
+ title: string;
5
+ description?: string;
6
+ sortKey?: number;
7
+ transforms?: string[];
8
+ }>;
9
+ isDark: boolean;
10
+ };
11
+ declare const ExamplesPagePreview: import("svelte").Component<$$ComponentProps, {}, "">;
12
+ type ExamplesPagePreview = ReturnType<typeof ExamplesPagePreview>;
13
+ export default ExamplesPagePreview;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelteplot",
3
- "version": "0.7.0-pr-269.0",
3
+ "version": "0.7.0-pr-274.0",
4
4
  "license": "ISC",
5
5
  "author": {
6
6
  "name": "Gregor Aisch",
@@ -56,6 +56,7 @@
56
56
  "@emotion/css": "^11.13.5",
57
57
  "@sveltejs/adapter-auto": "^7.0.0",
58
58
  "@sveltejs/adapter-static": "^3.0.10",
59
+ "@sveltejs/enhanced-img": "^0.6.1",
59
60
  "@sveltejs/eslint-config": "^8.3.4",
60
61
  "@sveltejs/kit": "^2.48.5",
61
62
  "@sveltejs/package": "^2.5.4",