Skip to content
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
20 changes: 10 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"canvas-confetti": "^1.9.4",
"chart.js": "^4.5.1",
"clsx": "^2.1.1",
"echarts": "^5.6.0",
"echarts": "^6.1.0",
"echarts-wordcloud": "^2.1.0",
"elkjs": "^0.11.1",
"idb": "^8.0.3",
Expand All @@ -116,6 +116,9 @@
},
"overrides": {
"dompurify": "^3.4.13",
"katex": "^0.18.2"
"katex": "^0.18.2",
"echarts-wordcloud": {
"echarts": "$echarts"
}
}
}
9 changes: 9 additions & 0 deletions src/lib/chart-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ import { resolveColor } from '$lib/geo-basemap.js'
/** @typedef {unknown[][]} Rows */

/** @param {ColInfo} col */
/**
* The echarts theme every chart is created with. echarts 6 changed its
* defaults (palette, visualMap ramp, treemap and sankey colors); its bundled
* `v5` theme (echarts/theme/v5) keeps charts looking as they did on 5, so the
* upgrade (for the XSS fix) changes nothing on screen. Import that theme
* before `init(dom, ECHARTS_THEME)`.
*/
export const ECHARTS_THEME = 'v5'

export function colType(col) {
const dt = (col.dataType ?? col.data_type ?? '').toLowerCase().replace(/\(.+\)$/, '').trim()
if (/^(int|integer|bigint|smallint|numeric|decimal|real|double|float|serial|money|number)/.test(dt)) return 'number'
Expand Down
4 changes: 3 additions & 1 deletion src/lib/components/AiChartRenderer.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script>
import { ECHARTS_THEME } from '$lib/chart-utils.js'
import { chartRows } from '$lib/ai-chart-data.js'
/**
* Renders AI-generated charts using ECharts + the shared buildOption() utility.
Expand Down Expand Up @@ -104,10 +105,11 @@
initializing = true
try {
const { init } = await import('echarts')
await import('echarts/theme/v5')
// Register the wordcloud series plugin lazily (keeps echarts out of startup bundle).
await import('echarts-wordcloud')
if (disposed) return
const instance = init(container, null, {
const instance = init(container, ECHARTS_THEME, {
renderer: 'canvas',
devicePixelRatio: window.devicePixelRatio || 2,
})
Expand Down
4 changes: 3 additions & 1 deletion src/lib/components/ChartView.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script>
import { ECHARTS_THEME } from '$lib/chart-utils.js'
import SelectMenu from './SelectMenu.svelte'
import Icon from './Icon.svelte'
import SearchableMenu from './SearchableMenu.svelte'
Expand Down Expand Up @@ -273,8 +274,9 @@
document.body.appendChild(host)
try {
const { init } = await import('echarts')
await import('echarts/theme/v5')
await import('echarts-wordcloud')
const inst = init(host, null, { renderer: 'svg' })
const inst = init(host, ECHARTS_THEME, { renderer: 'svg' })
inst.setOption(option, { notMerge: true })
const svg = host.querySelector('svg')?.outerHTML ?? ''
inst.dispose()
Expand Down
4 changes: 3 additions & 1 deletion src/lib/components/ChoroplethChart.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script>
import { ECHARTS_THEME } from '$lib/chart-utils.js'
import { onDestroy } from 'svelte'
import { isCurrentThemeDark } from '$lib/stores/settings.js'
import { getWorldGeoJson } from '$lib/geo.js'
Expand Down Expand Up @@ -83,12 +84,13 @@

// Container stays mounted throughout - safe to proceed
const { init, registerMap } = await import('echarts')
await import('echarts/theme/v5')
if (!container.isConnected) return

registerMap('world', geoJson)

if (chart) { chart.dispose(); chart = null }
const instance = init(container, null, {
const instance = init(container, ECHARTS_THEME, {
renderer: 'canvas',
devicePixelRatio: window.devicePixelRatio || 2,
})
Expand Down
4 changes: 3 additions & 1 deletion src/lib/components/EChartPanel.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script>
import { ECHARTS_THEME } from '$lib/chart-utils.js'
import { onDestroy } from 'svelte'

let {
Expand Down Expand Up @@ -55,13 +56,14 @@
initializing = true
try {
const { init } = await import('echarts')
await import('echarts/theme/v5')
// Register the wordcloud series plugin lazily (keeps echarts out of startup bundle).
await import('echarts-wordcloud')
if (disposed) return
const opts = renderer === 'canvas'
? { renderer: /** @type {'canvas'} */ ('canvas'), devicePixelRatio: window.devicePixelRatio || 2 }
: { renderer: /** @type {'svg'} */ ('svg') }
chart = init(container, null, opts)
chart = init(container, ECHARTS_THEME, opts)
} finally {
initializing = false
}
Expand Down
Loading