@keneth80/k-chart 1.21.0 → 1.23.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/CHANGELOG.md +32 -0
- package/README.md +10 -24
- package/docs/configuration-reference.md +18 -0
- package/docs/functional-api.md +16 -0
- package/examples/stackblitz-area-basic/index.html +21 -0
- package/examples/stackblitz-area-basic/package-lock.json +1531 -0
- package/examples/stackblitz-area-basic/package.json +18 -0
- package/examples/stackblitz-area-basic/src/main.ts +65 -0
- package/examples/stackblitz-area-basic/src/style.css +83 -0
- package/examples/stackblitz-area-basic/src/vite-env.d.ts +1 -0
- package/examples/stackblitz-box-plot-basic/index.html +21 -0
- package/examples/stackblitz-box-plot-basic/package-lock.json +1531 -0
- package/examples/stackblitz-box-plot-basic/package.json +18 -0
- package/examples/stackblitz-box-plot-basic/src/main.ts +69 -0
- package/examples/stackblitz-box-plot-basic/src/style.css +83 -0
- package/examples/stackblitz-box-plot-basic/src/vite-env.d.ts +1 -0
- package/examples/stackblitz-bubble-basic/index.html +21 -0
- package/examples/stackblitz-bubble-basic/package-lock.json +1531 -0
- package/examples/stackblitz-bubble-basic/package.json +18 -0
- package/examples/stackblitz-bubble-basic/src/main.ts +64 -0
- package/examples/stackblitz-bubble-basic/src/style.css +83 -0
- package/examples/stackblitz-bubble-basic/src/vite-env.d.ts +1 -0
- package/examples/stackblitz-gauge-basic/index.html +21 -0
- package/examples/stackblitz-gauge-basic/package-lock.json +1531 -0
- package/examples/stackblitz-gauge-basic/package.json +18 -0
- package/examples/stackblitz-gauge-basic/src/main.ts +55 -0
- package/examples/stackblitz-gauge-basic/src/style.css +83 -0
- package/examples/stackblitz-gauge-basic/src/vite-env.d.ts +1 -0
- package/examples/stackblitz-grouped-column-basic/index.html +26 -0
- package/examples/stackblitz-grouped-column-basic/package-lock.json +1531 -0
- package/examples/stackblitz-grouped-column-basic/package.json +18 -0
- package/examples/stackblitz-grouped-column-basic/src/main.ts +61 -0
- package/examples/stackblitz-grouped-column-basic/src/style.css +83 -0
- package/examples/stackblitz-grouped-column-basic/src/vite-env.d.ts +1 -0
- package/examples/stackblitz-histogram-basic/index.html +21 -0
- package/examples/stackblitz-histogram-basic/package-lock.json +1531 -0
- package/examples/stackblitz-histogram-basic/package.json +18 -0
- package/examples/stackblitz-histogram-basic/src/main.ts +64 -0
- package/examples/stackblitz-histogram-basic/src/style.css +83 -0
- package/examples/stackblitz-histogram-basic/src/vite-env.d.ts +1 -0
- package/examples/stackblitz-horizontal-bar-basic/index.html +21 -0
- package/examples/stackblitz-horizontal-bar-basic/package-lock.json +1531 -0
- package/examples/stackblitz-horizontal-bar-basic/package.json +18 -0
- package/examples/stackblitz-horizontal-bar-basic/src/main.ts +58 -0
- package/examples/stackblitz-horizontal-bar-basic/src/style.css +83 -0
- package/examples/stackblitz-horizontal-bar-basic/src/vite-env.d.ts +1 -0
- package/examples/stackblitz-scatter-basic/index.html +21 -0
- package/examples/stackblitz-scatter-basic/package-lock.json +1531 -0
- package/examples/stackblitz-scatter-basic/package.json +18 -0
- package/examples/stackblitz-scatter-basic/src/main.ts +66 -0
- package/examples/stackblitz-scatter-basic/src/style.css +83 -0
- package/examples/stackblitz-scatter-basic/src/vite-env.d.ts +1 -0
- package/examples/stackblitz-three-constellation-basic/index.html +41 -0
- package/examples/stackblitz-three-constellation-basic/package-lock.json +1607 -0
- package/examples/stackblitz-three-constellation-basic/package.json +22 -0
- package/examples/stackblitz-three-constellation-basic/src/main.ts +374 -0
- package/examples/stackblitz-three-constellation-basic/src/style.css +173 -0
- package/examples/stackblitz-waterfall-basic/index.html +26 -0
- package/examples/stackblitz-waterfall-basic/package-lock.json +1531 -0
- package/examples/stackblitz-waterfall-basic/package.json +18 -0
- package/examples/stackblitz-waterfall-basic/src/main.ts +75 -0
- package/examples/stackblitz-waterfall-basic/src/style.css +83 -0
- package/examples/stackblitz-waterfall-basic/src/vite-env.d.ts +1 -0
- package/lib/core/axis-title.d.ts +23 -0
- package/lib/core/axis-title.d.ts.map +1 -0
- package/lib/core/axis-title.js +129 -0
- package/lib/core/axis-title.js.map +1 -0
- package/lib/core/contracts.d.ts +3 -0
- package/lib/core/contracts.d.ts.map +1 -1
- package/lib/core/create-kchart.d.ts +9 -0
- package/lib/core/create-kchart.d.ts.map +1 -1
- package/lib/core/create-kchart.js +130 -25
- package/lib/core/create-kchart.js.map +1 -1
- package/lib/presets/index.d.ts +2 -0
- package/lib/presets/index.d.ts.map +1 -1
- package/lib/presets/index.js.map +1 -1
- package/lib/series/support/canvas.d.ts.map +1 -1
- package/lib/series/support/canvas.js +68 -15
- package/lib/series/support/canvas.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "kchart-stackblitz-three-constellation-basic",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite --host 0.0.0.0",
|
|
8
|
+
"build": "tsc -p tsconfig.json && vite build",
|
|
9
|
+
"preview": "vite preview --host 0.0.0.0"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@keneth80/k-chart": "^1.22.0",
|
|
13
|
+
"@keneth80/k-chart-three": "^0.1.0",
|
|
14
|
+
"three": "^0.184.0"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@types/three": "^0.185.0",
|
|
18
|
+
"typescript": "^6.0.3",
|
|
19
|
+
"vite": "^7.2.7"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import {
|
|
3
|
+
createKThreeScene,
|
|
4
|
+
type KThreeObject,
|
|
5
|
+
type KThreeSceneContext,
|
|
6
|
+
} from '@keneth80/k-chart-three';
|
|
7
|
+
import '@keneth80/k-chart-three/style.css';
|
|
8
|
+
import './style.css';
|
|
9
|
+
|
|
10
|
+
interface AriesStar {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
designation: string;
|
|
14
|
+
magnitude: number;
|
|
15
|
+
position: [number, number, number];
|
|
16
|
+
size: number;
|
|
17
|
+
color: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface AriesLink {
|
|
21
|
+
source: AriesStar['id'];
|
|
22
|
+
target: AriesStar['id'];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const ariesStars: AriesStar[] = [
|
|
26
|
+
{
|
|
27
|
+
id: 'mesarthim',
|
|
28
|
+
name: 'Mesarthim',
|
|
29
|
+
designation: 'Gamma Ari',
|
|
30
|
+
magnitude: 3.88,
|
|
31
|
+
position: [-2.65, 0.68, -0.15],
|
|
32
|
+
size: 0.72,
|
|
33
|
+
color: '#d6e8ff',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: 'sheratan',
|
|
37
|
+
name: 'Sheratan',
|
|
38
|
+
designation: 'Beta Ari',
|
|
39
|
+
magnitude: 2.64,
|
|
40
|
+
position: [-1.62, 0.42, 0.18],
|
|
41
|
+
size: 0.92,
|
|
42
|
+
color: '#dcecff',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: 'hamal',
|
|
46
|
+
name: 'Hamal',
|
|
47
|
+
designation: 'Alpha Ari',
|
|
48
|
+
magnitude: 2.0,
|
|
49
|
+
position: [0.02, 0.05, 0.3],
|
|
50
|
+
size: 1.24,
|
|
51
|
+
color: '#ffd7a1',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: 'botein',
|
|
55
|
+
name: 'Botein',
|
|
56
|
+
designation: 'Delta Ari',
|
|
57
|
+
magnitude: 4.35,
|
|
58
|
+
position: [1.72, -0.52, -0.04],
|
|
59
|
+
size: 0.68,
|
|
60
|
+
color: '#ffe4b8',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
id: '41-ari',
|
|
64
|
+
name: '41 Arietis',
|
|
65
|
+
designation: 'Bharani',
|
|
66
|
+
magnitude: 3.61,
|
|
67
|
+
position: [2.72, -1.08, -0.34],
|
|
68
|
+
size: 0.8,
|
|
69
|
+
color: '#cbe4ff',
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
const ariesLinks: AriesLink[] = [
|
|
74
|
+
{ source: 'mesarthim', target: 'sheratan' },
|
|
75
|
+
{ source: 'sheratan', target: 'hamal' },
|
|
76
|
+
{ source: 'hamal', target: 'botein' },
|
|
77
|
+
{ source: 'botein', target: '41-ari' },
|
|
78
|
+
];
|
|
79
|
+
|
|
80
|
+
const status = document.querySelector<HTMLParagraphElement>('#star-status');
|
|
81
|
+
const sceneHost = document.querySelector<HTMLElement>('#scene');
|
|
82
|
+
|
|
83
|
+
if (!status || !sceneHost) {
|
|
84
|
+
throw new Error('Aries example host elements are missing.');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const createGlowTexture = (): THREE.CanvasTexture => {
|
|
88
|
+
const canvas = document.createElement('canvas');
|
|
89
|
+
canvas.width = 128;
|
|
90
|
+
canvas.height = 128;
|
|
91
|
+
const context = canvas.getContext('2d');
|
|
92
|
+
|
|
93
|
+
if (context) {
|
|
94
|
+
const gradient = context.createRadialGradient(64, 64, 2, 64, 64, 62);
|
|
95
|
+
gradient.addColorStop(0, 'rgba(255,255,255,1)');
|
|
96
|
+
gradient.addColorStop(0.14, 'rgba(221,239,255,.94)');
|
|
97
|
+
gradient.addColorStop(0.45, 'rgba(100,190,255,.36)');
|
|
98
|
+
gradient.addColorStop(1, 'rgba(100,190,255,0)');
|
|
99
|
+
context.fillStyle = gradient;
|
|
100
|
+
context.fillRect(0, 0, 128, 128);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const texture = new THREE.CanvasTexture(canvas);
|
|
104
|
+
texture.colorSpace = THREE.SRGBColorSpace;
|
|
105
|
+
return texture;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const disposeGroup = (group: THREE.Group): void => {
|
|
109
|
+
group.traverse((object) => {
|
|
110
|
+
const renderable = object as THREE.Mesh;
|
|
111
|
+
renderable.geometry?.dispose();
|
|
112
|
+
const materials = Array.isArray(renderable.material)
|
|
113
|
+
? renderable.material
|
|
114
|
+
: [renderable.material];
|
|
115
|
+
materials.filter(Boolean).forEach((material) => material.dispose());
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const setPointer = (
|
|
120
|
+
event: PointerEvent | MouseEvent,
|
|
121
|
+
context: KThreeSceneContext<AriesStar>,
|
|
122
|
+
): void => {
|
|
123
|
+
const bounds = context.canvas.getBoundingClientRect();
|
|
124
|
+
context.pointer.set(
|
|
125
|
+
((event.clientX - bounds.left) / Math.max(bounds.width, 1)) * 2 - 1,
|
|
126
|
+
-((event.clientY - bounds.top) / Math.max(bounds.height, 1)) * 2 + 1,
|
|
127
|
+
);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const createAriesObject = (links: readonly AriesLink[]): KThreeObject<AriesStar> => {
|
|
131
|
+
let context: KThreeSceneContext<AriesStar> | undefined;
|
|
132
|
+
let root: THREE.Group | undefined;
|
|
133
|
+
let glowTexture: THREE.CanvasTexture | undefined;
|
|
134
|
+
let stars: THREE.Mesh<THREE.SphereGeometry, THREE.MeshBasicMaterial>[] = [];
|
|
135
|
+
let glows: THREE.Sprite[] = [];
|
|
136
|
+
let data: readonly AriesStar[] = [];
|
|
137
|
+
let hoveredIndex = -1;
|
|
138
|
+
let selectedIndex = -1;
|
|
139
|
+
|
|
140
|
+
const clear = (): void => {
|
|
141
|
+
if (root) {
|
|
142
|
+
context?.scene.remove(root);
|
|
143
|
+
disposeGroup(root);
|
|
144
|
+
}
|
|
145
|
+
glowTexture?.dispose();
|
|
146
|
+
root = undefined;
|
|
147
|
+
glowTexture = undefined;
|
|
148
|
+
stars = [];
|
|
149
|
+
glows = [];
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const updateStatus = (): void => {
|
|
153
|
+
const star = data[hoveredIndex] ?? data[selectedIndex];
|
|
154
|
+
status.textContent = star
|
|
155
|
+
? `${star.name} / ${star.designation} / magnitude ${star.magnitude.toFixed(2)}`
|
|
156
|
+
: 'Drag to orbit. Scroll to zoom. Select a star.';
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const updateAppearance = (): void => {
|
|
160
|
+
stars.forEach((mesh, index) => {
|
|
161
|
+
const active = index === selectedIndex;
|
|
162
|
+
const hovered = index === hoveredIndex;
|
|
163
|
+
const scale = active ? 1.42 : hovered ? 1.22 : 1;
|
|
164
|
+
mesh.scale.setScalar(scale);
|
|
165
|
+
mesh.material.color.set(active ? '#ffffff' : hovered ? '#f4fbff' : data[index].color);
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const hitTest = (
|
|
170
|
+
event: PointerEvent | MouseEvent,
|
|
171
|
+
sceneContext: KThreeSceneContext<AriesStar>,
|
|
172
|
+
): number => {
|
|
173
|
+
setPointer(event, sceneContext);
|
|
174
|
+
sceneContext.raycaster.setFromCamera(sceneContext.pointer, sceneContext.camera);
|
|
175
|
+
const hit = sceneContext.raycaster.intersectObjects(stars, false)[0];
|
|
176
|
+
return hit ? Number(hit.object.userData.starIndex) : -1;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const rebuild = (): void => {
|
|
180
|
+
if (!context) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
clear();
|
|
185
|
+
root = new THREE.Group();
|
|
186
|
+
root.rotation.set(-0.06, -0.18, -0.04);
|
|
187
|
+
glowTexture = createGlowTexture();
|
|
188
|
+
|
|
189
|
+
const positions = new Map<string, THREE.Vector3>();
|
|
190
|
+
data.forEach((star, index) => {
|
|
191
|
+
const position = new THREE.Vector3(...star.position);
|
|
192
|
+
positions.set(star.id, position);
|
|
193
|
+
|
|
194
|
+
const mesh = new THREE.Mesh(
|
|
195
|
+
new THREE.SphereGeometry(0.115 * star.size, 22, 16),
|
|
196
|
+
new THREE.MeshBasicMaterial({ color: star.color, toneMapped: false }),
|
|
197
|
+
);
|
|
198
|
+
mesh.position.copy(position);
|
|
199
|
+
mesh.userData.starIndex = index;
|
|
200
|
+
stars.push(mesh);
|
|
201
|
+
root?.add(mesh);
|
|
202
|
+
|
|
203
|
+
const glow = new THREE.Sprite(
|
|
204
|
+
new THREE.SpriteMaterial({
|
|
205
|
+
map: glowTexture,
|
|
206
|
+
color: star.color,
|
|
207
|
+
transparent: true,
|
|
208
|
+
opacity: 0.88,
|
|
209
|
+
depthWrite: false,
|
|
210
|
+
blending: THREE.AdditiveBlending,
|
|
211
|
+
toneMapped: false,
|
|
212
|
+
}),
|
|
213
|
+
);
|
|
214
|
+
glow.position.copy(position);
|
|
215
|
+
glow.userData.baseScale = 0.9 * star.size;
|
|
216
|
+
glow.scale.setScalar(glow.userData.baseScale);
|
|
217
|
+
glows.push(glow);
|
|
218
|
+
root?.add(glow);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
const lineVertices: number[] = [];
|
|
222
|
+
links.forEach((link) => {
|
|
223
|
+
const source = positions.get(link.source);
|
|
224
|
+
const target = positions.get(link.target);
|
|
225
|
+
if (source && target) {
|
|
226
|
+
lineVertices.push(source.x, source.y, source.z, target.x, target.y, target.z);
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
const lineGeometry = new THREE.BufferGeometry();
|
|
230
|
+
lineGeometry.setAttribute('position', new THREE.Float32BufferAttribute(lineVertices, 3));
|
|
231
|
+
root.add(
|
|
232
|
+
new THREE.LineSegments(
|
|
233
|
+
lineGeometry,
|
|
234
|
+
new THREE.LineBasicMaterial({
|
|
235
|
+
color: '#6ec8ff',
|
|
236
|
+
transparent: true,
|
|
237
|
+
opacity: 0.54,
|
|
238
|
+
}),
|
|
239
|
+
),
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
let seed = 1729;
|
|
243
|
+
const random = (): number => {
|
|
244
|
+
seed = (seed * 48271) % 2147483647;
|
|
245
|
+
return seed / 2147483647;
|
|
246
|
+
};
|
|
247
|
+
const backgroundVertices: number[] = [];
|
|
248
|
+
for (let index = 0; index < 520; index += 1) {
|
|
249
|
+
const radius = 7 + random() * 11;
|
|
250
|
+
const theta = random() * Math.PI * 2;
|
|
251
|
+
const phi = Math.acos(2 * random() - 1);
|
|
252
|
+
backgroundVertices.push(
|
|
253
|
+
radius * Math.sin(phi) * Math.cos(theta),
|
|
254
|
+
radius * Math.cos(phi),
|
|
255
|
+
radius * Math.sin(phi) * Math.sin(theta),
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
const backgroundGeometry = new THREE.BufferGeometry();
|
|
259
|
+
backgroundGeometry.setAttribute(
|
|
260
|
+
'position',
|
|
261
|
+
new THREE.Float32BufferAttribute(backgroundVertices, 3),
|
|
262
|
+
);
|
|
263
|
+
root.add(
|
|
264
|
+
new THREE.Points(
|
|
265
|
+
backgroundGeometry,
|
|
266
|
+
new THREE.PointsMaterial({
|
|
267
|
+
color: '#d5e9ff',
|
|
268
|
+
size: 0.032,
|
|
269
|
+
transparent: true,
|
|
270
|
+
opacity: 0.7,
|
|
271
|
+
sizeAttenuation: true,
|
|
272
|
+
}),
|
|
273
|
+
),
|
|
274
|
+
);
|
|
275
|
+
|
|
276
|
+
context.scene.add(root);
|
|
277
|
+
updateAppearance();
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
return {
|
|
281
|
+
attach(sceneContext) {
|
|
282
|
+
context = sceneContext;
|
|
283
|
+
context.scene.fog = new THREE.FogExp2('#060b14', 0.035);
|
|
284
|
+
},
|
|
285
|
+
setData(nextData) {
|
|
286
|
+
data = nextData;
|
|
287
|
+
selectedIndex = Math.min(selectedIndex, data.length - 1);
|
|
288
|
+
hoveredIndex = -1;
|
|
289
|
+
rebuild();
|
|
290
|
+
updateStatus();
|
|
291
|
+
},
|
|
292
|
+
beforeRender() {
|
|
293
|
+
const time = performance.now() * 0.0015;
|
|
294
|
+
glows.forEach((glow, index) => {
|
|
295
|
+
const emphasis = index === selectedIndex ? 1.32 : index === hoveredIndex ? 1.16 : 1;
|
|
296
|
+
const pulse = 1 + Math.sin(time + index * 1.7) * 0.045;
|
|
297
|
+
glow.scale.setScalar(Number(glow.userData.baseScale) * emphasis * pulse);
|
|
298
|
+
});
|
|
299
|
+
},
|
|
300
|
+
pointerMove(event, sceneContext) {
|
|
301
|
+
const nextIndex = hitTest(event, sceneContext);
|
|
302
|
+
if (nextIndex === hoveredIndex) {
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
hoveredIndex = nextIndex;
|
|
306
|
+
sceneContext.canvas.style.cursor = hoveredIndex >= 0 ? 'pointer' : 'grab';
|
|
307
|
+
updateAppearance();
|
|
308
|
+
updateStatus();
|
|
309
|
+
},
|
|
310
|
+
click(event, sceneContext) {
|
|
311
|
+
const nextIndex = hitTest(event, sceneContext);
|
|
312
|
+
if (nextIndex < 0) {
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
selectedIndex = nextIndex;
|
|
316
|
+
updateAppearance();
|
|
317
|
+
updateStatus();
|
|
318
|
+
},
|
|
319
|
+
destroy() {
|
|
320
|
+
clear();
|
|
321
|
+
if (context) {
|
|
322
|
+
context.scene.fog = null;
|
|
323
|
+
}
|
|
324
|
+
context = undefined;
|
|
325
|
+
},
|
|
326
|
+
};
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
const controller = createKThreeScene<AriesStar>({
|
|
330
|
+
container: sceneHost,
|
|
331
|
+
backgroundColor: '#060b14',
|
|
332
|
+
alpha: false,
|
|
333
|
+
lights: 'none',
|
|
334
|
+
camera: {
|
|
335
|
+
fov: 43,
|
|
336
|
+
near: 0.1,
|
|
337
|
+
far: 100,
|
|
338
|
+
position: [0, 0.35, 8.4],
|
|
339
|
+
lookAt: [0, -0.08, 0],
|
|
340
|
+
},
|
|
341
|
+
controls: {
|
|
342
|
+
orbit: true,
|
|
343
|
+
autoRotate: true,
|
|
344
|
+
autoRotateSpeed: 0.24,
|
|
345
|
+
enablePan: false,
|
|
346
|
+
minDistance: 5.2,
|
|
347
|
+
maxDistance: 13,
|
|
348
|
+
},
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
controller.add(createAriesObject(ariesLinks));
|
|
352
|
+
controller.setData(ariesStars);
|
|
353
|
+
|
|
354
|
+
const resizeObserver = new ResizeObserver(([entry]) => {
|
|
355
|
+
if (!entry) {
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
const { width, height } = entry.contentRect;
|
|
359
|
+
controller.resize(Math.max(1, Math.round(width)), Math.max(1, Math.round(height)));
|
|
360
|
+
});
|
|
361
|
+
resizeObserver.observe(sceneHost);
|
|
362
|
+
|
|
363
|
+
let destroyed = false;
|
|
364
|
+
const destroy = (): void => {
|
|
365
|
+
if (destroyed) {
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
destroyed = true;
|
|
369
|
+
resizeObserver.disconnect();
|
|
370
|
+
controller.destroy();
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
window.addEventListener('pagehide', destroy, { once: true });
|
|
374
|
+
import.meta.hot?.dispose(destroy);
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
color-scheme: dark;
|
|
3
|
+
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
4
|
+
background: #05080d;
|
|
5
|
+
color: #eef5fb;
|
|
6
|
+
font-synthesis: none;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
* {
|
|
10
|
+
box-sizing: border-box;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
body {
|
|
14
|
+
margin: 0;
|
|
15
|
+
min-width: 320px;
|
|
16
|
+
min-height: 100vh;
|
|
17
|
+
background: #05080d;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.page-shell {
|
|
21
|
+
width: min(1120px, calc(100vw - 32px));
|
|
22
|
+
margin: 0 auto;
|
|
23
|
+
padding: 38px 0 48px;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.intro {
|
|
27
|
+
display: grid;
|
|
28
|
+
grid-template-columns: minmax(0, 1fr) minmax(240px, 420px);
|
|
29
|
+
align-items: end;
|
|
30
|
+
gap: 28px;
|
|
31
|
+
margin-bottom: 20px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.eyebrow {
|
|
35
|
+
grid-column: 1 / -1;
|
|
36
|
+
margin: 0 0 -18px;
|
|
37
|
+
color: #75cdf9;
|
|
38
|
+
font-size: 11px;
|
|
39
|
+
font-weight: 750;
|
|
40
|
+
letter-spacing: 0;
|
|
41
|
+
text-transform: uppercase;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
h1 {
|
|
45
|
+
margin: 0;
|
|
46
|
+
font-size: clamp(32px, 5vw, 56px);
|
|
47
|
+
line-height: 1.02;
|
|
48
|
+
font-weight: 690;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.lede {
|
|
52
|
+
margin: 0 0 4px;
|
|
53
|
+
color: #9eafbf;
|
|
54
|
+
font-size: 15px;
|
|
55
|
+
line-height: 1.65;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.constellation-panel {
|
|
59
|
+
overflow: hidden;
|
|
60
|
+
border: 1px solid #253345;
|
|
61
|
+
border-radius: 8px;
|
|
62
|
+
background: #0a1019;
|
|
63
|
+
box-shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.panel-meta,
|
|
67
|
+
.interaction-bar {
|
|
68
|
+
display: flex;
|
|
69
|
+
align-items: center;
|
|
70
|
+
justify-content: space-between;
|
|
71
|
+
min-height: 66px;
|
|
72
|
+
padding: 14px 18px;
|
|
73
|
+
border-color: #202d3b;
|
|
74
|
+
background: #0d151f;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.panel-meta {
|
|
78
|
+
border-bottom: 1px solid #202d3b;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.panel-meta > div:first-child {
|
|
82
|
+
display: grid;
|
|
83
|
+
gap: 3px;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.catalog-label {
|
|
87
|
+
color: #7f92a5;
|
|
88
|
+
font-size: 10px;
|
|
89
|
+
font-weight: 700;
|
|
90
|
+
letter-spacing: 0;
|
|
91
|
+
text-transform: uppercase;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.panel-meta strong {
|
|
95
|
+
color: #f7fbff;
|
|
96
|
+
font-size: 14px;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.sky-key {
|
|
100
|
+
display: flex;
|
|
101
|
+
align-items: center;
|
|
102
|
+
gap: 8px;
|
|
103
|
+
color: #a7b6c5;
|
|
104
|
+
font-size: 12px;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.sky-key span {
|
|
108
|
+
width: 8px;
|
|
109
|
+
height: 8px;
|
|
110
|
+
border-radius: 50%;
|
|
111
|
+
background: #f5c878;
|
|
112
|
+
box-shadow: 0 0 12px rgba(245, 200, 120, 0.76);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.scene-host {
|
|
116
|
+
position: relative;
|
|
117
|
+
width: 100%;
|
|
118
|
+
height: clamp(430px, 62vh, 650px);
|
|
119
|
+
min-height: 430px;
|
|
120
|
+
background: #060b14;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.scene-host .kchart-three-canvas {
|
|
124
|
+
display: block;
|
|
125
|
+
width: 100%;
|
|
126
|
+
height: 100%;
|
|
127
|
+
outline: none;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.interaction-bar {
|
|
131
|
+
min-height: 54px;
|
|
132
|
+
border-top: 1px solid #202d3b;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.interaction-bar p {
|
|
136
|
+
margin: 0;
|
|
137
|
+
font-size: 12px;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
#star-status {
|
|
141
|
+
color: #c7d5e1;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.interaction-hint {
|
|
145
|
+
color: #718395;
|
|
146
|
+
white-space: nowrap;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
@media (max-width: 680px) {
|
|
150
|
+
.page-shell {
|
|
151
|
+
width: min(100% - 20px, 1120px);
|
|
152
|
+
padding-top: 24px;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.intro {
|
|
156
|
+
grid-template-columns: 1fr;
|
|
157
|
+
gap: 10px;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.eyebrow {
|
|
161
|
+
margin-bottom: 0;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.scene-host {
|
|
165
|
+
height: min(62vh, 520px);
|
|
166
|
+
min-height: 390px;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.interaction-bar {
|
|
170
|
+
align-items: flex-start;
|
|
171
|
+
gap: 12px;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>KChart Waterfall Basic</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<main class="page-shell">
|
|
10
|
+
<header class="intro">
|
|
11
|
+
<p class="eyebrow">Finance review</p>
|
|
12
|
+
<h1>Q2 operating profit bridge</h1>
|
|
13
|
+
<p>Movement from first-quarter operating profit to the second-quarter result, in USD millions.</p>
|
|
14
|
+
</header>
|
|
15
|
+
<section class="chart-panel">
|
|
16
|
+
<div class="data-key" aria-label="Bar colors">
|
|
17
|
+
<span><i style="--key-color:#34d399"></i>Increase</span>
|
|
18
|
+
<span><i style="--key-color:#fb7185"></i>Decrease</span>
|
|
19
|
+
<span><i style="--key-color:#38bdf8"></i>Total</span>
|
|
20
|
+
</div>
|
|
21
|
+
<div id="chart"></div>
|
|
22
|
+
</section>
|
|
23
|
+
</main>
|
|
24
|
+
<script type="module" src="/src/main.ts"></script>
|
|
25
|
+
</body>
|
|
26
|
+
</html>
|