Vector Map
vector-mapuiReact mirror of @uipkge/vector-map — see the Vue registry item for the canonical description.
Installation
$pnpm dlx shadcn@latest add https://uipkge.dev/r/lit/vector-map.json$npx shadcn@latest add https://uipkge.dev/r/lit/vector-map.json$yarn dlx shadcn@latest add https://uipkge.dev/r/lit/vector-map.json$bunx shadcn@latest add https://uipkge.dev/r/lit/vector-map.jsonManifest:
https://uipkge.dev/r/lit/vector-map.jsonInstalls to:src/uip/components/charts/Examples
Loading interactive previews…
Loading interactive previews…
Props
| Name | Type / Values | Default | Required |
|---|---|---|---|
mode | 'countries' | 'continents' | continents | optional |
regions | MapRegion[] | WORLD_REGIONS | optional |
region-data | Record<string, RegionDataRecord> | {} | optional |
selected-region | string | — | optional |
pins | VectorMapPin[] | [] | optional |
routes | FlowRoute[] | [] | optional |
height | number | string | 460 | optional |
interactive | string | true | optional |
show-graticule | string | true | optional |
show-region-labels | string | true | optional |
fill-color | string | — | optional |
hover-color | string | — | optional |
stroke-color | string | — | optional |
projection | 'globe' | 'mercator' | globe | optional |
access-token | string | — | optional |
aria-label | string | — | optional |
Schema
Type aliases from this item's source — use them to shape the data you pass in.
MapRegioninterface MapRegion {
id: string
name: string
path?: string
}VectorMapPininterface VectorMapPin {
id?: string
lat?: number
lng?: number
x?: number
y?: number
label?: string
value?: string | number
color?: string
status?: string
description?: string
}FlowRouteinterface FlowRoute {
id?: string
from: { lat?: number; lng?: number; x?: number; y?: number }
to: { lat?: number; lng?: number; x?: number; y?: number }
color?: string
width?: number
curvature?: number
animated?: boolean
dashed?: boolean
duration?: number
label?: string
}RegionDataRecordinterface RegionDataRecord {
value?: number
label?: string
status?: string
color?: string
description?: string
}HTMLElementTagNameMapinterface HTMLElementTagNameMap {
'uip-vector-map': UipVectorMap
}
}ChartThemeinterface ChartTheme {
colors: string[]
textColor: string
axisColor: string
splitLineColor: string
tooltipBg: string
tooltipBorder: string
tooltipText: string
bgColor: string
accentColor: string
dangerColor: string
/** `--card`: cell borders and inside-label text, so they read as gaps /
* contrast on light and dark surfaces (never '#fff'). */
surfaceColor: string
/** `--foreground`: primary numbers drawn on the canvas (gauge value). */
foregroundColor: string
/** Gauge stoplight from the status tokens, same rule as <uip-usage-bar>:
* < 70% success, 70-89% warning, >= 90% destructive. */
semanticGaugeThresholds: [number, string][]
}Used by
Files installed (4)
src/uip/components/charts/vector-map.ts12.2 kB
import { LitElement, css, html } from 'lit' import { styleMap } from 'lit/directives/style-map.js' import { Globe } from 'lucide' import { tailwind } from '../../lib/styles' import { ThemeController } from '../../lib/theme' import { icon } from '../../lib/icon' import { cn } from '../../lib/utils' import { heightToStyle } from './lib/chart-theme' import { defaultTrue } from './lib/chart-element' import '../map/map' export interface MapRegion { id: string name: string path?: string } export interface VectorMapPin { id?: string lat?: number lng?: number x?: number y?: number label?: string value?: string | number color?: string status?: string description?: string } export interface FlowRoute { id?: string from: { lat?: number; lng?: number; x?: number; y?: number } to: { lat?: number; lng?: number; x?: number; y?: number } color?: string width?: number curvature?: number animated?: boolean dashed?: boolean duration?: number label?: string } export interface RegionDataRecord { value?: number label?: string status?: string color?: string description?: string } export const WORLD_REGIONS: MapRegion[] = [ { id: 'northAmerica', name: 'North America' }, { id: 'southAmerica', name: 'South America' }, { id: 'europe', name: 'Europe' }, { id: 'asia', name: 'Asia' }, { id: 'africa', name: 'Africa' }, { id: 'australiaOceania', name: 'Oceania' }, { id: 'unitedKingdom', name: 'United Kingdom' }, { id: 'japan', name: 'Japan' }, ] export const WORLD_COUNTRIES: MapRegion[] = [ { id: 'US', name: 'United States' }, { id: 'CA', name: 'Canada' }, { id: 'GB', name: 'United Kingdom' }, { id: 'DE', name: 'Germany' }, { id: 'FR', name: 'France' }, { id: 'JP', name: 'Japan' }, { id: 'CN', name: 'China' }, { id: 'IN', name: 'India' }, { id: 'BR', name: 'Brazil' }, { id: 'AU', name: 'Australia' }, ] export function projectPoint(pt: { lat?: number; lng?: number; x?: number; y?: number }) { if (pt.x !== undefined && pt.y !== undefined) return { x: pt.x, y: pt.y } const lng = pt.lng ?? 0 const lat = pt.lat ?? 0 const x = ((lng + 180) / 360) * 1000 const y = ((90 - lat) / 180) * 500 return { x, y } } /** * <uip-vector-map> — the registry VectorMap (React `VectorMap`) as a web * component. Same region chips, pins, routes, record/hover cards and * projection toggle as React, rendered on the shipped <uip-map> * (declarative sources, layers and markers as its light-DOM children — the * web-component stand-in for React's JSX children). * * Properties (React props): `mode` ('countries' | 'continents'; default * 'continents'), `regions` (default WORLD_REGIONS), `region-data` (Record<id, * RegionDataRecord>), `selected-region`, `pins`, `routes`, `height` (default * 460), `interactive` (default true), `show-graticule` (accepted like React, * unused), `show-region-labels` (accepted like React, unused), `fill-color` / * `hover-color` / `stroke-color` (accepted like React, unused), `projection` * (initial 'globe' | 'mercator'), `aria-label` (React `ariaLabel`). * `access-token` forwards a Mapbox token to the inner map (elements never * read the environment). React's `className` → host classes. * * Events: `selected-region-change` (detail: id — React's * `onSelectedRegionChange`). */ export class UipVectorMap extends LitElement { // :host display can't be a utility class (the host has no template of its own). static styles = [tailwind, css`:host { display: block; }`] static properties = { mode: {}, regions: { type: Array }, regionData: { attribute: 'region-data', type: Object }, selectedRegion: { attribute: 'selected-region' }, pins: { type: Array }, routes: { type: Array }, height: {}, interactive: { converter: defaultTrue }, showGraticule: { attribute: 'show-graticule', converter: defaultTrue }, showRegionLabels: { attribute: 'show-region-labels', converter: defaultTrue }, fillColor: { attribute: 'fill-color' }, hoverColor: { attribute: 'hover-color' }, strokeColor: { attribute: 'stroke-color' }, projection: {}, accessToken: { attribute: 'access-token' }, accessibleLabel: { attribute: 'aria-label' }, internalRegion: { state: true }, hoveredPin: { state: true }, } mode: 'countries' | 'continents' = 'continents' regions: MapRegion[] = WORLD_REGIONS regionData: Record<string, RegionDataRecord> = {} selectedRegion?: string pins: VectorMapPin[] = [] routes: FlowRoute[] = [] height: number | string = 460 interactive = true showGraticule = true showRegionLabels = true fillColor?: string hoverColor?: string strokeColor?: string projection: 'globe' | 'mercator' = 'globe' accessToken?: string accessibleLabel?: string private internalRegion = 'northAmerica' private hoveredPin: VectorMapPin | null = null constructor() { super() new ThemeController(this) } connectedCallback() { super.connectedCallback() this.setAttribute('data-uipkge', '') this.setAttribute('data-slot', 'vector-map') } private get activeRegion() { return this.selectedRegion !== undefined ? this.selectedRegion : this.internalRegion } private handleSelectRegion(id: string) { if (!this.interactive) return this.internalRegion = id this.dispatchEvent(new CustomEvent('selected-region-change', { detail: id, bubbles: true, composed: true })) } private toggleProjection() { this.projection = this.projection === 'globe' ? 'mercator' : 'globe' } private get routesGeoJson() { const routes = this.routes ?? [] if (!routes.length) return null return { type: 'FeatureCollection', features: routes.map((r, i) => { const fromLng = r.from.lng ?? -74 const fromLat = r.from.lat ?? 40 const toLng = r.to.lng ?? 8 const toLat = r.to.lat ?? 50 return { type: 'Feature', id: i, properties: { color: r.color || 'rgba(56, 189, 248, 0.75)', }, geometry: { type: 'LineString', coordinates: [ [fromLng, fromLat], [(fromLng + toLng) / 2, (fromLat + toLat) / 2 + 5], [toLng, toLat], ], }, } }), } } render() { const regions = this.regions ?? WORLD_REGIONS const activeRegion = this.activeRegion const activeRecord = (this.regionData ?? {})[activeRegion] || null const routesGeoJson = this.routesGeoJson const hoveredPin = this.hoveredPin return html`<div part="base" aria-label=${this.accessibleLabel ?? 'Vector map'} style=${styleMap({ height: heightToStyle(this.height) })} class="border-border bg-card group relative w-full overflow-hidden rounded-xl border shadow-xs" > <uip-map .accessToken=${this.accessToken} variant="dark" .projection=${this.projection} .center=${[10, 25]} .zoom=${1.6} class="size-full" > ${routesGeoJson ? html`<uip-map-source id="vector-routes-source" type="geojson" .data=${routesGeoJson}> <uip-map-layer id="vector-routes-layer" type="line" .paint=${{ 'line-color': ['get', 'color'] as any, 'line-width': 1.5, 'line-dasharray': [2, 2] }} ></uip-map-layer> </uip-map-source>` : null} ${(this.pins ?? []).map( (pin) => html`<uip-map-marker longitude=${pin.lng ?? 0} latitude=${pin.lat ?? 0} anchor="center" class="cursor-pointer select-none"> <div class="relative flex size-6 items-center justify-center" @mouseenter=${() => (this.hoveredPin = pin)} @mouseleave=${() => (this.hoveredPin = null)} > <span class="absolute inline-flex size-full animate-ping rounded-full opacity-60" style=${styleMap({ backgroundColor: pin.color || 'oklch(0.65 0.20 145)' })} ></span> <span class="ring-background relative inline-flex size-2.5 rounded-full shadow-xs ring-2" style=${styleMap({ backgroundColor: pin.color || 'oklch(0.65 0.20 145)', boxShadow: `0 0 10px ${pin.color || 'oklch(0.65 0.20 145)'}`, })} ></span> </div> </uip-map-marker>`, )} </uip-map> <div class="border-border/70 bg-card/85 absolute top-3 left-3 z-10 hidden max-w-md flex-wrap gap-1 rounded-lg border p-1.5 shadow-xs backdrop-blur-md md:flex" > ${regions.map( (r) => html`<button type="button" class=${cn( 'rounded-md px-2 py-0.5 text-xs font-medium transition', activeRegion === r.id ? 'bg-primary text-primary-foreground font-semibold' : 'text-muted-foreground hover:bg-muted hover:text-foreground', )} @click=${() => this.handleSelectRegion(r.id)} > ${r.name} </button>`, )} </div> <div class="border-border/70 bg-card/85 absolute top-3 right-3 z-10 flex items-center gap-1 rounded-lg border p-1 shadow-xs backdrop-blur-md" > <button type="button" class="text-muted-foreground hover:bg-muted hover:text-foreground flex items-center gap-1.5 rounded-md px-2.5 py-1 text-xs font-medium transition" @click=${this.toggleProjection} > ${icon(Globe, 'globe', 'size-3.5')} <span class="capitalize">${this.projection}</span> </button> </div> ${activeRecord ? html`<div class="border-border/80 bg-card/95 animate-in fade-in slide-in-from-bottom-2 absolute bottom-3 left-3 z-10 max-w-sm rounded-xl border p-3.5 shadow-lg backdrop-blur-md duration-150" > <div class="flex items-center gap-2"> <span class="size-2 rounded-full" style=${styleMap({ backgroundColor: activeRecord.color || 'oklch(0.65 0.20 145)' })} ></span> <h4 class="text-foreground text-sm font-semibold capitalize">${activeRegion.replace(/([A-Z])/g, ' $1')}</h4> <span class="text-muted-foreground ml-auto font-mono text-xs uppercase">${activeRecord.status || 'Optimal'}</span> </div> ${activeRecord.value !== undefined ? html`<div class="border-border/60 mt-2.5 flex items-baseline justify-between border-t pt-2 font-mono text-xs"> <span class="text-muted-foreground">Active Nodes</span> <span class="text-foreground font-semibold">${activeRecord.value.toLocaleString()}</span> </div>` : null} ${activeRecord.description ? html`<p class="text-muted-foreground mt-1.5 text-xs leading-relaxed">${activeRecord.description}</p>` : null} </div>` : null} ${hoveredPin ? html`<div class="border-border/80 bg-card/95 animate-in fade-in slide-in-from-bottom-2 absolute right-3 bottom-3 z-10 max-w-xs rounded-xl border p-3 shadow-lg backdrop-blur-md duration-150" > <div class="flex items-center gap-2"> <span class="size-2 rounded-full" style=${styleMap({ backgroundColor: hoveredPin.color || 'oklch(0.65 0.20 145)' })} ></span> <h5 class="text-foreground text-xs font-semibold">${hoveredPin.label || 'Hub'}</h5> </div> ${hoveredPin.description ? html`<p class="text-muted-foreground mt-1 text-xs">${hoveredPin.description}</p>` : null} ${hoveredPin.value !== undefined ? html`<div class="border-border/60 mt-2 flex items-baseline justify-between border-t pt-1.5 font-mono text-xs"> <span class="text-muted-foreground">Throughput</span> <span class="text-foreground font-semibold">${hoveredPin.value}</span> </div>` : null} </div>` : null} </div>` } } customElements.get('uip-vector-map') || customElements.define('uip-vector-map', UipVectorMap) declare global { interface HTMLElementTagNameMap { 'uip-vector-map': UipVectorMap } }src/uip/components/charts/lib/chart-element.ts4.9 kB
import { LitElement, css, html, type PropertyDeclarations, type PropertyValues } from 'lit' import { styleMap } from 'lit/directives/style-map.js' import type { ECharts } from 'echarts/core' import { tailwind } from '../../../lib/styles' import { ThemeController } from '../../../lib/theme' import { heightToStyle, resolveChartTheme, subscribeChartTheme, type ChartTheme } from './chart-theme' /** * Attribute converter for booleans whose React default is `true` * (`showLabels`, `autoresize`): Lit's `type: Boolean` can't be switched off * from markup, so `show-labels="false"` turns it off and anything else * (including removing the attribute) means true. */ export const defaultTrue = { fromAttribute: (v: string | null) => v !== 'false', toAttribute: (v: boolean) => (v ? '' : 'false'), } /** * `yField="value"` from markup, `yField=['north', 'south']` from markup as a * JSON array or from JS as a property. */ export const stringOrArray = { fromAttribute: (v: string | null) => (v?.trim().startsWith('[') ? (JSON.parse(v) as string[]) : v), } /** * Shared base for every ECharts-backed element — the Lit stand-in for React's * `ChartFrame` + `EChart` + `useChartTheme()`: * * - renders React's ChartFrame chrome (role="img", tabindex, focus ring, * `height`) with a full-size inner container for the canvas; * - resolves the chart theme from the CSS tokens and re-resolves it (and * re-sets the option) whenever <html> class/style/data-theme changes; * - lazily `import()`s echarts in firstUpdated (SSR-safe: nothing runs on the * server), resizes with a ResizeObserver and disposes on disconnect; * - applies `buildOption()` with `{ notMerge: true, lazyUpdate: true }`, * exactly like React's EChart. * * Subclasses implement `buildOption()` (React's `mergedOption` useMemo) and * set `chartSlot` (the host's data-slot). `instance` exposes the ECharts * instance (undefined until initialised) for getOption()/dispatchAction(). */ export abstract class ChartElement extends LitElement { // :host display can't be a utility class (the host has no template of its own). static styles = [tailwind, css`:host { display: block; }`] static properties: PropertyDeclarations = { height: {}, // role="img" lives on the inner frame, so the host's aria-label is forwarded. accessibleLabel: { attribute: 'aria-label' }, chartTheme: { state: true }, } height: number | string = 300 accessibleLabel?: string protected chartTheme: ChartTheme = resolveChartTheme() /** Resize with the container. Only RawChart exposes it as a property. */ protected autoresize = true protected abstract readonly chartSlot: string protected abstract buildOption(): any private chart?: ECharts private resizeObserver?: ResizeObserver private unsubscribeTheme?: () => void constructor() { super() new ThemeController(this) } /** The ECharts instance, once initialised in the browser. */ get instance(): ECharts | undefined { return this.chart } connectedCallback() { super.connectedCallback() this.setAttribute('data-uipkge', '') this.setAttribute('data-slot', this.chartSlot) this.chartTheme = resolveChartTheme() this.unsubscribeTheme = subscribeChartTheme(() => { this.chartTheme = resolveChartTheme() }) // Re-attached after a move: firstUpdated won't run again. if (this.hasUpdated) void this.initChart() } disconnectedCallback() { super.disconnectedCallback() this.unsubscribeTheme?.() this.resizeObserver?.disconnect() this.resizeObserver = undefined this.chart?.dispose() this.chart = undefined } protected firstUpdated() { void this.initChart() } protected updated(changed: PropertyValues) { if (!this.chart) return if (changed.has('autoresize')) this.observeResize() this.chart.setOption(this.buildOption(), { notMerge: true, lazyUpdate: true }) } private get container() { return this.renderRoot.querySelector<HTMLDivElement>('[data-chart]') } private async initChart() { const { echarts } = await import('./echarts') const el = this.container if (!this.isConnected || this.chart || !el) return this.chart = echarts.init(el) this.chart.setOption(this.buildOption(), { notMerge: true, lazyUpdate: true }) this.observeResize() } private observeResize() { this.resizeObserver?.disconnect() this.resizeObserver = undefined const el = this.container if (!this.autoresize || !el) return this.resizeObserver = new ResizeObserver(() => this.chart?.resize()) this.resizeObserver.observe(el) } render() { return html`<div part="base" role="img" aria-label=${this.accessibleLabel || 'Chart'} tabindex="0" style=${styleMap({ height: heightToStyle(this.height) })} class="focus-visible:ring-ring w-full focus-visible:ring-2 focus-visible:outline-none" > <div data-chart class="h-full w-full"></div> </div>` } }src/uip/components/charts/lib/chart-theme.ts7.1 kB
import { isServer } from 'lit' // Port of packages/registry-react/components/charts/useChartTheme.ts. // // The chart palette is driven by the design tokens (`--chart-1`..`--chart-5`, // `--muted-foreground`, `--border`, `--popover`, …). They are resolved with // getComputedStyle on <html> and re-resolved whenever <html> class / style / // data-theme changes, so a light/dark flip re-colours every chart. Instead of // React's useChartTheme() hook, elements call subscribeChartTheme(). const listeners = new Set<() => void>() let observing = false function bump() { listeners.forEach((l) => l()) } /** Call `cb` whenever the page theme changes. Returns the unsubscribe fn. */ export function subscribeChartTheme(cb: () => void): () => void { listeners.add(cb) if (!observing && !isServer) { observing = true // Same as React: one bump on the first frame (tokens resolved after the // stylesheet applies), then on every <html> class/style/data-theme change. requestAnimationFrame(bump) new MutationObserver(bump).observe(document.documentElement, { attributes: true, attributeFilter: ['class', 'style', 'data-theme'], }) } return () => listeners.delete(cb) } // ECharts' canvas renderer does not accept OKLCH in every browser. Assigning // one of our Tailwind tokens to `fillStyle` can silently leave the sentinel // colour in place, turning a whole chart black. Convert OKLCH ourselves and // let the canvas normalize older CSS colour formats. let _hexCanvas: CanvasRenderingContext2D | null = null export function toCanvasColor(cssColor: string): string { const value = cssColor.trim() const match = value.match( /^oklch\(\s*([+-]?(?:\d+\.?\d*|\.\d+))(%?)\s+([+-]?(?:\d+\.?\d*|\.\d+))\s+([+-]?(?:\d+\.?\d*|\.\d+))(?:deg)?(?:\s*\/\s*([+-]?(?:\d+\.?\d*|\.\d+))(%?))?\s*\)$/i, ) if (match) { const lightness = Number(match[1]) / (match[2] === '%' ? 100 : 1) const chroma = Number(match[3]) const hue = (Number(match[4]) * Math.PI) / 180 const alpha = match[5] == null ? 1 : Number(match[5]) / (match[6] === '%' ? 100 : 1) const a = chroma * Math.cos(hue) const b = chroma * Math.sin(hue) const l = Math.pow(lightness + 0.3963377774 * a + 0.2158037573 * b, 3) const m = Math.pow(lightness - 0.1055613458 * a - 0.0638541728 * b, 3) const s = Math.pow(lightness - 0.0894841775 * a - 1.291485548 * b, 3) const linear = [ 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s, -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s, -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s, ] const rgb = linear.map((channel) => { const encoded = channel <= 0.0031308 ? 12.92 * channel : 1.055 * Math.pow(channel, 1 / 2.4) - 0.055 return Math.round(Math.min(1, Math.max(0, encoded)) * 255) }) return alpha < 1 ? `rgba(${rgb.join(', ')}, ${alpha})` : `rgb(${rgb.join(', ')})` } if (isServer) return cssColor if (!_hexCanvas) { _hexCanvas = document.createElement('canvas').getContext('2d') } if (!_hexCanvas) return cssColor _hexCanvas.fillStyle = '#010203' _hexCanvas.fillStyle = value const normalized = _hexCanvas.fillStyle as string return normalized === '#010203' && value.toLowerCase() !== '#010203' ? value : normalized } // Convert any CSS color (hex, rgb, oklch, color()) + alpha 0..1 to a // canvas-safe rgba(r,g,b,a). export function toRgba(cssColor: string, alpha: number): string { const normalized = toCanvasColor(cssColor) if (normalized.startsWith('#') && normalized.length === 7) { const r = parseInt(normalized.slice(1, 3), 16) const g = parseInt(normalized.slice(3, 5), 16) const b = parseInt(normalized.slice(5, 7), 16) return `rgba(${r},${g},${b},${alpha})` } if (normalized.startsWith('rgba(')) { return normalized.replace(/,\s*[\d.]+\s*\)$/, `,${alpha})`) } if (normalized.startsWith('rgb(')) { return normalized.replace(/^rgb\(/, 'rgba(').replace(/\)$/, `,${alpha})`) } return cssColor } export function resolveVar(name: string, fallback: string): string { if (isServer) return fallback const v = getComputedStyle(document.documentElement).getPropertyValue(name).trim() if (!v) return fallback return toCanvasColor(v) } // SSR / pre-hydration fallback palette (same values as React). const CHART_FALLBACK = ['#f59e0b', '#14b8a6', '#3b82f6', '#f97316', '#eab308'] /** The resolved chart theme tokens. All values are canvas-safe hex/rgba. */ export interface ChartTheme { colors: string[] textColor: string axisColor: string splitLineColor: string tooltipBg: string tooltipBorder: string tooltipText: string bgColor: string accentColor: string dangerColor: string /** `--card`: cell borders and inside-label text, so they read as gaps / * contrast on light and dark surfaces (never '#fff'). */ surfaceColor: string /** `--foreground`: primary numbers drawn on the canvas (gauge value). */ foregroundColor: string /** Gauge stoplight from the status tokens, same rule as <uip-usage-bar>: * < 70% success, 70-89% warning, >= 90% destructive. */ semanticGaugeThresholds: [number, string][] } export function resolveChartTheme(): ChartTheme { return { colors: Array.from({ length: 5 }, (_, i) => resolveVar(`--chart-${i + 1}`, CHART_FALLBACK[i]!)), textColor: resolveVar('--muted-foreground', '#888888'), axisColor: resolveVar('--border', '#e5e5e5'), splitLineColor: resolveVar('--border', '#f0f0f0'), tooltipBg: resolveVar('--popover', 'rgba(255,255,255,0.96)'), tooltipBorder: resolveVar('--border', '#e5e5e5'), tooltipText: resolveVar('--popover-foreground', '#333333'), bgColor: resolveVar('--card', resolveVar('--background', '#ffffff')), accentColor: resolveVar('--primary', '#38bdf8'), dangerColor: resolveVar('--destructive', '#dc2626'), surfaceColor: resolveVar('--card', '#ffffff'), foregroundColor: resolveVar('--foreground', '#171717'), semanticGaugeThresholds: [ [0.7, resolveVar('--success', '#14b8a6')], [0.9, resolveVar('--warning', '#f59e0b')], [1, resolveVar('--destructive', '#dc2626')], ], } } // Two-level deep merge for ECharts option blocks (verbatim from React): top-level // keys merge shallowly, and one nested level (axisLabel, splitLine, …) merges // shallowly too. Arrays + primitives replace outright — including a whole // block given as an array (e.g. `xAxis: [a, b]` for two axes). export function mergeOptionBlock<T extends Record<string, any>>(base: T, user: Partial<T> | undefined): T { if (!user) return base if (Array.isArray(user)) return user as unknown as T const out: any = { ...base } for (const k of Object.keys(user)) { const bv = (base as any)[k] const uv = (user as any)[k] if ( bv != null && uv != null && typeof bv === 'object' && typeof uv === 'object' && !Array.isArray(bv) && !Array.isArray(uv) ) { out[k] = { ...bv, ...uv } } else { out[k] = uv } } return out } /** `height` prop → CSS: bare digits are px, anything else is raw CSS. */ export function heightToStyle(height: number | string): string { return /^\d+$/.test(String(height)) ? `${height}px` : String(height) }src/uip/components/charts/lib/echarts.ts1.9 kB
// ECharts core with every chart type / component the React wrappers register // (same list as packages/registry-react/components/charts/shared.tsx), so // <uip-raw-chart> can render any of them. Only ever loaded with a dynamic // import() from ChartElement.firstUpdated — never at module scope — so the // elements stay SSR-safe and echarts stays out of the initial bundle. // (Lives in charts/lib/ so src/index.ts's components/*/*.ts glob skips it.) import * as echarts from 'echarts/core' import { CanvasRenderer } from 'echarts/renderers' import { LineChart, BarChart, PieChart, ScatterChart, EffectScatterChart, PictorialBarChart, RadarChart, GaugeChart, HeatmapChart, TreemapChart, FunnelChart, BoxplotChart, CandlestickChart, CustomChart, ChordChart, MapChart, GraphChart, ParallelChart, SankeyChart, SunburstChart, ThemeRiverChart, TreeChart, } from 'echarts/charts' import { GridComponent, PolarComponent, TooltipComponent, LegendComponent, MarkLineComponent, MarkAreaComponent, MarkPointComponent, GraphicComponent, RadarComponent, VisualMapComponent, CalendarComponent, DataZoomComponent, ParallelComponent, SingleAxisComponent, TitleComponent, } from 'echarts/components' echarts.use([ CanvasRenderer, LineChart, BarChart, PieChart, ScatterChart, EffectScatterChart, PictorialBarChart, RadarChart, GaugeChart, HeatmapChart, TreemapChart, FunnelChart, BoxplotChart, CandlestickChart, CustomChart, ChordChart, MapChart, GraphChart, ParallelChart, SankeyChart, SunburstChart, ThemeRiverChart, TreeChart, GridComponent, PolarComponent, TooltipComponent, LegendComponent, MarkLineComponent, MarkAreaComponent, MarkPointComponent, GraphicComponent, RadarComponent, VisualMapComponent, CalendarComponent, DataZoomComponent, ParallelComponent, SingleAxisComponent, TitleComponent, ]) export { echarts }
Raw manifest:https://uipkge.dev/r/lit/vector-map.json