Skip to content

Commit 14c5e65

Browse files
afuchereca-agent
andcommitted
fix(website): animation error and gallery code snippet readability
Fix animation demo crashing with "Data is not set": - Transit.animate() requires (data, duration, isReverse, callback) — was called with no arguments, causing validate() to throw on undefined data - Add animateTargetData to demoData.ts (planets shifted ~30–90° from the initial transit so movement is clearly visible) - Pass animateTargetData via define:vars to the inline script - Button now toggles forward/back between transitData and animateTargetData - Duration passed as 2 (seconds, the library multiplies by 1000 internally) Fix gallery/guide code snippet hard to read in dark mode: - Replace light #f5f5f5 pre background with dark #1e1e2e (Catppuccin Mocha) - Set explicit code color #cdd6f4 (light lavender) for contrast on both light and dark mode - Add a subtle border so the block has definition on any background 🤖 Generated with [eca](https://eca.dev) Co-Authored-By: eca <git@eca.dev>
1 parent a227bdd commit 14c5e65

2 files changed

Lines changed: 48 additions & 3 deletions

File tree

website/src/components/ChartDemo.astro

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export interface Props {
1616
showCode?: boolean
1717
}
1818
19-
import { defaultRadixData, defaultTransitData } from '../data/demoData'
19+
import { defaultRadixData, defaultTransitData, animateTargetData } from '../data/demoData'
2020
2121
const {
2222
id,
@@ -84,6 +84,7 @@ const codeSnippet = getCodeSnippet()
8484
chartHeight: height,
8585
radixData: defaultRadixData,
8686
transitData: defaultTransitData,
87+
animateTargetData: animateTargetData,
8788
baseUrl: import.meta.env.BASE_URL
8889
}}
8990
>
@@ -104,11 +105,15 @@ const codeSnippet = getCodeSnippet()
104105
chart.radix(radixData).aspects()
105106
} else if (chartMode === 'animate') {
106107
const transit = chart.radix(radixData).transit(transitData)
108+
var isForward = true
107109

108110
const animateBtn = document.getElementById(chartId + '-animate-btn')
109111
if (animateBtn) {
110112
animateBtn.addEventListener('click', function () {
111-
transit.animate()
113+
var target = isForward ? animateTargetData : transitData
114+
transit.animate(target, 2, false, function () {
115+
isForward = !isForward
116+
})
112117
})
113118
}
114119
}
@@ -190,16 +195,18 @@ const codeSnippet = getCodeSnippet()
190195
}
191196

192197
.code-snippet pre {
193-
background: #f5f5f5;
198+
background: #1e1e2e;
194199
padding: 1rem;
195200
border-radius: 0.5rem;
196201
overflow-x: auto;
197202
margin-top: 0.5rem;
198203
font-size: 0.875rem;
199204
line-height: 1.5;
205+
border: 1px solid rgba(255, 255, 255, 0.08);
200206
}
201207

202208
.code-snippet code {
203209
font-family: 'Courier New', monospace;
210+
color: #cdd6f4;
204211
}
205212
</style>

website/src/data/demoData.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,41 @@ export const animationData = {
9494
radix: defaultRadixData,
9595
transit: defaultTransitData
9696
}
97+
98+
/**
99+
* Target transit data for animation demo.
100+
* Planets are shifted ~30–90° from defaultTransitData so the animation is visible.
101+
*/
102+
export const animateTargetData: AstroData = {
103+
planets: {
104+
Sun: [55.34, 0], // moved ~30°
105+
Moon: [242.45, 0], // Moon moves fast
106+
Mercury: [82.67, 0],
107+
Venus: [98.12, 0],
108+
Mars: [228.34, 0],
109+
Jupiter: [358.56, 0],
110+
Saturn: [318.78, 0],
111+
Uranus: [328.90, 0],
112+
Neptune: [355.12, 0],
113+
Pluto: [330.34, 0],
114+
Chiron: [198.67, 0],
115+
NNode: [92.45, 0],
116+
SNode: [272.45, 0],
117+
Lilith: [245.23, 0],
118+
Fortune: [75.67, 0]
119+
},
120+
cusps: [
121+
345.45,
122+
65.67,
123+
95.23,
124+
122.45,
125+
155.67,
126+
185.89,
127+
165.45,
128+
245.67,
129+
275.23,
130+
302.45,
131+
335.67,
132+
5.89
133+
]
134+
}

0 commit comments

Comments
 (0)