@weasel-js/plot 0.0.0-stage → 1.15.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 +21 -0
- package/README.md +58 -2
- package/dist/index.d.ts +679 -0
- package/dist/index.js +860 -0
- package/dist/index.js.map +1 -0
- package/package.json +50 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/scales/linear.ts","../src/scales/log.ts","../src/scales/band.ts","../src/scales/time.ts","../src/scales/ordinal.ts","../src/marks/boxes.ts","../src/marks/paths.ts","../src/marks/text.ts","../src/axes.ts","../src/theme.ts","../src/measure.ts","../src/xychart/compile.ts","../src/plotData.ts","../src/xychart/edit.ts","../src/plotScene.ts","../src/xychart/editor.ts","../src/editing/editors.ts","../src/editing/handleLayer.ts","../src/editing/dragAction.ts","../src/editing/plotEditing.ts","../src/PlotView.tsx"],"names":["at","n","GAP","scale","slots"],"mappings":";;;;;;;;AAiBA,IAAM,aAAA,GAAgB,CAAA;AAGf,SAAS,QAAA,CAAS,EAAA,EAAY,EAAA,EAAY,KAAA,GAAQ,aAAA,EAAuB;AAC9E,EAAA,MAAM,IAAA,GAAO,IAAA,CAAK,GAAA,CAAI,EAAA,GAAK,EAAE,CAAA;AAC7B,EAAA,IAAI,SAAS,CAAA,IAAK,CAAC,OAAO,QAAA,CAAS,IAAI,GAAG,OAAO,CAAA;AACjD,EAAA,MAAM,GAAA,GAAM,IAAA,GAAO,IAAA,CAAK,GAAA,CAAI,GAAG,KAAK,CAAA;AACpC,EAAA,MAAM,QAAQ,EAAA,IAAM,IAAA,CAAK,MAAM,IAAA,CAAK,KAAA,CAAM,GAAG,CAAC,CAAA;AAC9C,EAAA,MAAM,QAAQ,GAAA,GAAM,KAAA;AACpB,EAAA,MAAM,SAAS,KAAA,IAAS,IAAA,CAAK,KAAK,EAAE,CAAA,GAAI,KAAK,KAAA,IAAS,IAAA,CAAK,IAAA,CAAK,EAAE,IAAI,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A;AAAA,EACH,CAAA,EAAG,CAAC,KAAA,EAAO,OAAO,CAAC,CAAA;AAEnB,EAAA,MAAM,UAAU,OAAA,CAAQ,MAAM,YAAY,EAAE,KAAA,EAAuB,GAAI,OAAA,GAAU,EAAE,OAAA,EAAQ,GAAI,EAAC,EAAI,GAAG,CAAC,KAAA,EAAO,OAAO,CAAC,CAAA;AACvH,EAAA,MAAM,OAAA,GAAU,QAAQ,MAAM,CAAC,QAAQ,YAAY,CAAA,EAAG,CAAC,OAAO,CAAC,CAAA;AAC/D,EAAA,MAAM,CAAC,MAAA,EAAQ,SAAS,CAAA,GAAI,SAAgC,IAAI,CAAA;AAChE,EAAA,SAAA,CAAU,MAAO,MAAA,KAAW,IAAA,GAAO,MAAA,GAAY,MAAA,CAAO,aAAA,CAAc,OAAA,CAAQ,KAAK,CAAA,EAAI,CAAC,MAAA,EAAQ,OAAO,CAAC,CAAA;AAEtG,EAAA,uBACE,GAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAsB,eAAA,EAAc,EAAA,EACvC,QAAA,kBAAA,GAAA;AAAA,IAAC,WAAA;AAAA,IAAA;AAAA,MACC,GAAA,EAAK,SAAA;AAAA,MACL,KAAA;AAAA,MACA,QAAA,EAAU,QAAA;AAAA,MACV,iBAAA,EAAiB,IAAA;AAAA,MACjB,OAAA;AAAA,MACA,KAAA;AAAA,MACA,MAAA;AAAA,MACC,GAAI,UAAA,GAAa,EAAE,cAAA,EAAgB,UAAA,KAAe,EAAC;AAAA,MACnD,GAAI,KAAA,GAAQ,EAAE,YAAA,EAAc,KAAA,KAAU;AAAC;AAAA,GAC1C,EACF,CAAA;AAEJ","file":"index.js","sourcesContent":["import type { ContinuousScale } from './types';\n\n/** Options for {@link linearScale}. */\nexport interface LinearScaleOptions {\n domain: readonly [number, number];\n range: readonly [number, number];\n /** Widen the domain out to whole tick steps for about this many ticks. Default no widening. */\n nice?: number;\n}\n\n/** A scale that maps numbers proportionally, as a value axis does. */\nexport interface LinearScale extends ContinuousScale {\n readonly kind: 'linear';\n /** The distance between ticks when about `count` are asked for. */\n tickStep(count?: number): number;\n}\n\nconst DEFAULT_TICKS = 5;\n\n/** The round step, 1, 2 or 5 times a power of ten, that cuts `lo`..`hi` into about `count` pieces. */\nexport function tickStep(lo: number, hi: number, count = DEFAULT_TICKS): number {\n const span = Math.abs(hi - lo);\n if (span === 0 || !Number.isFinite(span)) return 1;\n const raw = span / Math.max(1, count);\n const power = 10 ** Math.floor(Math.log10(raw));\n const error = raw / power;\n const factor = error >= Math.sqrt(50) ? 10 : error >= Math.sqrt(10) ? 5 : error >= Math.sqrt(2) ? 2 : 1;\n return factor * power;\n}\n\n/** How many decimals a value on a grid of `step` needs. */\nexport const decimalsOf = (step: number): number => Math.max(0, -Math.floor(Math.log10(step) + 1e-9));\n\n/** `i` steps of `step`, without the float noise a bare product carries. */\nconst onGrid = (i: number, step: number): number => Number((i * step).toFixed(decimalsOf(step)));\n\n/** Every multiple of `step` from `lo` to `hi`, inclusive. */\nexport function stepTicks(lo: number, hi: number, step: number): number[] {\n const [a, b] = lo <= hi ? [lo, hi] : [hi, lo];\n const out: number[] = [];\n for (let i = Math.ceil(a / step - 1e-9); i <= Math.floor(b / step + 1e-9); i++) out.push(onGrid(i, step));\n return lo <= hi ? out : out.reverse();\n}\n\n/** `value` written as plainly as a grid of `step` allows: no trailing zeros, no exponent. */\nexport function formatNumber(value: number, step: number): string {\n const fixed = value.toFixed(Math.min(20, decimalsOf(step)));\n return fixed.includes('.') ? fixed.replace(/\\.?0+$/, '') : fixed;\n}\n\n/** `domain` widened to whole steps of a tick grid of about `count` ticks. */\nexport function niceDomain(domain: readonly [number, number], count = DEFAULT_TICKS): [number, number] {\n const [lo, hi] = domain;\n if (lo === hi) return lo === 0 ? [0, 1] : [Math.min(0, lo), Math.max(0, hi)];\n const step = tickStep(lo, hi, count);\n const down = (v: number) => onGrid(Math.floor(v / step + 1e-9), step);\n const up = (v: number) => onGrid(Math.ceil(v / step - 1e-9), step);\n return lo < hi ? [down(lo), up(hi)] : [up(lo), down(hi)];\n}\n\n/** A linear scale from `domain` onto `range`. */\nexport function linearScale(opts: LinearScaleOptions): LinearScale {\n const domain = opts.nice !== undefined ? niceDomain(opts.domain, opts.nice) : ([opts.domain[0], opts.domain[1]] as const);\n const range = [opts.range[0], opts.range[1]] as const;\n const [d0, d1] = domain;\n const [r0, r1] = range;\n const span = d1 - d0;\n const map = (v: number) => (span === 0 ? (r0 + r1) / 2 : r0 + ((v - d0) / span) * (r1 - r0));\n const step = (count = DEFAULT_TICKS) => tickStep(d0, d1, count);\n return {\n kind: 'linear',\n domain,\n range,\n map,\n position: map,\n invert: (at) => (r1 === r0 ? d0 : d0 + ((at - r0) / (r1 - r0)) * span),\n tickStep: step,\n ticks: (count = DEFAULT_TICKS) => stepTicks(d0, d1, step(count)),\n format: (v) => formatNumber(v, step()),\n };\n}\n","import { formatNumber } from './linear';\nimport type { ContinuousScale } from './types';\n\n/** Options for {@link logScale}. */\nexport interface LogScaleOptions {\n /** Both ends above zero. */\n domain: readonly [number, number];\n range: readonly [number, number];\n /** Default 10. */\n base?: number;\n}\n\n/** A scale that maps the logarithm of a value proportionally. */\nexport interface LogScale extends ContinuousScale {\n readonly kind: 'log';\n readonly base: number;\n}\n\n/** A logarithmic scale from `domain`, whose ends must both be above zero, onto `range`. */\nexport function logScale(opts: LogScaleOptions): LogScale {\n const base = opts.base ?? 10;\n const [d0, d1] = opts.domain;\n if (!(d0 > 0 && d1 > 0)) throw new Error(`logScale: a domain of ${d0}..${d1} does not lie above zero`);\n const [r0, r1] = opts.range;\n const log = (v: number) => Math.log(v) / Math.log(base);\n const l0 = log(d0);\n const l1 = log(d1);\n const map = (v: number) => (l1 === l0 ? (r0 + r1) / 2 : r0 + ((log(v) - l0) / (l1 - l0)) * (r1 - r0));\n const ticks = (count = 5): number[] => {\n const [lo, hi] = l0 <= l1 ? [l0, l1] : [l1, l0];\n const first = Math.floor(lo + 1e-9);\n const last = Math.ceil(hi - 1e-9);\n // Few decades get their 2s and 5s too, so a short axis still reads.\n const steps = last - first < count / 2 && base === 10 ? [1, 2, 5] : [1];\n const out: number[] = [];\n for (let p = first; p <= last; p++) {\n for (const m of steps) {\n const v = Number((m * base ** p).toPrecision(12));\n if (log(v) >= lo - 1e-9 && log(v) <= hi + 1e-9) out.push(v);\n }\n }\n return l0 <= l1 ? out : out.reverse();\n };\n return {\n kind: 'log',\n base,\n domain: [d0, d1],\n range: [r0, r1],\n map,\n position: map,\n invert: (at) => base ** (r1 === r0 ? l0 : l0 + ((at - r0) / (r1 - r0)) * (l1 - l0)),\n ticks,\n format: (v) => (v >= 1 ? formatNumber(v, 1) : formatNumber(v, 10 ** Math.floor(Math.log10(v)))),\n };\n}\n","import type { Scale } from './types';\n\n/** Options for {@link bandScale}. */\nexport interface BandScaleOptions {\n /** The categories, one band each, in order. */\n domain: readonly string[];\n range: readonly [number, number];\n /** The share of each step left empty between bands, 0 to 1. Default 0.2. */\n paddingInner?: number;\n /** The room before the first band and after the last, in steps. Default half of `paddingInner`. */\n paddingOuter?: number;\n}\n\n/** A scale that cuts its range into equal bands, one per category, as a bar chart's category axis does. */\nexport interface BandScale extends Scale<string> {\n readonly kind: 'band';\n readonly domain: readonly string[];\n /** The width of each band. */\n readonly bandwidth: number;\n /** From one band's start to the next's. */\n readonly step: number;\n /** Where `key`'s band starts, or `NaN` for a key not in the domain. */\n start(key: string): number;\n /** The key whose band is nearest `at`; `undefined` for an empty domain. */\n invert(at: number): string | undefined;\n}\n\n/** A band scale over `domain`. */\nexport function bandScale(opts: BandScaleOptions): BandScale {\n const domain = [...opts.domain];\n const [r0, r1] = opts.range;\n const inner = Math.min(1, Math.max(0, opts.paddingInner ?? 0.2));\n const outer = Math.max(0, opts.paddingOuter ?? inner / 2);\n const n = domain.length;\n const step = n === 0 ? 0 : (r1 - r0) / Math.max(1e-9, n - inner + 2 * outer);\n const bandwidth = Math.abs(step * (1 - inner));\n const index = new Map(domain.map((key, i) => [key, i]));\n const startAt = (i: number) => r0 + step * (outer + i) + (step < 0 ? step * (1 - inner) : 0);\n const start = (key: string) => {\n const i = index.get(key);\n return i === undefined ? Number.NaN : startAt(i);\n };\n return {\n kind: 'band',\n domain,\n range: [r0, r1],\n bandwidth,\n step: Math.abs(step),\n start,\n position: (key) => start(key) + bandwidth / 2,\n invert: (at) => {\n if (n === 0) return undefined;\n const i = Math.round((at - r0) / step - outer - (1 - inner) / 2);\n return domain[Math.min(n - 1, Math.max(0, i))];\n },\n ticks: () => [...domain],\n format: (key) => key,\n };\n}\n","import type { ContinuousScale } from './types';\n\n/** Options for {@link timeScale}. */\nexport interface TimeScaleOptions {\n /** Milliseconds since the epoch, as `Date.getTime` gives them. */\n domain: readonly [number, number];\n range: readonly [number, number];\n}\n\n/** A scale over instants, whose ticks fall on whole seconds, minutes, hours, days, months or years, in UTC. */\nexport interface TimeScale extends ContinuousScale {\n readonly kind: 'time';\n}\n\nconst SECOND = 1000;\nconst MINUTE = 60 * SECOND;\nconst HOUR = 60 * MINUTE;\nconst DAY = 24 * HOUR;\n\n/** A tick interval: a fixed span, or a count of calendar months. */\ntype Interval = { ms: number; months?: never; unit: Unit } | { months: number; ms?: never; unit: Unit };\ntype Unit = 'second' | 'minute' | 'hour' | 'day' | 'month' | 'year';\n\nconst INTERVALS: readonly Interval[] = [\n { ms: SECOND, unit: 'second' }, { ms: 5 * SECOND, unit: 'second' }, { ms: 15 * SECOND, unit: 'second' }, { ms: 30 * SECOND, unit: 'second' },\n { ms: MINUTE, unit: 'minute' }, { ms: 5 * MINUTE, unit: 'minute' }, { ms: 15 * MINUTE, unit: 'minute' }, { ms: 30 * MINUTE, unit: 'minute' },\n { ms: HOUR, unit: 'hour' }, { ms: 3 * HOUR, unit: 'hour' }, { ms: 6 * HOUR, unit: 'hour' }, { ms: 12 * HOUR, unit: 'hour' },\n { ms: DAY, unit: 'day' }, { ms: 2 * DAY, unit: 'day' }, { ms: 7 * DAY, unit: 'day' },\n { months: 1, unit: 'month' }, { months: 3, unit: 'month' }, { months: 12, unit: 'year' },\n];\n\nconst MONTH_MS = 30 * DAY;\nconst spanOf = (i: Interval): number => i.ms ?? i.months * MONTH_MS;\n\n/** The interval nearest a cut of `span` into `count` pieces; whole years past the table's end. */\nfunction intervalFor(span: number, count: number): Interval {\n const target = span / Math.max(1, count);\n let best = INTERVALS[0]!;\n for (const i of INTERVALS) if (Math.abs(Math.log(spanOf(i) / target)) < Math.abs(Math.log(spanOf(best) / target))) best = i;\n if (best.unit === 'year' && target > 12 * MONTH_MS) {\n const years = 10 ** Math.floor(Math.log10(target / (12 * MONTH_MS)));\n return { months: 12 * years, unit: 'year' };\n }\n return best;\n}\n\n/** Every instant on `interval`'s grid from `lo` to `hi`. */\nfunction gridTicks(lo: number, hi: number, interval: Interval): number[] {\n const out: number[] = [];\n if (interval.ms !== undefined) {\n for (let t = Math.ceil(lo / interval.ms) * interval.ms; t <= hi; t += interval.ms) out.push(t);\n return out;\n }\n const at = new Date(lo);\n let month = at.getUTCFullYear() * 12 + at.getUTCMonth();\n month = Math.ceil(month / interval.months) * interval.months;\n for (;; month += interval.months) {\n const t = Date.UTC(Math.floor(month / 12), month % 12, 1);\n if (t < lo) continue;\n if (t > hi) break;\n out.push(t);\n }\n return out;\n}\n\nconst pad = (n: number) => String(n).padStart(2, '0');\n\n/** `t` written to the precision of `unit`. */\nexport function formatInstant(t: number, unit: Unit): string {\n const d = new Date(t);\n const date = `${d.getUTCFullYear()}-${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())}`;\n const time = `${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())}`;\n switch (unit) {\n case 'year': return String(d.getUTCFullYear());\n case 'month': return date.slice(0, 7);\n case 'day': return date;\n case 'hour':\n case 'minute': return d.getUTCHours() === 0 && d.getUTCMinutes() === 0 ? date : time;\n case 'second': return `${time}:${pad(d.getUTCSeconds())}`;\n }\n}\n\n/** A time scale from `domain`, in milliseconds since the epoch, onto `range`. */\nexport function timeScale(opts: TimeScaleOptions): TimeScale {\n const [d0, d1] = opts.domain;\n const [r0, r1] = opts.range;\n const span = d1 - d0;\n const map = (v: number) => (span === 0 ? (r0 + r1) / 2 : r0 + ((v - d0) / span) * (r1 - r0));\n const interval = (count = 5) => intervalFor(Math.abs(span), count);\n return {\n kind: 'time',\n domain: [d0, d1],\n range: [r0, r1],\n map,\n position: map,\n invert: (at) => (r1 === r0 ? d0 : d0 + ((at - r0) / (r1 - r0)) * span),\n ticks: (count = 5) => {\n const out = gridTicks(Math.min(d0, d1), Math.max(d0, d1), interval(count));\n return d0 <= d1 ? out : out.reverse();\n },\n format: (v) => formatInstant(v, interval().unit),\n };\n}\n","/** Options for {@link ordinalScale}. */\nexport interface OrdinalScaleOptions<T> {\n /** The keys, in order. */\n domain: readonly string[];\n /** What each key maps to, in domain order, wrapping when there are fewer than keys. */\n range: readonly T[];\n}\n\n/** A scale from keys to values in turn, as a series' colors are chosen. */\nexport interface OrdinalScale<T> {\n readonly kind: 'ordinal';\n readonly domain: readonly string[];\n readonly range: readonly T[];\n /** `key`'s value; a key not in the domain takes the next value after the last, and joins the domain. */\n map(key: string): T;\n /** The keys a legend lists. */\n ticks(): string[];\n format(key: string): string;\n}\n\n/** An ordinal scale from `domain` to `range`. Throws on an empty range. */\nexport function ordinalScale<T>(opts: OrdinalScaleOptions<T>): OrdinalScale<T> {\n if (opts.range.length === 0) throw new Error('ordinalScale: an empty range');\n const domain = [...opts.domain];\n const index = new Map(domain.map((key, i) => [key, i]));\n const range = [...opts.range];\n return {\n kind: 'ordinal',\n domain,\n range,\n map: (key) => {\n let i = index.get(key);\n if (i === undefined) {\n i = domain.length;\n domain.push(key);\n index.set(key, i);\n }\n return range[i % range.length]!;\n },\n ticks: () => [...domain],\n format: (key) => key,\n };\n}\n","/** Marks drawn as a box: bars, spans and points. Each carries its outline as `path`, which every export writes. */\nimport { ellipsePath, type Path } from '@weasel-js/geom';\nimport type { PlotBox, PlotDatum, PlotMark } from './types';\n\nconst rectOf = (b: PlotBox): Path => ({ kind: 'rect', x: b.x, y: b.y, width: b.width, height: b.height });\n\nconst fillOf = (color: string, opacity?: number) => ({ paint: { color, ...(opacity !== undefined ? { opacity } : {}) } });\n\n/** Options for {@link barMark}. */\nexport interface BarMarkOptions {\n key: string;\n /** Where the bar stands along the category axis: its left edge, or its top for a horizontal bar. */\n x: number;\n /** The bar's breadth across the category axis. */\n width: number;\n /** The baseline the bar rises from, and the end it reaches, along the value axis. */\n from: number;\n to: number;\n color: string;\n datum?: PlotDatum;\n /** Default `'vertical'`: `x` and `width` run along x. */\n orient?: 'vertical' | 'horizontal';\n}\n\n/** A bar from `from` to `to`, either way round. */\nexport function barMark(opts: BarMarkOptions): PlotMark {\n const lo = Math.min(opts.from, opts.to);\n const length = Math.abs(opts.to - opts.from);\n const pose = opts.orient === 'horizontal'\n ? { x: lo, y: opts.x, width: length, height: opts.width }\n : { x: opts.x, y: lo, width: opts.width, height: length };\n return {\n key: opts.key,\n pose,\n data: { plotMark: { kind: 'bar', ...(opts.datum ? { datum: opts.datum } : {}) }, path: rectOf(pose), fill: fillOf(opts.color) },\n };\n}\n\n/** Options for {@link spanMark}. */\nexport interface SpanMarkOptions {\n key: string;\n /** Start and end along x. */\n x0: number;\n x1: number;\n /** Its row: top and height. */\n y: number;\n height: number;\n color: string;\n opacity?: number;\n datum?: PlotDatum;\n}\n\n/** A span across x, as a task's bar on a timeline is. */\nexport function spanMark(opts: SpanMarkOptions): PlotMark {\n const pose = { x: Math.min(opts.x0, opts.x1), y: opts.y, width: Math.abs(opts.x1 - opts.x0), height: opts.height };\n return {\n key: opts.key,\n pose,\n data: {\n plotMark: { kind: 'span', ...(opts.datum ? { datum: opts.datum } : {}) },\n path: rectOf(pose),\n fill: fillOf(opts.color, opts.opacity),\n },\n };\n}\n\n/** Options for {@link pointMark}. */\nexport interface PointMarkOptions {\n key: string;\n x: number;\n y: number;\n /** Default 3. */\n radius?: number;\n color: string;\n datum?: PlotDatum;\n}\n\n/** A dot centered on `x`, `y`. */\nexport function pointMark(opts: PointMarkOptions): PlotMark {\n const r = opts.radius ?? 3;\n const pose = { x: opts.x - r, y: opts.y - r, width: 2 * r, height: 2 * r };\n return {\n key: opts.key,\n pose,\n data: { plotMark: { kind: 'point', ...(opts.datum ? { datum: opts.datum } : {}) }, path: ellipsePath(pose), fill: fillOf(opts.color) },\n };\n}\n","/** Marks drawn as a path: lines, areas, rules, arcs and ribbons. */\nimport { boundsOfPath, pathFromD, type Path } from '@weasel-js/geom';\nimport type { PlotDatum, PlotMark, PlotMarkData, PlotPoint, SolidStroke } from './types';\n\nconst n = (v: number) => Number(v.toFixed(3));\nconst at = (p: PlotPoint) => `${n(p.x)} ${n(p.y)}`;\n\n/** A mark whose pose is its path's box, so the painter draws the path where it was built. */\nfunction pathMark(key: string, path: Path, data: Omit<PlotMarkData, 'path'>): PlotMark {\n const b = boundsOfPath(path);\n return { key, pose: { x: b.x, y: b.y, width: b.width, height: b.height }, data: { ...data, path } };\n}\n\nconst traitOf = (kind: PlotMarkData['plotMark']['kind'], datum?: PlotDatum) => ({ kind, ...(datum ? { datum } : {}) });\n\n/** Options for {@link lineMark}. */\nexport interface LineMarkOptions {\n key: string;\n /** At least one. */\n points: readonly PlotPoint[];\n color: string;\n /** Default 2. */\n width?: number;\n dash?: number[];\n datum?: PlotDatum;\n}\n\n/** A line through `points`, in order. */\nexport function lineMark(opts: LineMarkOptions): PlotMark {\n const [first, ...rest] = opts.points;\n if (first === undefined) throw new Error(`lineMark \"${opts.key}\": no points`);\n const d = `M ${at(first)}${rest.map((p) => ` L ${at(p)}`).join('')}`;\n const stroke: SolidStroke = {\n paint: { color: opts.color }, width: opts.width ?? 2, join: 'round', cap: 'round', ...(opts.dash ? { dash: opts.dash } : {}),\n };\n return pathMark(opts.key, pathFromD(d), { plotMark: traitOf('line', opts.datum), stroke });\n}\n\n/** Options for {@link ruleMark}. */\nexport interface RuleMarkOptions {\n key: string;\n from: PlotPoint;\n to: PlotPoint;\n color: string;\n /** Default 1. */\n width?: number;\n dash?: number[];\n datum?: PlotDatum;\n}\n\n/** A straight rule from `from` to `to`: an axis line, a tick, a grid line, a marker. */\nexport function ruleMark(opts: RuleMarkOptions): PlotMark {\n const stroke: SolidStroke = { paint: { color: opts.color }, width: opts.width ?? 1, cap: 'butt', ...(opts.dash ? { dash: opts.dash } : {}) };\n return pathMark(opts.key, pathFromD(`M ${at(opts.from)} L ${at(opts.to)}`), { plotMark: traitOf('rule', opts.datum), stroke });\n}\n\n/** Options for {@link areaMark}. */\nexport interface AreaMarkOptions {\n key: string;\n /** The upper edge, in order. */\n top: readonly PlotPoint[];\n /** The lower edge, in the same order as `top`. Default a baseline at `baseline` under each top point. */\n bottom?: readonly PlotPoint[];\n baseline?: number;\n color: string;\n /** Default 0.35. */\n opacity?: number;\n datum?: PlotDatum;\n}\n\n/** The region between two edges, as an area chart or a radar's polygon fills it. */\nexport function areaMark(opts: AreaMarkOptions): PlotMark {\n if (opts.top.length === 0) throw new Error(`areaMark \"${opts.key}\": no points`);\n const bottom = opts.bottom ?? (opts.baseline !== undefined ? opts.top.map((p) => ({ x: p.x, y: opts.baseline! })) : []);\n const ring = [...opts.top, ...[...bottom].reverse()];\n const d = `M ${ring.map(at).join(' L ')} Z`;\n return pathMark(opts.key, pathFromD(d), {\n plotMark: traitOf('area', opts.datum), fill: { paint: { color: opts.color, opacity: opts.opacity ?? 0.35 } },\n });\n}\n\n/** Options for {@link arcMark}. */\nexport interface ArcMarkOptions {\n key: string;\n center: PlotPoint;\n /** 0 for a pie slice. */\n innerRadius: number;\n outerRadius: number;\n /** Radians clockwise from twelve o'clock. */\n startAngle: number;\n endAngle: number;\n color: string;\n datum?: PlotDatum;\n}\n\nconst polar = (c: PlotPoint, r: number, a: number): PlotPoint => ({ x: c.x + r * Math.sin(a), y: c.y - r * Math.cos(a) });\n\n/** One side of an arc from `a0` to `a1` at radius `r`, as SVG arc commands, in halves past a half turn. */\nfunction arcTo(c: PlotPoint, r: number, a0: number, a1: number): string {\n const sweep = a1 >= a0 ? 1 : 0;\n const mid = (a0 + a1) / 2;\n const to = (a: number) => ` A ${n(r)} ${n(r)} 0 0 ${sweep} ${at(polar(c, r, a))}`;\n return Math.abs(a1 - a0) > Math.PI ? to(mid) + to(a1) : to(a1);\n}\n\n/** A slice of a ring, as a pie or a donut is cut. */\nexport function arcMark(opts: ArcMarkOptions): PlotMark {\n const { center: c, innerRadius: r0, outerRadius: r1, startAngle: a0 } = opts;\n const a1 = Math.abs(opts.endAngle - a0) >= 2 * Math.PI ? a0 + Math.sign(opts.endAngle - a0) * (2 * Math.PI - 1e-6) : opts.endAngle;\n let d = `M ${at(polar(c, r1, a0))}${arcTo(c, r1, a0, a1)}`;\n d += r0 > 0 ? ` L ${at(polar(c, r0, a1))}${arcTo(c, r0, a1, a0)} Z` : ` L ${at(c)} Z`;\n return pathMark(opts.key, pathFromD(d), { plotMark: traitOf('arc', opts.datum), fill: { paint: { color: opts.color } } });\n}\n\n/** Options for {@link ribbonMark}. */\nexport interface RibbonMarkOptions {\n key: string;\n /** The end it leaves: an x, and the span along y it leaves across. */\n from: { x: number; y0: number; y1: number };\n to: { x: number; y0: number; y1: number };\n color: string;\n /** Default 0.45. */\n opacity?: number;\n datum?: PlotDatum;\n}\n\n/** A band curving from one span to another, as a flow between two nodes is drawn. */\nexport function ribbonMark(opts: RibbonMarkOptions): PlotMark {\n const { from: f, to: t } = opts;\n const mx = (f.x + t.x) / 2;\n const d = `M ${n(f.x)} ${n(f.y0)} C ${n(mx)} ${n(f.y0)} ${n(mx)} ${n(t.y0)} ${n(t.x)} ${n(t.y0)}`\n + ` L ${n(t.x)} ${n(t.y1)} C ${n(mx)} ${n(t.y1)} ${n(mx)} ${n(f.y1)} ${n(f.x)} ${n(f.y1)} Z`;\n return pathMark(opts.key, pathFromD(d), {\n plotMark: traitOf('ribbon', opts.datum), fill: { paint: { color: opts.color, opacity: opts.opacity ?? 0.45 } },\n });\n}\n","/** Marks drawn as text: titles, tick labels, values. */\nimport type { PlotMeasure } from '../measure';\nimport type { PlotFont } from '../theme';\nimport type { PlotDatum, PlotMark } from './types';\n\n/** Options for {@link textMark}. */\nexport interface TextMarkOptions {\n key: string;\n text: string;\n /** The anchor point. */\n x: number;\n y: number;\n /** Which part of the text stands on `x`. Default `'middle'`. */\n anchor?: 'start' | 'middle' | 'end';\n /** Which part of the text stands on `y`. Default `'middle'`. */\n baseline?: 'top' | 'middle' | 'bottom';\n font: PlotFont;\n color: string;\n measure: PlotMeasure;\n /** Turns the text a quarter turn counterclockwise about the anchor, as a vertical axis's title reads. */\n vertical?: boolean;\n bold?: boolean;\n datum?: PlotDatum;\n}\n\nconst ALIGN = { start: 'left', middle: 'center', end: 'right' } as const;\n\n/** One line of text, its box measured with `measure` and placed by its anchor. */\nexport function textMark(opts: TextMarkOptions): PlotMark {\n const { width, height } = opts.measure(opts.text, opts.font);\n const anchor = opts.anchor ?? 'middle';\n const baseline = opts.baseline ?? 'middle';\n // Along and across the line, which a quarter turn swaps on screen.\n const along = anchor === 'start' ? 0 : anchor === 'middle' ? -width / 2 : -width;\n const across = baseline === 'top' ? 0 : baseline === 'middle' ? -height / 2 : -height;\n const center = opts.vertical\n ? { x: opts.x + across + height / 2, y: opts.y - along - width / 2 }\n : { x: opts.x + along + width / 2, y: opts.y + across + height / 2 };\n return {\n key: opts.key,\n pose: {\n x: center.x - width / 2, y: center.y - height / 2, width, height, ...(opts.vertical ? { rotation: -Math.PI / 2 } : {}),\n },\n data: {\n plotMark: { kind: 'text', ...(opts.datum ? { datum: opts.datum } : {}) },\n text: opts.text,\n style: { fontFamily: opts.font.fontFamily, fontSize: opts.font.fontSize, align: ALIGN[anchor], ...(opts.bold ? { fontWeight: 700 } : {}) },\n fill: { paint: { color: opts.color } },\n verticalAlign: 'center',\n },\n };\n}\n","/** Axes as marks: a rule along a scale's range, a tick and a label at each of its ticks, grid lines, a title. */\nimport { ruleMark } from './marks/paths';\nimport { textMark } from './marks/text';\nimport type { PlotMark } from './marks/types';\nimport type { PlotMeasure } from './measure';\nimport type { Scale } from './scales/types';\nimport type { PlotTheme } from './theme';\n\n/** Which side of the plot an axis runs along. Its scale's range runs along x for top and bottom, along y otherwise. */\nexport type AxisSide = 'top' | 'bottom' | 'left' | 'right';\n\n/** Options for {@link axisMarks} and {@link axisRoom}. */\nexport interface AxisOptions<T> {\n scale: Scale<T>;\n side: AxisSide;\n /** Where the axis line stands across its scale: a y for top and bottom, an x for left and right. */\n at: number;\n /** Draw a grid line at each tick, from the axis across to here. */\n gridTo?: number;\n title?: string;\n /** How many ticks to ask the scale for. */\n ticks?: number;\n /** Prefixes every mark's key. Default `axis:<side>`. */\n key?: string;\n theme: PlotTheme;\n measure: PlotMeasure;\n}\n\nconst TICK = 5;\nconst GAP = 4;\n\nconst isHorizontal = (side: AxisSide) => side === 'top' || side === 'bottom';\n/** Which way leads away from the plot across the axis. */\nconst outward = (side: AxisSide) => (side === 'bottom' || side === 'right' ? 1 : -1);\n\n/** How far an axis reaches out from its line: ticks, labels and title. */\nexport function axisRoom<T>(opts: AxisOptions<T>): number {\n const { scale, side, theme, measure } = opts;\n const sizes = scale.ticks(opts.ticks).map((t) => measure(scale.format(t), theme.font));\n const labels = sizes.length === 0 ? 0 : Math.max(...sizes.map((s) => (isHorizontal(side) ? s.height : s.width)));\n const title = opts.title ? measure(opts.title, theme.font).height + GAP : 0;\n return TICK + GAP + labels + title;\n}\n\n/** Every mark one axis is drawn with. Keys: `<key>:rule`, `<key>:tick:<i>`, `<key>:label:<i>`, `<key>:grid:<i>`, `<key>:title`. */\nexport function axisMarks<T>(opts: AxisOptions<T>): PlotMark[] {\n const { scale, side, at, theme, measure } = opts;\n const key = opts.key ?? `axis:${side}`;\n const h = isHorizontal(side);\n const out = outward(side);\n const pt = (along: number, across: number) => (h ? { x: along, y: across } : { x: across, y: along });\n const [r0, r1] = scale.range;\n const marks: PlotMark[] = [];\n const ticks = scale.ticks(opts.ticks);\n ticks.forEach((t, i) => {\n const p = scale.position(t);\n if (opts.gridTo !== undefined) {\n marks.push(ruleMark({ key: `${key}:grid:${i}`, from: pt(p, at), to: pt(p, opts.gridTo), color: theme.grid }));\n }\n });\n marks.push(ruleMark({ key: `${key}:rule`, from: pt(r0, at), to: pt(r1, at), color: theme.axis }));\n let reach = 0;\n ticks.forEach((t, i) => {\n const p = scale.position(t);\n marks.push(ruleMark({ key: `${key}:tick:${i}`, from: pt(p, at), to: pt(p, at + out * TICK), color: theme.axis }));\n const anchorAt = pt(p, at + out * (TICK + GAP));\n const label = textMark({\n key: `${key}:label:${i}`, text: scale.format(t), ...anchorAt, font: theme.font, color: theme.text, measure,\n anchor: h ? 'middle' : out > 0 ? 'start' : 'end',\n baseline: h ? (out > 0 ? 'top' : 'bottom') : 'middle',\n });\n reach = Math.max(reach, h ? label.pose.height : label.pose.width);\n marks.push(label);\n });\n if (opts.title) {\n const across = at + out * (TICK + GAP + reach + GAP);\n marks.push(textMark({\n key: `${key}:title`, text: opts.title, ...pt((r0 + r1) / 2, across), font: theme.font, color: theme.text, measure,\n anchor: 'middle', baseline: out > 0 ? 'top' : 'bottom', vertical: !h,\n }));\n }\n return marks;\n}\n","import { THEMES, type ResolvedTheme } from '@weasel-js/theme';\n\n/** The face a chart's text is set in. */\nexport interface PlotFont {\n fontFamily: string;\n fontSize: number;\n}\n\n/** The colors a chart is drawn in, by role, and its face. Plain strings, so a scene can keep it. */\nexport interface PlotTheme {\n /** Titles, labels and values. */\n text: string;\n /** Axis rules and ticks. */\n axis: string;\n /** Grid lines behind the marks. */\n grid: string;\n /** The colors series take in turn. Never empty. */\n series: readonly string[];\n font: PlotFont;\n}\n\n/** The weasel theme's swatches, in the order series take them. */\nconst SWATCHES = ['sky', 'amber', 'green', 'rose', 'violet', 'teal', 'citron', 'fuchsia', 'blue', 'red'] as const;\n\n/** A plot theme from a resolved weasel theme: text in `fg`, axes in `border-strong`, grid in `border`, series in\n * its swatches. */\nexport function plotThemeFrom(resolved: Readonly<Record<string, string>> | ResolvedTheme, font: PlotFont = PLOT_FONT): PlotTheme {\n const at = (token: string) => (resolved as Record<string, string>)[`--wzl-${token}`] ?? '#888888';\n return {\n text: at('fg'),\n axis: at('border-strong'),\n grid: at('border'),\n series: SWATCHES.map((s) => at(`swatch-${s}`)),\n font,\n };\n}\n\n/** 12px sans-serif. */\nexport const PLOT_FONT: PlotFont = { fontFamily: 'sans-serif', fontSize: 12 };\n\n/** The weasel theme in its dark mode. */\nexport const PLOT_THEME: PlotTheme = plotThemeFrom(THEMES.weasel.selections['mode=dark,density=comfortable']);\n\n/** The `i`th series' color, wrapping. */\nexport const seriesColor = (theme: PlotTheme, i: number): string =>\n theme.series[((i % theme.series.length) + theme.series.length) % theme.series.length] ?? theme.text;\n","import { measureTextBounds } from '@weasel-js/text';\nimport type { PlotFont } from './theme';\n\n/** How wide and tall one line of text is set in `font`. */\nexport type PlotMeasure = (text: string, font: PlotFont) => { width: number; height: number };\n\n/** Measures as the kit's text renderer lays text out, from the registered face's metrics; a line is 1.2 sizes tall. */\nexport const textMeasure: PlotMeasure = (text, font) => {\n const { width } = measureTextBounds(text, { fontFamily: font.fontFamily, fontSize: font.fontSize });\n return { width: Math.ceil(width), height: Math.ceil(font.fontSize * 1.2) };\n};\n","/** An xychart compiled to its scales and marks. */\nimport { axisMarks, axisRoom } from '../axes';\nimport { barMark, pointMark } from '../marks/boxes';\nimport { lineMark } from '../marks/paths';\nimport { textMark } from '../marks/text';\nimport type { PlotMark } from '../marks/types';\nimport type { PlotMeasure } from '../measure';\nimport { bandScale } from '../scales/band';\nimport { linearScale, niceDomain, type LinearScale } from '../scales/linear';\nimport type { Scale } from '../scales/types';\nimport { seriesColor, type PlotTheme } from '../theme';\nimport type { XyChartData } from './types';\n\n/** Where an xychart's parts landed: the plot area, the value scale, and each value index's place across it. */\nexport interface XyLayout {\n orientation: 'vertical' | 'horizontal';\n /** The area the marks are drawn in, inside the axes. */\n plot: { x: number; y: number; width: number; height: number };\n /** Values along y for a vertical chart, along x for a horizontal one. */\n value: LinearScale;\n /** Each value index's center along the category axis. */\n slots: readonly number[];\n /** How much of the category axis each index's bars share. */\n slotWidth: number;\n}\n\nconst PAD = 12;\nconst GAP = 8;\nconst BAND_PADDING = 0.2;\n\n/** How many values the longest series holds. */\nexport const xyLength = (data: XyChartData): number => Math.max(0, ...data.series.map((s) => s.values.length));\n\n/** The labels of the category bands: the axis's own, else numbers from 1, one per value of the longest series. */\nfunction categoriesOf(data: XyChartData): string[] {\n if (data.x?.kind === 'band' && data.x.categories.length > 0) return [...data.x.categories];\n return Array.from({ length: xyLength(data) }, (_, i) => String(i + 1));\n}\n\n/** The value axis's domain: its own ends, and where one is missing, the values' reach with zero in it, made round. */\nexport function xyValueDomain(data: XyChartData): [number, number] {\n const values = data.series.flatMap((s) => s.values).filter(Number.isFinite);\n const lo = Math.min(0, ...values);\n const hi = Math.max(0, ...values);\n const [niceLo, niceHi] = niceDomain([lo, hi === lo ? lo + 1 : hi]);\n const min = data.y?.min ?? niceLo;\n const max = data.y?.max ?? niceHi;\n return min === max ? [min, min + 1] : [min, max];\n}\n\n/** The category axis's scale over `range`, and each value index's center and share along it. */\nfunction categoryAxis(data: XyChartData, range: [number, number]): { scale: Scale<string> | Scale<number>; slots: number[]; slotWidth: number } {\n const n = xyLength(data);\n if (data.x?.kind === 'range') {\n const scale = linearScale({ domain: [data.x.min, data.x.max], range });\n const step = (range[1] - range[0]) / Math.max(1, n);\n const slots = Array.from({ length: n }, (_, i) => range[0] + step * (i + 0.5));\n return { scale, slots, slotWidth: Math.abs(step) * (1 - BAND_PADDING) };\n }\n const categories = categoriesOf(data);\n const scale = bandScale({ domain: categories, range, paddingInner: BAND_PADDING });\n const slots = Array.from({ length: n }, (_, i) => (i < categories.length ? scale.position(categories[i]!) : Number.NaN));\n return { scale, slots, slotWidth: scale.bandwidth };\n}\n\n/** Lays out an xychart in a box of `size`: its title, axes, bars, lines and points. */\nexport function compileXyChart(\n data: XyChartData, size: { width: number; height: number }, theme: PlotTheme, measure: PlotMeasure,\n): { marks: PlotMark[]; layout: XyLayout } {\n const vertical = data.orientation !== 'horizontal';\n const marks: PlotMark[] = [];\n let top = PAD;\n if (data.title) {\n const title = textMark({\n key: 'title', text: data.title, x: size.width / 2, y: PAD, baseline: 'top', font: theme.font, color: theme.text, measure, bold: true,\n });\n marks.push(title);\n top += title.pose.height + GAP;\n }\n const domain = xyValueDomain(data);\n const base = { theme, measure, at: 0 };\n const valueTitle = data.y?.title !== undefined ? { title: data.y.title } : {};\n const categoryTitle = data.x?.title !== undefined ? { title: data.x.title } : {};\n const probe = categoryAxis(data, [0, 1]);\n const valueRoom = axisRoom({ ...base, ...valueTitle, scale: linearScale({ domain, range: [0, 1] }), side: vertical ? 'left' : 'bottom' });\n const categoryRoom = axisRoom({ ...base, ...categoryTitle, scale: probe.scale as Scale<unknown>, side: vertical ? 'bottom' : 'left' });\n const left = PAD + (vertical ? valueRoom : categoryRoom);\n const bottom = size.height - PAD - (vertical ? categoryRoom : valueRoom);\n const plot = { x: left, y: top, width: Math.max(1, size.width - PAD - left), height: Math.max(1, bottom - top) };\n const right = plot.x + plot.width;\n\n const value = linearScale({ domain, range: vertical ? [bottom, top] : [left, right] });\n const category = categoryAxis(data, vertical ? [left, right] : [top, bottom]);\n marks.push(...axisMarks({ ...base, ...valueTitle, key: 'axis:value', scale: value, side: vertical ? 'left' : 'bottom', at: vertical ? left : bottom, gridTo: vertical ? right : top }));\n marks.push(...axisMarks({ ...base, ...categoryTitle, key: 'axis:category', scale: category.scale as Scale<unknown>, side: vertical ? 'bottom' : 'left', at: vertical ? bottom : left }));\n\n const layout: XyLayout = { orientation: vertical ? 'vertical' : 'horizontal', plot, value, slots: category.slots, slotWidth: category.slotWidth };\n marks.push(...seriesMarks(data, layout, theme));\n return { marks, layout };\n}\n\n/** The bars, lines and points of every series, in series order. */\nfunction seriesMarks(data: XyChartData, layout: XyLayout, theme: PlotTheme): PlotMark[] {\n const { value, slots, slotWidth } = layout;\n const vertical = layout.orientation === 'vertical';\n const at = (along: number, v: number) => (vertical ? { x: along, y: value.map(v) } : { x: value.map(v), y: along });\n const [d0, d1] = value.domain;\n const baseline = value.map(Math.min(Math.max(0, Math.min(d0, d1)), Math.max(d0, d1)));\n const bars = data.series.filter((s) => s.kind === 'bar');\n const barWidth = slotWidth / Math.max(1, bars.length);\n const categories = categoriesOf(data);\n const marks: PlotMark[] = [];\n data.series.forEach((series, s) => {\n const color = seriesColor(theme, s);\n const datum = (i: number) => ({ series: s, index: i, value: series.values[i]!, category: categories[i] ?? String(i + 1) });\n const placed = series.values.map((v, i) => ({ v, i })).filter(({ v, i }) => Number.isFinite(v) && Number.isFinite(slots[i] ?? Number.NaN));\n if (series.kind === 'bar') {\n const j = bars.indexOf(series);\n for (const { v, i } of placed) {\n marks.push(barMark({\n key: `bar:${s}:${i}`, x: slots[i]! - slotWidth / 2 + j * barWidth, width: barWidth, from: baseline, to: value.map(v), color,\n datum: datum(i), orient: layout.orientation,\n }));\n }\n return;\n }\n if (placed.length > 0) {\n marks.push(lineMark({ key: `line:${s}`, points: placed.map(({ v, i }) => at(slots[i]!, v)), color, datum: { series: s } }));\n }\n for (const { v, i } of placed) marks.push(pointMark({ key: `point:${s}:${i}`, ...at(slots[i]!, v), radius: 3.5, color, datum: datum(i) }));\n });\n return marks;\n}\n","/** Chart specs, and the one table that compiles each kind to marks. */\nimport type { PlotMark } from './marks/types';\nimport type { PlotMeasure } from './measure';\nimport type { PlotTheme } from './theme';\nimport { compileXyChart } from './xychart/compile';\nimport type { XyChartData } from './xychart/types';\n\n/** A chart, as data: one spec per kind, told apart by `kind`. */\nexport type PlotData = XyChartData;\n\n/** The kinds of chart {@link PlotData} holds. */\nexport type PlotKind = PlotData['kind'];\n\n/** What a kind's compiler is given and gives back: its spec laid out in a box of `size`, as marks. */\nexport type PlotCompiler<D extends PlotData> = (\n data: D, size: { width: number; height: number }, theme: PlotTheme, measure: PlotMeasure,\n) => { marks: PlotMark[] };\n\nconst COMPILERS: { readonly [K in PlotKind]: PlotCompiler<Extract<PlotData, { kind: K }>> } = {\n xychart: compileXyChart,\n};\n\n/** `data` laid out in a box of `size`, as the marks it is drawn with, in drawing order. */\nexport function compilePlot(\n data: PlotData, size: { width: number; height: number }, theme: PlotTheme, measure: PlotMeasure,\n): PlotMark[] {\n const compile = COMPILERS[data.kind] as PlotCompiler<PlotData> | undefined;\n if (compile === undefined) throw new Error(`compilePlot: no chart of kind \"${(data as { kind: string }).kind}\"`);\n return compile(data, size, theme, measure).marks;\n}\n","/** Edits to an xychart, as plain data in and out. */\nimport { decimalsOf } from '../scales/linear';\nimport type { XyLayout } from './compile';\nimport type { XyChartData } from './types';\n\n/** `data` with series `series`'s value at `index` set to `value`. Throws on an index the series does not hold. */\nexport function setXyValue(data: XyChartData, series: number, index: number, value: number): XyChartData {\n const target = data.series[series];\n if (target === undefined || index < 0 || index >= target.values.length) {\n throw new Error(`setXyValue: series ${series} holds no value ${index}`);\n }\n if (target.values[index] === value) return data;\n const values = target.values.map((v, i) => (i === index ? value : v));\n return { ...data, series: data.series.map((s, i) => (i === series ? { ...s, values } : s)) };\n}\n\n/** The value a point stands at along `layout`'s value axis, rounded to a tenth of its tick step. */\nexport function xyValueAt(layout: XyLayout, at: { x: number; y: number }): number {\n const raw = layout.value.invert(layout.orientation === 'vertical' ? at.y : at.x);\n const step = layout.value.tickStep() / 10;\n return Number((Math.round(raw / step) * step).toFixed(decimalsOf(step)));\n}\n","/**\n * A plot in a scene: one root node holding the spec, its marks derived\n * children rebuilt from it. An edit replaces the spec and rebuilds the marks\n * as one undo entry.\n */\nimport type { AddNodeSpec, NodeId, RectPose, Scene } from '@weasel-js/core';\nimport type { PlotMark, PlotMarkData, PlotMarkTrait } from './marks/types';\nimport { textMeasure, type PlotMeasure } from './measure';\nimport { compilePlot, type PlotData } from './plotData';\nimport { PLOT_THEME, type PlotTheme } from './theme';\n\n/** What a plot's root node keeps: the spec, and the theme its marks were drawn in. */\nexport interface PlotRootTrait {\n data: PlotData;\n theme: PlotTheme;\n}\n\n/** A plot root's scene data. */\nexport interface PlotRootData {\n plot: PlotRootTrait;\n}\n\n/** The data of any node a plot puts in a scene. */\nexport type PlotSceneData = PlotRootData | PlotMarkData;\n\n/** A scene node spec, as {@link plotSpecs} returns them. */\nexport type PlotSpec<TLayer extends string = 'main'> = AddNodeSpec<PlotSceneData, TLayer, RectPose>;\n\n/** Options for {@link plotSpecs}. */\nexport interface PlotSpecsOptions<TLayer extends string = 'main'> {\n /** The root's id. Default `'plot'`. */\n id?: string;\n /** The box the plot fills. */\n box: { x: number; y: number; width: number; height: number };\n /** Default `'main'`. */\n layer?: TLayer;\n /** Default {@link PLOT_THEME}. */\n theme?: PlotTheme;\n /** Default {@link textMeasure}. */\n measure?: PlotMeasure;\n}\n\n/** The trait a plot root's data carries, or `null` for any other node. */\nexport function plotRootOf(node: { data: unknown } | undefined): PlotRootTrait | null {\n const plot = (node?.data as { plot?: PlotRootTrait } | null | undefined)?.plot;\n return plot !== undefined && plot !== null && typeof plot === 'object' && typeof plot.data?.kind === 'string' ? plot : null;\n}\n\n/** The trait a plot mark's data carries, or `null` for any other node. */\nexport function plotMarkOf(node: { data: unknown } | undefined): PlotMarkTrait | null {\n const mark = (node?.data as { plotMark?: PlotMarkTrait } | null | undefined)?.plotMark;\n return mark !== undefined && mark !== null && typeof mark.kind === 'string' ? mark : null;\n}\n\n/** The id of the mark keyed `key` under the root `rootId`. */\nexport const plotMarkId = (rootId: string, key: string): string => `${rootId}/${key}`;\n\n/** `marks` as children of the root `rootId`, in its frame. */\nexport function markSpecs<TLayer extends string>(rootId: string, layer: TLayer, marks: readonly PlotMark[]): PlotSpec<TLayer>[] {\n return marks.map((m) => ({\n kind: 'mark', id: plotMarkId(rootId, m.key) as NodeId, parent: rootId as NodeId, layer,\n pose: { x: m.pose.x, y: m.pose.y, width: m.pose.width, height: m.pose.height, ...(m.pose.rotation ? { rotation: m.pose.rotation } : {}) },\n data: m.data,\n }));\n}\n\n/** The nodes a plot of `data` is: its root, a group filling `box`, then each mark under it, in drawing order. */\nexport function plotSpecs<TLayer extends string = 'main'>(data: PlotData, opts: PlotSpecsOptions<TLayer>): PlotSpec<TLayer>[] {\n const id = opts.id ?? 'plot';\n const layer = (opts.layer ?? 'main') as TLayer;\n const theme = opts.theme ?? PLOT_THEME;\n const { x, y, width, height } = opts.box;\n const marks = compilePlot(data, { width, height }, theme, opts.measure ?? textMeasure);\n const root: PlotSpec<TLayer> = { kind: 'group', id: id as NodeId, layer, pose: { x, y, width, height }, data: { plot: { data, theme } } };\n return [root, ...markSpecs(id, layer, marks)];\n}\n\n/** Options for {@link replacePlotData}. */\nexport interface ReplacePlotOptions {\n /** The undo entry's label. Default `'Edit chart'`. */\n label?: string;\n /** Draw in this theme from now on. Default the one the root keeps. */\n theme?: PlotTheme;\n /** Default {@link textMeasure}. */\n measure?: PlotMeasure;\n}\n\ntype AnyScene = Scene<unknown, string, unknown>;\n\n/** The plot root `rootId`'s trait. Throws when `rootId` is not one. */\nfunction rootTrait(scene: AnyScene, rootId: string): { node: NonNullable<ReturnType<AnyScene['get']>>; trait: PlotRootTrait } {\n const node = scene.get(rootId as NodeId);\n const trait = plotRootOf(node);\n if (node === undefined || trait === null) throw new Error(`replacePlotData: \"${rootId}\" is not a plot root`);\n return { node, trait };\n}\n\n/** Replaces the spec of the plot rooted at `rootId` with `data` and rebuilds its marks, as one undo entry. */\nexport function replacePlotData<TData, TLayer extends string, TPose>(\n scene: Scene<TData, TLayer, TPose>, rootId: string, data: PlotData, opts: ReplacePlotOptions = {},\n): void {\n const s = scene as unknown as AnyScene;\n const { node, trait } = rootTrait(s, rootId);\n const theme = opts.theme ?? trait.theme;\n const pose = node.pose as RectPose;\n const marks = compilePlot(data, { width: pose.width, height: pose.height }, theme, opts.measure ?? textMeasure);\n s.batch(opts.label ?? 'Edit chart', () => {\n s.update(node.id, { data: { ...(node.data as object), plot: { data, theme } } });\n const children = s.childrenOf(node.id);\n if (children.length > 0) s.removeMany(children);\n for (const spec of markSpecs(rootId, node.layer, marks)) s.add(spec as never);\n });\n}\n\n/** Every plot root in `scene`, in render order. */\nexport function plotRootsIn(scene: Scene<unknown, string, unknown>): NodeId[] {\n return scene.renderOrderNodes().filter((n) => plotRootOf(n) !== null).map((n) => n.id);\n}\n","/** Dragging an xychart's bar ends and line points to change their values. */\nimport type { PlotEditor } from '../editing/editors';\nimport { compileXyChart } from './compile';\nimport { setXyValue, xyValueAt } from './edit';\nimport type { XyChartData } from './types';\n\nconst seriesIndex = (datum: unknown): { series: number; index: number } | null => {\n const d = datum as { series?: unknown; index?: unknown } | undefined;\n return typeof d?.series === 'number' && typeof d.index === 'number' ? { series: d.series, index: d.index } : null;\n};\n\n/** A bar's value end and a line's points take a press; a drag moves the value along the value axis. */\nexport const xyEditor: PlotEditor<XyChartData> = {\n handle(data, { trait, pose }) {\n if ((trait.kind !== 'bar' && trait.kind !== 'point') || seriesIndex(trait.datum) === null) return null;\n const vertical = data.orientation !== 'horizontal';\n const cursor = vertical ? 'ns-resize' : 'ew-resize';\n const cx = pose.x + pose.width / 2;\n const cy = pose.y + pose.height / 2;\n if (trait.kind === 'point') return { at: { x: cx, y: cy }, cursor };\n const up = Number(trait.datum?.value ?? 0) >= 0;\n return vertical\n ? { at: { x: cx, y: up ? pose.y : pose.y + pose.height }, cursor }\n : { at: { x: up ? pose.x + pose.width : pose.x, y: cy }, cursor };\n },\n drag(data, trait, size, theme, measure) {\n const which = seriesIndex(trait.datum);\n if (which === null) return null;\n const { layout } = compileXyChart(data, size, theme, measure);\n return (at) => setXyValue(data, which.series, which.index, xyValueAt(layout, at));\n },\n};\n","/** What each chart kind lets a drag edit: which marks carry a handle, and the spec a drag of one proposes. */\nimport type { PlotBox, PlotMarkTrait, PlotPoint } from '../marks/types';\nimport type { PlotMeasure } from '../measure';\nimport type { PlotData, PlotKind } from '../plotData';\nimport type { PlotTheme } from '../theme';\nimport { xyEditor } from '../xychart/editor';\n\n/** A handle a press can take: where it stands in the plot's coordinates, and the cursor over it. */\nexport interface PlotHandle {\n at: PlotPoint;\n cursor: 'ns-resize' | 'ew-resize' | 'move';\n}\n\n/** One chart kind's edits. */\nexport interface PlotEditor<D extends PlotData> {\n /** The handle on a mark, or `null` for a mark a drag does not edit. */\n handle(data: D, mark: { trait: PlotMarkTrait; pose: PlotBox }): PlotHandle | null;\n /** A drag that took the handle on `mark`: the spec it proposes with the pointer at a point in the plot's coordinates.\n * `null` when the mark has nothing to edit. */\n drag(data: D, mark: PlotMarkTrait, size: { width: number; height: number }, theme: PlotTheme, measure: PlotMeasure): ((at: PlotPoint) => D) | null;\n}\n\nconst EDITORS: { readonly [K in PlotKind]?: PlotEditor<Extract<PlotData, { kind: K }>> } = {\n xychart: xyEditor,\n};\n\n/** The edits `data`'s kind allows, or `null` for a kind with none. */\nexport const plotEditorOf = (data: PlotData): PlotEditor<PlotData> | null =>\n (EDITORS[data.kind] as PlotEditor<PlotData> | undefined) ?? null;\n","/**\n * What makes a plot's editable marks grabbable: a hit-only point region at\n * each handle its kind's editor names, composed into a layer whose id is the\n * kind a press reports.\n */\nimport {\n composeAffordanceLayer, composeWorldPose, scenePoseAdapter,\n type Affordance, type AffordanceRegion, type RectPose, type RenderLayer, type Scene,\n} from '@weasel-js/core';\nimport type { PlotPoint } from '../marks/types';\nimport { plotMarkOf, plotRootOf, plotRootsIn } from '../plotScene';\nimport { plotEditorOf, type PlotHandle } from './editors';\n\n/** The layer id the handles are composed into. */\nexport const PLOT_HANDLE_LAYER_ID = 'plot-handles';\n\n/** The affordance kind a press on a handle reports. */\nexport const PLOT_HANDLE_AFFORDANCE_KIND = `layer:${PLOT_HANDLE_LAYER_ID}` as const;\n\n/** What a press on a handle hands the drag, as the hit's `payload`. */\nexport interface PlotHandleScratch {\n rootId: string;\n markId: string;\n /** The handle, in world coordinates. */\n at: PlotPoint;\n}\n\n/** A press's scratch, read back off the hit an action was handed. */\nexport function plotHandleScratchOf(hit: { payload?: unknown } | null | undefined): PlotHandleScratch | null {\n const p = hit?.payload as PlotHandleScratch | undefined;\n return p !== undefined && typeof p.rootId === 'string' && typeof p.markId === 'string' ? p : null;\n}\n\ntype AnyScene = Scene<unknown, string, unknown>;\n\n/** Where the plot root `rootId`'s corner stands in world coordinates. */\nexport function plotOrigin(scene: AnyScene, rootId: string): PlotPoint {\n const pose = composeWorldPose(scenePoseAdapter(scene as never), rootId, scene.composition.compose as never) as RectPose;\n return { x: pose.x, y: pose.y };\n}\n\n/** Every handle in `scene` an edit may take, in world coordinates, in render order. */\nexport function* plotHandles(scene: AnyScene): Iterable<PlotHandleScratch & PlotHandle> {\n for (const rootId of plotRootsIn(scene)) {\n const root = scene.get(rootId);\n const trait = plotRootOf(root);\n const editor = trait && plotEditorOf(trait.data);\n if (trait === null || editor === null || scene.isLocked(rootId) || scene.isHidden(rootId)) continue;\n const origin = plotOrigin(scene, rootId);\n for (const id of scene.childrenOf(rootId)) {\n const node = scene.get(id);\n const mark = plotMarkOf(node);\n if (node === undefined || mark === null) continue;\n const handle = editor.handle(trait.data, { trait: mark, pose: node.pose as RectPose });\n if (handle === null) continue;\n yield { rootId, markId: id, cursor: handle.cursor, at: { x: origin.x + handle.at.x, y: origin.y + handle.at.y } };\n }\n }\n}\n\nconst HIT_RADIUS_PX = 6;\n\nfunction handleAffordance(scene: AnyScene): Affordance {\n const regions = (): AffordanceRegion[] => [...plotHandles(scene)].map(({ rootId, markId, at, cursor }) => ({\n id: markId,\n targetId: null,\n shape: { kind: 'point', x: at.x, y: at.y, hitRadiusPx: HIT_RADIUS_PX },\n cursor,\n strength: 'exclusive',\n claimedKinds: ['pointer'],\n bind: () => ({ initialScratch: { rootId, markId, at } satisfies PlotHandleScratch }),\n }));\n return { id: PLOT_HANDLE_LAYER_ID, regions, regionsAt: regions };\n}\n\n/** The handle layer, for `CanvasExtensionApi.registerLayer`. */\nexport function plotHandleLayer(scene: Scene<unknown, string, unknown>): RenderLayer<unknown> {\n return composeAffordanceLayer(PLOT_HANDLE_LAYER_ID, 'Plot handles', [handleAffordance(scene)]) as unknown as RenderLayer<unknown>;\n}\n","/**\n * Dragging a plot's handle to edit the value behind it. The handle layer\n * claims the press; this action previews every mark the proposed spec\n * redraws, and commits the spec as one edit of the plot's root.\n */\nimport type { Action, InvocationCtx, NodeId, OngoingHandle, RectPose, Scene } from '@weasel-js/core';\nimport type { PlotPoint } from '../marks/types';\nimport { textMeasure, type PlotMeasure } from '../measure';\nimport { compilePlot, type PlotData } from '../plotData';\nimport { markSpecs, plotMarkOf, plotRootOf, replacePlotData, type PlotSpec } from '../plotScene';\nimport { plotEditorOf } from './editors';\nimport { plotHandleScratchOf, plotOrigin } from './handleLayer';\n\n/** The action that drags a plot's handle. */\nexport const PLOT_DRAG_ACTION_ID = 'plot.dragValue';\n\n/** A plot edited: the root, and the spec it now holds. */\nexport interface PlotEdit {\n rootId: string;\n data: PlotData;\n}\n\n/** Options for {@link createPlotDragAction}. */\nexport interface PlotDragOptions {\n id?: string;\n /** Default {@link textMeasure}. */\n measure?: PlotMeasure;\n /** Defaults to {@link replacePlotData} against `deps.scene`, labeled \"Edit value\". */\n commit?: (edit: PlotEdit, ctx: InvocationCtx) => void;\n}\n\ntype AnyScene = Scene<unknown, string, unknown>;\n\n/** What a drag captured at its press, read-only after. */\ninterface PlotPress {\n rootId: string;\n /** The spec the pointer at a point in the plot's coordinates proposes. */\n propose: (at: PlotPoint) => PlotData;\n /** From the world to the plot's coordinates, the grab offset included. */\n toPlot: (world: PlotPoint) => PlotPoint;\n redraw: (data: PlotData) => PlotSpec<string>[];\n deps: InvocationCtx['deps'];\n}\n\nfunction pressOf(ctx: InvocationCtx, measure: PlotMeasure): PlotPress | null {\n const pressed = plotHandleScratchOf(ctx.drag?.affordance);\n const scene = ctx.deps.scene as AnyScene | undefined;\n const root = pressed === null ? undefined : scene?.get(pressed.rootId as NodeId);\n const trait = plotRootOf(root);\n const mark = plotMarkOf(pressed === null ? undefined : scene?.get(pressed.markId as NodeId));\n const editor = trait && plotEditorOf(trait.data);\n if (pressed === null || scene === undefined || root === undefined || trait === null || mark === null || editor === null) return null;\n const size = { width: (root.pose as RectPose).width, height: (root.pose as RectPose).height };\n const propose = editor.drag(trait.data, mark, size, trait.theme, measure);\n if (propose === null) return null;\n const origin = plotOrigin(scene, pressed.rootId);\n const start = ctx.drag?.start ?? ctx.world;\n const grab = { x: pressed.at.x - start.x, y: pressed.at.y - start.y };\n return {\n rootId: pressed.rootId,\n propose,\n toPlot: (w) => ({ x: w.x + grab.x - origin.x, y: w.y + grab.y - origin.y }),\n redraw: (data) => markSpecs(pressed.rootId, root.layer, compilePlot(data, size, trait.theme, measure)),\n deps: ctx.deps,\n };\n}\n\n/** The default commit: the spec into the root, its marks rebuilt, as one history entry, \"Edit value\". */\nexport function commitPlotToScene(edit: PlotEdit, ctx: InvocationCtx, measure: PlotMeasure = textMeasure): void {\n const scene = ctx.deps.scene as AnyScene | undefined;\n if (scene === undefined || plotRootOf(scene.get(edit.rootId as NodeId)) === null) return;\n replacePlotData(scene, edit.rootId, edit.data, { label: 'Edit value', measure });\n}\n\n/** The `plot.dragValue` action: an ongoing drag that moves one value of a plot, previewing the marks it redraws. */\nexport function createPlotDragAction(opts: PlotDragOptions = {}): Action {\n const measure = opts.measure ?? textMeasure;\n const commit = opts.commit ?? ((edit: PlotEdit, ctx: InvocationCtx) => commitPlotToScene(edit, ctx, measure));\n return {\n id: opts.id ?? PLOT_DRAG_ACTION_ID,\n label: 'Edit value',\n group: 'plot',\n requires: ['scene'],\n eligible: { mode: 'normal' },\n invoker: {\n timing: 'ongoing',\n start(ctx: InvocationCtx): OngoingHandle {\n const p = pressOf(ctx, measure);\n if (p === null) return {};\n // Null until the pointer moves, so a still click commits nothing.\n let next: PlotData | null = null;\n let shown = new Map<string, PlotSpec<string>>();\n let open = true;\n const scene = ctx.deps.scene as AnyScene;\n const previewing = () => (open && next !== null ? shown : null);\n return {\n kind: 'plot-drag-value',\n onMove(moveCtx: InvocationCtx): void {\n next = p.propose(p.toPlot(moveCtx.world));\n shown = new Map(p.redraw(next).map((spec) => [spec.id as string, spec]));\n },\n previewIds: () => {\n const specs = previewing();\n return specs === null ? null : [...specs.keys()].filter((id) => scene.get(id as NodeId) !== undefined);\n },\n previewPose: (id) => previewing()?.get(id)?.pose ?? null,\n previewData: (id) => previewing()?.get(id)?.data ?? null,\n onEnd(endCtx: InvocationCtx, reason: 'commit' | 'cancel'): void {\n open = false;\n if (reason !== 'commit' || next === null) return;\n commit({ rootId: p.rootId, data: p.propose(p.toPlot(endCtx.world)) }, { ...endCtx, deps: p.deps });\n },\n };\n },\n },\n enabled: () => true as const,\n };\n}\n","import type { Action, Contribution, RenderLayer, Scene } from '@weasel-js/core';\nimport { PLOT_DRAG_ACTION_ID, createPlotDragAction, type PlotDragOptions } from './dragAction';\nimport { PLOT_HANDLE_AFFORDANCE_KIND, plotHandleLayer } from './handleLayer';\n\n/** The action id that absorbs a press on a handle, so it reaches neither marquee nor pan. */\nexport const GRAB_PLOT_HANDLE_ACTION_ID = 'plot.grabHandle';\n\nconst grabHandleAction: Action = {\n id: GRAB_PLOT_HANDLE_ACTION_ID,\n label: 'Grab chart handle',\n group: 'plot',\n invoker: { timing: 'immediate', run: () => {} },\n enabled: () => true as const,\n};\n\n/**\n * Both halves of editing a scene's plots by dragging: the handle layer to\n * `registerLayer`, and the contribution to pass as `ambient`, which binds a\n * drag on a handle to `plot.dragValue`. One without the other fails quietly:\n * the layer alone claims presses that start nothing, the contribution alone\n * binds a kind nothing reports.\n */\nexport function plotEditing(\n opts: PlotDragOptions & { scene: Scene<unknown, string, unknown> },\n): { layer: RenderLayer<unknown>; contribution: Contribution } {\n const actionId = opts.id ?? PLOT_DRAG_ACTION_ID;\n const target = `affordance:${PLOT_HANDLE_AFFORDANCE_KIND}` as const;\n return {\n layer: plotHandleLayer(opts.scene),\n contribution: {\n id: 'weasel-plot-editing',\n eligibility: { claimed: true },\n actions: [createPlotDragAction({ ...opts, id: actionId }), grabHandleAction],\n bindings: [\n { spec: { kind: 'drag', target }, actionId, opts: { id: 'weasel-plot-editing.drag' } },\n { spec: { kind: 'pointerDown', target }, actionId: GRAB_PLOT_HANDLE_ACTION_ID, opts: { id: 'weasel-plot-editing.pointerDown' } },\n { spec: { kind: 'click', target }, actionId: GRAB_PLOT_HANDLE_ACTION_ID, opts: { id: 'weasel-plot-editing.click' } },\n ],\n },\n };\n}\n","import {\n SceneCanvas, WeaselProvider, useLatest, useScene, type NodeId, type Paint, type RectPose, type SceneCanvasApi,\n} from '@weasel-js/core';\nimport { useEffect, useMemo, useState, type ReactElement } from 'react';\nimport { plotEditing } from './editing/plotEditing';\nimport type { PlotMeasure } from './measure';\nimport type { PlotData } from './plotData';\nimport { plotRootOf, plotSpecs, replacePlotData, type PlotSceneData, type PlotSpec } from './plotScene';\nimport type { PlotTheme } from './theme';\n\n/** Props for {@link PlotView}. */\nexport interface PlotViewProps {\n /** The chart. A new value redraws it, with no undo entry. */\n data: PlotData;\n /** Hears each edit a drag commits, with the spec it leaves. Undo and redo in the view report too. */\n onChange?: (data: PlotData) => void;\n width: number;\n height: number;\n /** Default the weasel theme's dark mode. */\n theme?: PlotTheme;\n measure?: PlotMeasure;\n background?: Paint;\n className?: string;\n 'aria-label'?: string;\n}\n\nconst ROOT = 'plot';\nconst FEATURES = ['pick'] as const;\n\n/**\n * A chart on its own canvas, edited by dragging its marks: a bar's end or a\n * line's point moves its value. Each drag is one undo entry. Text paints only\n * in a registered font family, so register the theme's (`registerCanvasFont`).\n */\nexport function PlotView(props: PlotViewProps): ReactElement {\n return (\n <WeaselProvider>\n <Inner {...props} />\n </WeaselProvider>\n );\n}\n\nfunction Inner({ data, onChange, width, height, theme, measure, background, className, 'aria-label': label }: PlotViewProps): ReactElement {\n const [initial] = useState(() => plotSpecs(data, {\n id: ROOT, box: { x: 0, y: 0, width, height }, ...(theme ? { theme } : {}), ...(measure ? { measure } : {}),\n }));\n const scene = useScene<PlotSceneData, 'main', RectPose>({ systemLayers: [{ id: 'main' }], initial: initial as PlotSpec[] });\n const changed = useLatest(onChange);\n\n // A spec from outside redraws without an undo entry; one the view reported back is already drawn.\n useEffect(() => {\n const root = scene.get(ROOT as NodeId);\n const pose = root?.pose;\n const trait = plotRootOf(root);\n const sized = pose !== undefined && pose.width === width && pose.height === height;\n if (trait === null || (trait.data === data && sized && (theme === undefined || trait.theme === theme))) return;\n scene.untracked(() => {\n if (!sized) scene.setPose(ROOT as NodeId, { x: 0, y: 0, width, height });\n replacePlotData(scene, ROOT, data, { ...(theme ? { theme } : {}), ...(measure ? { measure } : {}) });\n });\n }, [scene, data, width, height, theme, measure]);\n\n useEffect(() => {\n let last = plotRootOf(scene.get(ROOT as NodeId))?.data;\n return scene.subscribe(() => {\n const now = plotRootOf(scene.get(ROOT as NodeId))?.data;\n if (now === undefined || now === last) return;\n last = now;\n changed.current?.(now);\n });\n }, [scene, changed]);\n\n const editing = useMemo(() => plotEditing({ scene: scene as never, ...(measure ? { measure } : {}) }), [scene, measure]);\n const ambient = useMemo(() => [editing.contribution], [editing]);\n const [canvas, setCanvas] = useState<SceneCanvasApi | null>(null);\n useEffect(() => (canvas === null ? undefined : canvas.registerLayer(editing.layer)), [canvas, editing]);\n\n return (\n <div className={className} data-wzl-plot=\"\">\n <SceneCanvas\n ref={setCanvas}\n scene={scene}\n features={FEATURES}\n enableKeybindings\n ambient={ambient}\n width={width}\n height={height}\n {...(background ? { backgroundFill: background } : {})}\n {...(label ? { 'aria-label': label } : {})}\n />\n </div>\n );\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weasel-js/plot",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.15.0",
|
|
4
|
+
"description": "Charts on weasel's scene graph: scales, axes, and marks that keep their data, and chart specs compiled to them, edited by dragging the marks.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"module": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts"
|
|
15
|
+
},
|
|
16
|
+
"./package.json": "./package.json"
|
|
17
|
+
},
|
|
18
|
+
"author": "orochi235",
|
|
19
|
+
"homepage": "https://orochi235.github.io/weasel/",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/orochi235/weasel.git",
|
|
23
|
+
"directory": "packages/plot"
|
|
24
|
+
},
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/orochi235/weasel/issues"
|
|
27
|
+
},
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=22"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"README.md",
|
|
34
|
+
"LICENSE"
|
|
35
|
+
],
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsup"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@weasel-js/geom": "1.15.0",
|
|
41
|
+
"@weasel-js/text": "1.15.0",
|
|
42
|
+
"@weasel-js/theme": "1.15.0"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"@weasel-js/core": "1.15.0",
|
|
46
|
+
"react": ">=18"
|
|
47
|
+
},
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"access": "public",
|
|
50
|
+
"provenance": true
|
|
51
|
+
}
|
|
52
|
+
}
|