chartist 2.0.0-rc.2 → 2.0.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/README.md +4 -4
- package/dist/chartist.min.css +1 -1
- package/dist/chartist.min.js +2 -1
- package/dist/compat.cjs +7 -0
- package/dist/compat.cjs.map +1 -1
- package/dist/compat.js +7 -0
- package/dist/compat.js.map +1 -1
- package/dist/compat.min.js +1 -1
- package/dist/compat.min.js.map +1 -1
- package/dist/compat.umd.js +1 -1
- package/dist/compat.umd.js.map +1 -1
- package/dist/index.cjs +1185 -202
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +192 -52
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +3442 -2701
- package/dist/index.d.ts +3442 -2701
- package/dist/index.js +1179 -203
- package/dist/index.js.map +1 -1
- package/dist/index.min.css +1 -1
- package/dist/index.min.css.map +1 -1
- package/dist/index.min.js +2 -1
- package/dist/index.min.js.map +1 -1
- package/dist/index.umd.js +2 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/live.cjs +770 -0
- package/dist/live.cjs.map +1 -0
- package/dist/live.d.cts +203 -0
- package/dist/live.d.ts +202 -0
- package/dist/live.js +767 -0
- package/dist/live.js.map +1 -0
- package/dist/live.min.js +4 -0
- package/dist/live.min.js.map +1 -0
- package/dist/live.umd.js +4 -0
- package/dist/live.umd.js.map +1 -0
- package/dist/scss/_settings.scss +22 -0
- package/dist/scss/index.scss +107 -6
- package/package.json +12 -1
package/dist/compat.min.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compat.min.js","names":["compat","core","__defProp","__exportAll","target","name","all","no_symbols","untyped","handle","nonEmptyRange","highLow","high","low","compat_exports","compat","fromLegacyPlugin","LEGACY_EVENTS","states","ANIMATION_EMITTER","PRESET_STATE","presetOf","CLASSES","LineChart","BarChart","PieChart","mutableCopy","value","proto","key","entry","isLegacyAxisClass","type","chartRectOf","layout","area","lineAxes","normalized","normalizeData","data","options","series","axisUnits","chartRect","StepAxis","AutoScaleAxis","isNumeric","serialSums","serialMap","values","sum","safeHasProperty","barAxes","horizontal","valueDimension","labelDimension","found","getHighLow","valueOptions","labelOptions","valueAxis","labelAxis","AXES","emitDrawEvents","state","axisOf","dimension","axisX","axisY","wrap","Svg","element","draw","payload","parts","elementOf","node","grids","findAll","scene","allLabels","labels","n","sliceLabels","order","onAxis","indexes","a","b","index","grid","label","background","rawSeries","seriesIndex","common","children","slice","ctx","labelCtx","barNode","point","shapes","shape","svgElement","enable","existing","config","change","svg","output","instance","event","optionsProviderOf","getOptions","legacyChart","preset","chart","listener","override","legacyPlugin","plugin","chartObject","getDataArray","reverse","LEGACY_NAMES","installGlobal","root","add"],"sources":["../src/chart/types.ts","../src/core/data/range.ts","../src/compat/index.ts","../src/compat/global.ts","../src/compat/entry.ts"],"sourcesContent":["import type { PipelineOptions } from '../pipeline/phases';\nimport type {\n AllPhasesListener,\n PhaseListener,\n PhaseListeners,\n PhaseName\n} from '../pipeline/types';\nimport type { Renderer } from '../render/types';\nimport type { ResponsiveSet } from '../responsive/responsive';\n\n/**\n * The custom events a chart can emit, by name, with their payloads. The\n * core emits only `responsive`. A plugin that emits events of its own\n * declares them here (TypeScript merges your declaration into Chartist's),\n * so `on()`, `off()` and `emit()` check the names and payloads:\n *\n * ```ts\n * declare module 'chartist' {\n * interface ChartEvents {\n * 'legend:click': { readonly seriesIndex: number };\n * }\n * }\n * ```\n *\n * `chartist/compat` declares the 1.x events (`draw`, `created`, …).\n * @experimental\n */\nexport interface ChartEvents {\n /**\n * Responsive entries changed which overrides apply: the config before\n * and after (`chart()`), or the options before and after (presets).\n */\n responsive:\n | {\n readonly previousConfig: ChartConfig;\n readonly currentConfig: ChartConfig;\n }\n | { readonly previousOptions: unknown; readonly currentOptions: unknown };\n}\n\n/**\n * The name of a custom event: a key of {@link ChartEvents}. Plugins list\n * the names they emit in `provides`.\n */\nexport type CustomEventName = keyof ChartEvents & string;\n\n/**\n * A plugin: a name and an `install` function that registers listeners on\n * the chart. Plugins go into `plugins`, in the config of {@link chart} or\n * the options of the presets. They install in order, so with two\n * listeners on the same event, the earlier plugin's runs first.\n *\n * For options, write a function that takes them and returns the plugin, or\n * read them from the second argument of `install` and pass the plugin\n * with {@link withOptions}.\n *\n * @example\n * ```ts\n * import { barChart, type ChartPlugin } from 'chartist';\n *\n * // Bars at or above the limit get the class ct-over.\n * const threshold = (limit: number): ChartPlugin => ({\n * name: 'threshold',\n * install(chart) {\n * chart.on('compose', current => {\n * if (current.role !== 'bar') {\n * return;\n * }\n * const { value } = current.ctx;\n * const y =\n * typeof value === 'number'\n * ? value\n * : value && 'y' in value\n * ? value.y\n * : undefined;\n * return y !== undefined && y >= limit\n * ? current.addClass('ct-over')\n * : undefined;\n * });\n * }\n * });\n *\n * barChart('#chart', { series: [[5, 4, 3, 7]] }, { plugins: [threshold(5)] });\n * ```\n * @experimental\n */\nexport interface ChartPlugin<TOptions = unknown> {\n /** Names the plugin. Prefix your custom events with it to keep them apart. */\n readonly name: string;\n /**\n * The custom events this plugin emits with `chart.emit()`, each declared\n * in {@link ChartEvents}. They're known before any plugin installs, so\n * another plugin may listen to them.\n */\n readonly provides?: readonly CustomEventName[];\n /**\n * Sets the plugin up: runs once, before the first render, with the\n * chart's handle. Listeners registered here stay for every later render,\n * after updates and resizes too, and `off(name)` without a listener\n * leaves them alone: remove one with its reference.\n * @param chart The chart's handle, to listen to events and emit them.\n * @param options The options of a `[plugin, options]` entry, if any.\n */\n install(chart: ChartHandle, options?: TOptions): void;\n}\n\n/**\n * A plugin paired with its options, as {@link withOptions} creates it.\n * `install` receives the options as its second argument.\n */\nexport type PluginWithOptions<TOptions = unknown> = readonly [\n ChartPlugin<TOptions>,\n TOptions\n];\n\n/**\n * An entry of a chart's `plugins`: a plugin, or a plugin with its options.\n * Prefer {@link withOptions} (it checks the options) or a function that\n * returns a plugin over a bare `[plugin, options]` pair. A 1.x plugin (a\n * plain function) throws; convert it with `fromLegacyPlugin()` from\n * `chartist/compat`.\n */\nexport type PluginEntry =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ChartPlugin<any> | PluginWithOptions<any>;\n\n/**\n * The config of {@link chart}: the data, the layers that draw it and the\n * axes they draw on, plus size, padding, plugins and listeners.\n *\n * Without `axes`, layers draw into the whole chart area; the pie layer\n * needs `coordinates: 'polar'`. {@link toScene} takes the same config.\n * @experimental\n */\nexport interface ChartConfig extends PipelineOptions {\n /**\n * Plugins to install before the first render, in order: plugins, or\n * plugins with their options from {@link withOptions}.\n */\n readonly plugins?: readonly PluginEntry[];\n /**\n * Phase listeners by phase name (or `'*'` for all phases). They're\n * registered before the first render, so they see it too.\n */\n readonly on?: PhaseListeners;\n /** Turns the scene into output; the DOM renderer by default. */\n readonly renderer?: Renderer;\n /**\n * Overrides that apply while their condition matches, created with\n * `responsive([...])`: entries of a media query string or a\n * `container()` condition, and a partial config. The chart renders again\n * when the matching entries change.\n */\n readonly responsive?: ResponsiveSet<ChartOverrides>;\n}\n\n/**\n * The part of a {@link ChartConfig} that responsive entries can override:\n * everything but `responsive`, `plugins`, `on` and `renderer`. The\n * matching entries merge over the config in order, shallowly.\n * @experimental\n */\nexport type ChartOverrides = Partial<\n Omit<ChartConfig, 'responsive' | 'plugins' | 'on' | 'renderer'>\n>;\n\n/**\n * The handle {@link chart} returns: update or remove the chart, and listen\n * to its events. Plugins get the same handle in `install`. The methods\n * other than `destroy` and `emit` return the handle, so calls chain.\n * @experimental\n */\nexport interface ChartHandle {\n /** The element the chart renders into (undefined in `toScene`). */\n readonly container?: Element;\n /**\n * Shallow-merges the changes into the config and renders again. Plugins\n * and listeners stay; `plugins` and `on` can't change.\n */\n update(config: Partial<Omit<ChartConfig, 'plugins' | 'on'>>): this;\n /**\n * Stops reacting to container size changes (and media queries in\n * presets). The output and the listeners stay.\n */\n detach(): this;\n /** Detaches, removes the output and clears all listeners. */\n destroy(): void;\n /**\n * Emits a custom event (declared in {@link ChartEvents}), e.g. from a\n * plugin. Phase names are reserved: emitting one throws.\n */\n emit<K extends CustomEventName>(name: K, payload: ChartEvents[K]): void;\n /**\n * Listens to a phase event, which fires on every render. Listeners of\n * `resolve` to `scene` may return a new payload to change what's drawn;\n * `compose` listeners may return `null` to drop a node.\n */\n on<K extends PhaseName>(name: K, listener: PhaseListener<K>): this;\n /** Listens to every phase event, with the phase name and its payload. */\n on(name: '*', listener: AllPhasesListener): this;\n /** Listens to a custom event, declared in {@link ChartEvents}. */\n on<K extends CustomEventName>(\n name: K,\n listener: (payload: ChartEvents[K]) => void\n ): this;\n /**\n * Removes a phase listener, whoever added it. Without a listener,\n * removes the listeners of the phase added through `on` and the\n * config's `on`; plugins keep theirs.\n */\n off<K extends PhaseName>(name: K, listener?: PhaseListener<K>): this;\n /**\n * Removes a listener of all phases, or without a listener, those added\n * through `on`.\n */\n off(name: '*', listener?: AllPhasesListener): this;\n /**\n * Removes a custom event listener, or without a listener, the event's\n * listeners added through `on`.\n */\n off<K extends CustomEventName>(\n name: K,\n listener?: (payload: ChartEvents[K]) => void\n ): this;\n}\n\n/**\n * Pairs a plugin with its options for a chart's `plugins`, and checks the\n * options against the plugin's options type. `install` receives them as\n * its second argument.\n *\n * @example\n * ```ts\n * import { lineChart, withOptions, type ChartPlugin } from 'chartist';\n *\n * const lastPoint: ChartPlugin<{ className: string }> = {\n * name: 'last-point',\n * install(chart, options) {\n * chart.on('compose', current => {\n * if (current.role !== 'series') {\n * return;\n * }\n * const last = current.children.at(-1);\n * return last && options\n * ? current.replace(last, last.addClass(options.className))\n * : undefined;\n * });\n * }\n * };\n *\n * lineChart(\n * '#chart',\n * { series: [[1, 3, 2, 5]] },\n * { plugins: [withOptions(lastPoint, { className: 'ct-last' })] }\n * );\n * ```\n * @experimental\n */\nexport function withOptions<TOptions>(\n plugin: ChartPlugin<TOptions>,\n options: TOptions\n): PluginWithOptions<TOptions> {\n return [plugin, options];\n}\n\n/**\n * The handle without event typing, for code that routes event names it\n * doesn't know (the 1.x chart classes, compat). Internal.\n */\nexport interface UntypedEvents {\n on(name: string, listener: (payload: unknown) => void): unknown;\n off(name: string, listener?: (payload: unknown) => void): unknown;\n emit(name: string, payload?: unknown): void;\n}\n\n/** The same handle, seen without event typing. Internal. */\nexport const untyped = (handle: ChartHandle): UntypedEvents =>\n handle as unknown as UntypedEvents;\n","/**\n * Repairs a value range that's empty because high is at or below low, from\n * flat data or a misconfigured `high`/`low`: sets the bound on the other\n * side of zero to 0, or gives `0` to `1` when there are no values. Chart\n * code that overrides a bound after `getHighLow` calls it again.\n *\n * @param highLow The range to check.\n * @returns The range, or the repaired one.\n */\nexport function nonEmptyRange(highLow: {\n readonly high: number;\n readonly low: number;\n}): { high: number; low: number } {\n const { high, low } = highLow;\n if (high > low) {\n return { high, low };\n }\n if (low === 0) {\n // Both are 0.\n return { high: 1, low };\n }\n if (low < 0) {\n // The same negative value for both.\n return { high: 0, low };\n }\n if (high > 0) {\n // The same positive value for both.\n return { high, low: 0 };\n }\n // No values: high and low are still -Number.MAX_VALUE and Number.MAX_VALUE.\n return { high: 1, low: 0 };\n}\n","/**\n * The compat plugin: 1.x events, `Svg` wrappers and 1.x plugins on v2\n * charts. Opt-in: `plugins: [compat]`, or convert a 1.x plugin with\n * `fromLegacyPlugin()`.\n *\n * Imports only from the package root, so the built `chartist/compat` entry\n * shares the core with `chartist` instead of bundling a copy.\n */\nimport {\n AutoScaleAxis,\n BarChart,\n LineChart,\n PieChart,\n Svg,\n StepAxis,\n axisUnits,\n findAll,\n getHighLow,\n isNumeric,\n normalizeData,\n safeHasProperty,\n serialMap,\n type ChartHandle,\n type ChartPlugin,\n type ChartRect,\n type Data,\n type Layout,\n type PresetState,\n type NormalizedSeries,\n type AxisLabelContext,\n type PieLabelContext,\n type RoleNode,\n type SceneNode\n} from '../index';\nimport { untyped } from '../chart/types';\nimport { nonEmptyRange } from '../core/data/range';\nimport type {\n AnimationEvent,\n AreaDrawEvent,\n AxesDrawEvent,\n BarChartCreatedEvent,\n BarDrawEvent,\n DataEvent,\n LineChartCreatedEvent,\n LineDrawEvent,\n OptionsChangedEvent,\n PieChartCreatedEvent,\n PointDrawEvent,\n SliceDrawEvent,\n SliceLabelDrawEvent\n} from '../index';\n\n// With chartist/compat, the 1.x events are typed on every chart handle.\ndeclare module '../chart/types' {\n interface ChartEvents {\n /**\n * 1.x: the chart's data, before the first render (`type: 'initial'`)\n * and after an update with new data (`type: 'update'`). Listeners can\n * change it in place. Needs the {@link compat} plugin.\n */\n data: DataEvent;\n /**\n * 1.x: the responsive options changed, with the options before and\n * after. Needs the {@link compat} plugin.\n */\n optionsChanged: OptionsChangedEvent;\n /**\n * 1.x: an element was drawn: a grid line, label, point, line, area,\n * bar or slice, with its live `element`. Check `type` to narrow it.\n * Needs the {@link compat} plugin.\n */\n draw:\n | PointDrawEvent\n | LineDrawEvent\n | AreaDrawEvent\n | BarDrawEvent\n | SliceDrawEvent\n | SliceLabelDrawEvent\n | AxesDrawEvent;\n /**\n * 1.x: the chart is drawn and in the DOM, after its `draw` events,\n * with the `svg`, the chart area and the axes. Needs the {@link compat}\n * plugin.\n */\n created:\n | LineChartCreatedEvent\n | BarChartCreatedEvent\n | PieChartCreatedEvent;\n /**\n * 1.x: an SMIL animation began, started with `animate()` on an element\n * of the chart, such as the `element` of a `draw` event. Needs the\n * {@link compat} plugin.\n */\n animationBegin: AnimationEvent;\n /**\n * 1.x: an SMIL animation ended, started with `animate()` on an element\n * of the chart. Needs the {@link compat} plugin.\n */\n animationEnd: AnimationEvent;\n }\n}\n\n/** The 1.x events the compat plugin emits. */\nconst LEGACY_EVENTS = [\n 'data',\n 'optionsChanged',\n 'draw',\n 'created',\n 'animationBegin',\n 'animationEnd'\n] as const;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype LegacyPlugin = (chart: any, options?: any) => void;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyOptions = any;\n\ninterface CompatState {\n preset?: PresetState<Data, AnyOptions>;\n /** The data object of the last `data` event, and its mutable copy. */\n source?: unknown;\n copy?: Data;\n layout?: Layout;\n svg?: Svg;\n /** 1.x chart instances whose `svg` field follows the chart's. */\n instances: { svg?: Svg }[];\n}\n\nconst states = new WeakMap<ChartHandle, CompatState>();\n\n/**\n * Where `Svg#animate()` looks for the emitter of an element's animations\n * when it gets none (on the element or an ancestor). The core reads the\n * same global symbol.\n */\nconst ANIMATION_EMITTER = Symbol.for('chartist.animationEmitter');\n\n/**\n * Where a preset's chart handle holds its preset state from the moment\n * plugins install. The core sets the same global symbol.\n */\nconst PRESET_STATE = Symbol.for('chartist.presetState');\n\nconst presetOf = (handle: ChartHandle) =>\n (handle as { [PRESET_STATE]?: PresetState<Data, AnyOptions> })[PRESET_STATE];\n\n/** The 1.x class of each preset, for 0.x and 1.x type checks in plugins. */\nconst CLASSES: Record<string, { prototype: object }> = {\n line: LineChart,\n bar: BarChart,\n pie: PieChart\n};\n\n/** Copies plain arrays and objects; other values are kept by reference. */\nfunction mutableCopy<T>(value: T): T {\n if (Array.isArray(value)) {\n return value.map(mutableCopy) as T;\n }\n if (value && typeof value === 'object') {\n const proto = Object.getPrototypeOf(value);\n if (proto === Object.prototype || proto === null) {\n return Object.fromEntries(\n Object.entries(value).map(([key, entry]) => [key, mutableCopy(entry)])\n ) as T;\n }\n }\n return value;\n}\n\nconst isLegacyAxisClass = (\n type: unknown\n): type is new (...args: unknown[]) => unknown =>\n typeof type === 'function' &&\n typeof (type as { prototype?: { projectValue?: unknown } }).prototype\n ?.projectValue === 'function';\n\nfunction chartRectOf(layout: Layout): ChartRect {\n const { area, padding } = layout;\n return {\n x1: area.x1,\n x2: area.x2,\n y1: area.y1,\n y2: area.y2,\n padding,\n width() {\n return this.x2 - this.x1;\n },\n height() {\n return this.y1 - this.y2;\n }\n };\n}\n\n/** The 1.x axes, constructed as 1.x `LineChart.createChart` does. */\nfunction lineAxes(options: AnyOptions, data: Data, chartRect: ChartRect) {\n const normalized = normalizeData(\n data as Data<NormalizedSeries[]>,\n options.reverseData,\n true\n );\n const series = normalized.series as NormalizedSeries[];\n const axisX = isLegacyAxisClass(options.axisX.type)\n ? new options.axisX.type(axisUnits.x, series, chartRect, options.axisX)\n : new StepAxis(axisUnits.x, series, chartRect, {\n ...options.axisX,\n ticks: normalized.labels,\n stretch: options.fullWidth\n });\n const axisY = isLegacyAxisClass(options.axisY.type)\n ? new options.axisY.type(axisUnits.y, series, chartRect, options.axisY)\n : new AutoScaleAxis(axisUnits.y, series, chartRect, {\n ...options.axisY,\n high: isNumeric(options.high) ? options.high : options.axisY.high,\n low: isNumeric(options.low) ? options.low : options.axisY.low\n });\n return { axisX, axisY };\n}\n\n/** Sums per index across series, as 1.x `BarChart` stacks them. */\nfunction serialSums(series: NormalizedSeries[]) {\n return serialMap(series, (...values) =>\n values.reduce<{ x: number; y: number }>(\n (sum, value) => ({\n x: sum.x + (safeHasProperty(value, 'x') ? (value.x as number) : 0),\n y: sum.y + (safeHasProperty(value, 'y') ? (value.y as number) : 0)\n }),\n { x: 0, y: 0 }\n )\n );\n}\n\n/** The 1.x axes, constructed as 1.x `BarChart.createChart` does. */\nfunction barAxes(options: AnyOptions, data: Data, chartRect: ChartRect) {\n const horizontal = Boolean(options.horizontalBars);\n const valueDimension = horizontal ? 'x' : 'y';\n const labelDimension = horizontal ? 'y' : 'x';\n const normalized = normalizeData(\n data as Data<NormalizedSeries[]>,\n options.reverseData,\n valueDimension,\n true\n );\n const series = normalized.series as NormalizedSeries[];\n const found =\n options.stackBars && options.stackMode !== true && series.length\n ? getHighLow([serialSums(series)], options, valueDimension)\n : getHighLow(series, options, valueDimension);\n // The chart-level bounds win, but can empty the range again (#1057).\n const highLow = nonEmptyRange({\n high: typeof options.high === 'number' ? options.high : found.high,\n low: typeof options.low === 'number' ? options.low : found.low\n });\n const valueOptions = horizontal ? options.axisX : options.axisY;\n const labelOptions = horizontal ? options.axisY : options.axisX;\n const ValueAxis = isLegacyAxisClass(valueOptions.type)\n ? valueOptions.type\n : AutoScaleAxis;\n const valueAxis = new ValueAxis(\n axisUnits[valueDimension],\n series,\n chartRect,\n {\n ...valueOptions,\n highLow,\n referenceValue: 0\n }\n );\n const labelAxis = isLegacyAxisClass(labelOptions.type)\n ? new labelOptions.type(\n axisUnits[labelDimension],\n series,\n chartRect,\n labelOptions\n )\n : new StepAxis(axisUnits[labelDimension], series, chartRect, {\n ticks:\n options.distributeSeries && options.stackBars\n ? normalized.labels.slice(0, 1)\n : normalized.labels\n });\n return horizontal\n ? { axisX: valueAxis, axisY: labelAxis }\n : { axisX: labelAxis, axisY: valueAxis };\n}\n\nconst AXES: Record<\n string,\n (\n options: AnyOptions,\n data: Data,\n chartRect: ChartRect\n ) => { axisX: unknown; axisY: unknown }\n> = {\n line: lineAxes,\n bar: barAxes,\n // Pie charts have no axes.\n pie: () => ({ axisX: undefined, axisY: undefined })\n};\n\n/** 1.x `draw` payloads in 1.x order, then `created`. */\nfunction emitDrawEvents(\n handle: ChartHandle,\n state: CompatState,\n scene: SceneNode,\n svgElement: Element,\n elementOf: (node: SceneNode) => Element | undefined\n) {\n const options = state.preset?.options as AnyOptions;\n const data = (state.copy ?? state.preset?.data) as Data;\n const chartRect = chartRectOf(state.layout!);\n const { axisX, axisY } = AXES[state.preset!.kind](options, data, chartRect);\n const axisOf = (dimension?: string) => (dimension === 'x' ? axisX : axisY);\n const wrap = (element: Element) => new Svg(element);\n const draw = (payload: Record<string, unknown>) =>\n untyped(handle).emit('draw', payload);\n const parts = (node: SceneNode) => {\n const element = elementOf(node)!;\n return { element: wrap(element), group: wrap(element.parentElement!) };\n };\n\n // Axes: per tick its grid line, then its label, in the order the axes\n // appear in the chart (X first for lines, the label axis first for bars).\n const grids = findAll(scene, { role: 'grid' });\n // Only axis labels; pie labels belong to their slice.\n const allLabels = findAll(scene, { role: 'label' });\n const labels = allLabels.filter(\n (n): n is RoleNode<'label'> & { ctx: AxisLabelContext } =>\n n.ctx.kind === 'axis'\n );\n const sliceLabels = allLabels.filter(\n (n): n is RoleNode<'label'> & { ctx: PieLabelContext } =>\n n.ctx.kind === 'pie'\n );\n const order = [\n ...new Set([...grids, ...labels].map(n => n.ctx.axis.dimension))\n ];\n for (const dimension of order) {\n const onAxis = (node: { ctx: { axis: { dimension: string } } }) =>\n node.ctx.axis.dimension === dimension;\n const indexes = [\n ...new Set([...grids, ...labels].filter(onAxis).map(n => n.ctx.index))\n ].sort((a, b) => a - b);\n for (const index of indexes) {\n const grid = grids.find(n => onAxis(n) && n.ctx.index === index);\n if (grid) {\n const { x1, y1, x2, y2 } = grid.attrs;\n draw({\n type: 'grid',\n axis: axisOf(dimension),\n index,\n ...parts(grid),\n x1,\n y1,\n x2,\n y2\n });\n }\n const label = labels.find(n => onAxis(n) && n.ctx.index === index);\n if (label) {\n const { x, y, width, height } = label.attrs;\n draw({\n type: 'label',\n axis: axisOf(dimension),\n index,\n ...parts(label),\n text: label.ctx.text,\n x,\n y,\n width,\n height\n });\n }\n }\n }\n for (const background of findAll(scene, { role: 'gridBackground' })) {\n draw({ type: 'gridBackground', ...parts(background) });\n }\n\n // Series: points, then the line, then the areas in creation order.\n const rawSeries = (data.series ?? []) as unknown[];\n for (const series of findAll(scene, { role: 'series' })) {\n const seriesIndex = series.ctx.seriesIndex;\n const original =\n rawSeries[\n options.reverseData ? rawSeries.length - 1 - seriesIndex : seriesIndex\n ];\n const common = { series: original, seriesIndex, axisX, axisY };\n const children = series.children;\n const slice = children.find(n => n.role === 'slice');\n if (slice) {\n const ctx = slice.ctx;\n draw({\n type: 'slice',\n value: ctx.value,\n totalDataSum: ctx.totalDataSum,\n index: ctx.index,\n meta: ctx.meta,\n series: ctx.series,\n ...parts(slice),\n path: ctx.path.clone(),\n center: ctx.center,\n radius: ctx.radius,\n startAngle: ctx.startAngle,\n endAngle: ctx.endAngle,\n chartRect\n });\n const label = sliceLabels.find(n => n.ctx.index === ctx.index);\n if (label) {\n const labelCtx = label.ctx;\n draw({\n type: 'label',\n index: labelCtx.index,\n ...parts(label),\n text: labelCtx.text,\n chartRect,\n series: labelCtx.series,\n meta: labelCtx.meta,\n x: labelCtx.x,\n y: labelCtx.y\n });\n }\n continue;\n }\n for (const barNode of children.filter(n => n.role === 'bar')) {\n const ctx = barNode.ctx!;\n draw({\n type: 'bar',\n value: ctx.value,\n index: ctx.valueIndex,\n meta: ctx.meta,\n series: ctx.series,\n seriesIndex,\n axisX,\n axisY,\n chartRect,\n ...parts(barNode),\n x1: ctx.x1,\n y1: ctx.y1,\n x2: ctx.x2,\n y2: ctx.y2\n });\n }\n for (const point of children.filter(n => n.role === 'point')) {\n const ctx = point.ctx!;\n draw({\n type: 'point',\n value: ctx.value,\n index: ctx.valueIndex,\n meta: ctx.meta,\n ...common,\n ...parts(point),\n x: ctx.x,\n y: ctx.y,\n chartRect\n });\n }\n const shapes = [\n ...children.filter(n => n.role === 'line'),\n // Areas are inserted first, so the DOM order is the reverse.\n ...children.filter(n => n.role === 'area').reverse()\n ];\n for (const shape of shapes) {\n const ctx = shape.ctx!;\n draw({\n type: shape.role,\n values: ctx.values,\n path: ctx.path.clone(),\n chartRect,\n index: seriesIndex,\n ...common,\n meta: ctx.meta,\n ...parts(shape)\n });\n }\n }\n\n // 0.x plugins also read `bounds`, the value axis's scale, which 0.x\n // passed next to the axes (auto scale axes only, as in 0.x).\n const valueAxis = options.horizontalBars ? axisX : axisY;\n untyped(handle).emit(\n 'created',\n state.preset!.kind === 'pie'\n ? { chartRect, svg: wrap(svgElement), options }\n : {\n chartRect,\n axisX,\n axisY,\n bounds: (valueAxis as { bounds?: unknown }).bounds,\n svg: wrap(svgElement),\n options\n }\n );\n}\n\n/** Turns the 1.x events on for a chart, once. */\nfunction enable(handle: ChartHandle): CompatState {\n const existing = states.get(handle);\n if (existing) {\n return existing;\n }\n const state: CompatState = { instances: [] };\n states.set(handle, state);\n\n handle.on('resolve', ({ config }) => {\n state.preset = config.preset as CompatState['preset'];\n if (config.data !== state.source) {\n // 1.x data handlers mutate the data; they get a copy, and the copy\n // is used from now on (as 1.x keeps its mutated data).\n state.copy = mutableCopy(config.data) as Data;\n untyped(handle).emit('data', {\n type: state.source === undefined ? 'initial' : 'update',\n data: state.copy\n });\n state.source = config.data;\n }\n return { config: { ...config, data: state.copy as typeof config.data } };\n });\n handle.on('layout', layout => {\n state.layout = layout;\n });\n handle.on('responsive', change =>\n 'previousOptions' in change\n ? untyped(handle).emit('optionsChanged', {\n previousOptions: change.previousOptions,\n currentOptions: change.currentOptions\n })\n : undefined\n );\n handle.on('mount', ({ scene, output, elementOf }) => {\n const svg = (output as { svg?: Element }).svg;\n if (!svg) {\n throw new Error('Chartist: the compat plugin requires the DOM renderer');\n }\n state.svg = new Svg(svg);\n // Set before the draw events, so listeners can query the chart.\n for (const instance of state.instances) {\n instance.svg = state.svg;\n }\n // Animations of the chart's elements emit animationBegin and\n // animationEnd on the chart, as 1.x did with the chart's emitter.\n (svg as { [ANIMATION_EMITTER]?: unknown })[ANIMATION_EMITTER] = {\n emit: (event: string, payload: unknown) =>\n untyped(handle).emit(event, payload)\n };\n if (state.preset) {\n emitDrawEvents(handle, state, scene, svg, elementOf);\n }\n });\n return state;\n}\n\n/** 1.x `optionsProvider`: the options in effect, after responsive options. */\nfunction optionsProviderOf(getOptions: () => unknown) {\n return {\n getCurrentOptions: getOptions,\n // The preset watches the media queries and stops on `detach()`.\n removeMediaQueryListeners: () => undefined\n };\n}\n\n/**\n * A 1.x-style chart object for 1.x plugins on the functional API. For a\n * preset it is an instance of the preset's 1.x class (without running its\n * constructor), so type checks such as `chart instanceof LineChart` hold;\n * for `chart()` compositions a plain object.\n */\nfunction legacyChart(handle: ChartHandle, state: CompatState) {\n const preset = presetOf(handle);\n const chart = {\n get container() {\n return handle.container;\n },\n get data() {\n return state.copy ?? preset?.data;\n },\n get options() {\n return preset?.options;\n },\n get svg() {\n return state.svg;\n },\n eventEmitter: {\n on: (event: string, listener: (payload: unknown) => void) =>\n untyped(handle).on(event, listener),\n off: (event: string, listener?: (payload: unknown) => void) =>\n untyped(handle).off(event, listener),\n emit: (event: string, payload: unknown) =>\n untyped(handle).emit(event, payload)\n },\n optionsProvider: optionsProviderOf(() => preset?.options),\n on(event: string, listener: (payload: unknown) => void) {\n untyped(handle).on(event, listener);\n return chart;\n },\n off(event: string, listener?: (payload: unknown) => void) {\n untyped(handle).off(event, listener);\n return chart;\n },\n update(data?: unknown, options?: unknown, override?: boolean) {\n if (preset) {\n preset.update(data as never, options as never, override);\n } else {\n handle.update(data ? { data: data as never } : {});\n }\n return chart;\n },\n detach() {\n if (preset) {\n preset.detach();\n } else {\n handle.detach();\n }\n return chart;\n }\n };\n // The fields above are own properties, so they shadow the class's.\n const type = preset && CLASSES[preset.kind];\n return type ? Object.setPrototypeOf(chart, type.prototype) : chart;\n}\n\n/**\n * Runs a 1.x plugin function as a v2 plugin, with the given chart object.\n * Used by the 1.x chart classes, which pass themselves.\n */\nfunction legacyPlugin(\n plugin: LegacyPlugin,\n options?: unknown,\n chart?: unknown\n): ChartPlugin {\n return {\n name: plugin.name || 'legacy-plugin',\n provides: LEGACY_EVENTS,\n install(handle) {\n const state = enable(handle);\n if (chart) {\n // A 1.x chart instance: keep its `svg` field current, as 1.x did.\n state.instances.push(chart as { svg?: Svg });\n // The 1.x classes run on a preset and have no options provider;\n // plugins call it for the options in effect.\n const instance = chart as { optionsProvider?: unknown };\n if (!instance.optionsProvider) {\n instance.optionsProvider = optionsProviderOf(\n () => presetOf(handle)?.options\n );\n }\n }\n const chartObject = chart ?? legacyChart(handle, state);\n // As 1.x: plugins without options are called with the chart only.\n if (options === undefined) {\n plugin(chartObject);\n } else {\n plugin(chartObject, options);\n }\n }\n };\n}\n\n/**\n * The compat plugin. Restores the 1.x events (`data`, `optionsChanged`,\n * `draw`, `created`, `animationBegin`, `animationEnd`) with 1.x payloads.\n * With it, the 1.x chart classes also run 1.x plugin functions.\n *\n * Add it to `plugins`, of a 1.x class, a preset or `chart()`. The `draw`\n * events come in the 1.x order, right after the chart is in the DOM, so\n * `element` is a live element; then `created`. Animations started with\n * `animate()` on the chart's elements emit `animationBegin` and\n * `animationEnd`. Importing\n * `chartist/compat` also types the 1.x events on every chart handle. It\n * needs the DOM renderer, and the `draw` and `created` events need a\n * chart made by a preset or a 1.x class.\n *\n * @example\n * ```ts\n * import { lineChart } from 'chartist';\n * import { compat } from 'chartist/compat';\n *\n * const chart = lineChart(\n * '#chart',\n * {\n * labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],\n * series: [[12, 9, 7, 8, 5]]\n * },\n * { plugins: [compat] }\n * );\n *\n * // Registered after the first render, so it runs from the next one on.\n * chart.on('draw', data => {\n * if (data.type === 'point' && data.index === 4) {\n * data.element.addClass('is-friday');\n * }\n * });\n * ```\n */\nexport const compat: ChartPlugin & { legacyPlugin: typeof legacyPlugin } = {\n name: 'compat',\n provides: LEGACY_EVENTS,\n install: handle => void enable(handle),\n legacyPlugin\n};\n\n/**\n * Converts a 1.x plugin function into a v2 plugin for `chart()` and the\n * preset functions. It turns the 1.x events on for the chart and calls the\n * plugin with a 1.x-style chart object (`container`, `data`, `options`,\n * `svg`, `eventEmitter`, `on`, `off`, `update`, `detach`). You don't need\n * {@link compat} in the list as well.\n *\n * @param plugin The 1.x plugin: a function that gets the chart (and its\n * options)\n * @param options The plugin's options; without them, the plugin is called\n * with the chart only, as in 1.x\n * @example\n * ```ts\n * import { lineChart, type Plugin } from 'chartist';\n * import { fromLegacyPlugin } from 'chartist/compat';\n *\n * // A 1.x plugin: a function that gets the chart and its options.\n * const caption: Plugin = (chart, options) => {\n * chart.on('created', () => {\n * chart.container.setAttribute('aria-label', options.text);\n * });\n * };\n *\n * lineChart(\n * '#chart',\n * { series: [[1, 3, 2, 4]] },\n * { plugins: [fromLegacyPlugin(caption, { text: 'Visitors per week' })] }\n * );\n * ```\n */\nexport function fromLegacyPlugin(\n plugin: LegacyPlugin,\n options?: unknown\n): ChartPlugin {\n return legacyPlugin(plugin, options);\n}\n\n// The types of the 1.x events and plugins this plugin turns on.\nexport type * from './types';\n","/**\n * The global `Chartist` that plugin scripts of the 0.x and 1.x era read.\n * They register on `Chartist.plugins`, check the chart type with\n * `instanceof Chartist.Line`, and call helpers such as `Chartist.extend`.\n * Importing `chartist/compat` (any build: module, CommonJS or the UMD\n * script) sets this up, so such a script works when it loads after it.\n *\n * The names are added to the global only, never exported: the module\n * builds keep the 1.x and v2 names.\n */\nimport * as core from '../index';\nimport {\n BarChart,\n LineChart,\n PieChart,\n normalizeData,\n type Data\n} from '../index';\n\n/**\n * 0.x: the values of each series as plain numbers (`undefined` for holes),\n * normalized as the 1.x charts do; reversed when `reverse` is true. Line\n * and bar data give an array per series, pie data one array.\n */\nexport function getDataArray(\n data: Data,\n reverse?: boolean\n): (number | undefined)[] | (number | undefined)[][] {\n return normalizeData(data as Data<never>, reverse).series as\n | (number | undefined)[]\n | (number | undefined)[][];\n}\n\n/** The 0.x names plugin scripts use, next to the library's own. */\nconst LEGACY_NAMES = {\n // 0.x names of the chart classes, for `chart instanceof Chartist.Line`.\n Line: LineChart,\n Bar: BarChart,\n Pie: PieChart,\n getDataArray\n};\n\ntype Root = { Chartist?: Record<string, unknown>; document?: unknown };\n\n/**\n * Adds the core, compat and the 0.x names to the global `Chartist`, only\n * what it lacks: a global set by the UMD build or by plugin scripts keeps\n * its values, and `plugins` keeps what scripts registered. If the global\n * belongs to another copy of Chartist (say the UMD build next to these\n * modules), it is left alone with a warning: mixing two copies breaks the\n * plugins' type checks. Outside a browser it does nothing.\n */\nexport function installGlobal(\n compat: Record<string, unknown>,\n root: Root = globalThis as Root\n): void {\n if (root.document === undefined) {\n return;\n }\n const existing = root.Chartist;\n if (existing && 'LineChart' in existing && existing.LineChart !== LineChart) {\n // A hint for developers, as the warnings for 1.x events without compat.\n // eslint-disable-next-line no-console\n console.warn(\n 'Chartist: the global `Chartist` belongs to another copy of Chartist, so chartist/compat leaves it alone. Load Chartist once: as modules, or as the UMD build with compat.umd.js.'\n );\n return;\n }\n const target = existing ?? (root.Chartist = {});\n const add = (name: string, value: unknown) => {\n if (!(name in target)) {\n target[name] = value;\n }\n };\n for (const [name, value] of Object.entries(core)) {\n add(name, value);\n }\n for (const [name, value] of Object.entries(compat)) {\n add(name, value);\n }\n add('plugins', {});\n for (const [name, value] of Object.entries(LEGACY_NAMES)) {\n add(name, value);\n }\n}\n","/**\n * The published entry of `chartist/compat`, in every build. Next to the\n * compat API, importing it sets up the global `Chartist` for plugin\n * scripts of the 0.x and 1.x era (see ./global.ts). That's why\n * package.json lists the compat files under `sideEffects`.\n */\nimport * as compat from './index';\nimport { installGlobal } from './global';\n\nexport * from './index';\n\ninstallGlobal(compat);\n"],"mappings":"wZAoRA,MAAaQ,EAAW,GACtBC,EC5QF,SAAgBC,EAAc,EAGI,CAChC,GAAM,CAAE,OAAM,OAAQC,EAiBtB,OAhBIC,EAAOC,EACF,CAAE,OAAM,KAAI,EAEjBA,IAAQ,EAEH,CAAE,KAAM,EAAG,KAAI,EAEpBA,EAAM,EAED,CAAE,KAAM,EAAG,KAAI,EAEpBD,EAAO,EAEF,CAAE,OAAM,IAAK,CAAE,EAGjB,CAAE,KAAM,EAAG,IAAK,CAAE,CAC3B,gECwEA,MAAMK,EAAgB,CACpB,OACA,iBACA,OACA,UACA,iBACA,cACF,EAkBMC,kBAAS,IAAI,QAObC,EAAoB,OAAO,IAAI,2BAA2B,EAM1DC,EAAe,OAAO,IAAI,sBAAsB,EAEhDC,EAAY,GACfZ,EAA8DW,GAG3DE,EAAiD,CACrD,KAAMC,EACN,IAAKC,EACL,IAAKC,CACP,EAGA,SAASC,EAAe,EAAa,CACnC,GAAI,MAAM,QAAQC,CAAK,EACrB,OAAOA,EAAM,IAAID,CAAW,EAE9B,GAAIC,GAAS,OAAOA,GAAU,SAAU,CACtC,IAAMC,EAAQ,OAAO,eAAeD,CAAK,EACzC,GAAIC,IAAU,OAAO,WAAaA,IAAU,KAC1C,OAAO,OAAO,YACZ,OAAO,QAAQD,CAAK,CAAC,CAAC,KAAK,CAACE,EAAKC,KAAW,CAACD,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B,EAAWqB,EAAK,SACtB,GAAIrB,GAAY,cAAeA,GAAYA,EAAS,YAAcnF,EAAW,CAG3E,QAAQ,KACN,kLACF,EACA,MACF,CACA,IAAMnB,EAASsG,IAAa,EAAK,SAAW,CAAC,GACvCsB,GAAO,EAAc,IAAmB,CACtC3H,KAAQD,IACZ,EAAOC,GAAQsB,EAEnB,EACA,IAAK,GAAM,CAACtB,EAAMsB,KAAU,OAAO,QAAQ1B,CAAI,EAC7C+H,EAAI3H,EAAMsB,CAAK,EAEjB,IAAK,GAAM,CAACtB,EAAMsB,KAAU,OAAO,QAAQZ,CAAM,EAC/CiH,EAAI3H,EAAMsB,CAAK,EAEjBqG,EAAI,UAAW,CAAC,CAAC,EACjB,IAAK,GAAM,CAAC3H,EAAMsB,KAAU,OAAO,QAAQkG,CAAY,EACrDG,EAAI3H,EAAMsB,CAAK,CAEnB,CCzEAmG,EAAc9H,CAAM"}
|
|
1
|
+
{"version":3,"file":"compat.min.js","names":["compat","core","__defProp","__exportAll","target","name","all","no_symbols","untyped","handle","nonEmptyRange","highLow","high","low","compat_exports","compat","fromLegacyPlugin","LEGACY_EVENTS","states","ANIMATION_EMITTER","PRESET_STATE","REPLACES_OUTPUT","presetOf","CLASSES","LineChart","BarChart","PieChart","mutableCopy","value","proto","key","entry","isLegacyAxisClass","type","chartRectOf","layout","area","lineAxes","normalized","normalizeData","data","options","series","axisUnits","chartRect","StepAxis","AutoScaleAxis","isNumeric","serialSums","serialMap","values","sum","safeHasProperty","barAxes","horizontal","valueDimension","labelDimension","found","getHighLow","valueOptions","labelOptions","valueAxis","labelAxis","AXES","emitDrawEvents","state","axisOf","dimension","axisX","axisY","wrap","Svg","element","draw","payload","parts","elementOf","node","grids","findAll","scene","allLabels","labels","n","sliceLabels","order","onAxis","indexes","a","b","index","grid","label","background","rawSeries","seriesIndex","common","children","slice","ctx","labelCtx","barNode","point","shapes","shape","svgElement","enable","existing","config","change","svg","output","instance","event","optionsProviderOf","getOptions","legacyChart","preset","chart","listener","override","legacyPlugin","plugin","chartObject","getDataArray","reverse","LEGACY_NAMES","installGlobal","root","add"],"sources":["../src/chart/types.ts","../src/core/data/range.ts","../src/compat/index.ts","../src/compat/global.ts","../src/compat/entry.ts"],"sourcesContent":["import type { PipelineOptions } from '../pipeline/phases';\nimport type {\n AllPhasesListener,\n PhaseListener,\n PhaseListeners,\n PhaseName\n} from '../pipeline/types';\nimport type { Keyframes, Renderer } from '../render/types';\nimport type { SceneNode } from '../scene/node';\nimport type { ResponsiveSet } from '../responsive/responsive';\n\n/**\n * The custom events a chart can emit, by name, with their payloads. The\n * core emits only `responsive`. A plugin that emits events of its own\n * declares them here (TypeScript merges your declaration into Chartist's),\n * so `on()`, `off()` and `emit()` check the names and payloads:\n *\n * ```ts\n * declare module 'chartist' {\n * interface ChartEvents {\n * 'legend:click': { readonly seriesIndex: number };\n * }\n * }\n * ```\n *\n * `chartist/compat` declares the 1.x events (`draw`, `created`, …).\n */\nexport interface ChartEvents {\n /**\n * Responsive entries changed which overrides apply: the config before\n * and after (`chart()`), or the options before and after (presets).\n */\n responsive:\n | {\n readonly previousConfig: ChartConfig;\n readonly currentConfig: ChartConfig;\n }\n | { readonly previousOptions: unknown; readonly currentOptions: unknown };\n}\n\n/**\n * The name of a custom event: a key of {@link ChartEvents}. Plugins list\n * the names they emit in `provides`.\n */\nexport type CustomEventName = keyof ChartEvents & string;\n\n/**\n * A plugin: a name and an `install` function that registers listeners on\n * the chart. Plugins go into `plugins`, in the config of {@link chart} or\n * the options of the presets. They install in order, so with two\n * listeners on the same event, the earlier plugin's runs first.\n *\n * For options, write a function that takes them and returns the plugin, or\n * read them from the second argument of `install` and pass the plugin\n * with {@link withOptions}.\n *\n * @example\n * ```ts\n * import { barChart, type ChartPlugin } from 'chartist';\n *\n * // Bars at or above the limit get the class ct-over.\n * const threshold = (limit: number): ChartPlugin => ({\n * name: 'threshold',\n * install(chart) {\n * chart.on('compose', current => {\n * if (current.role !== 'bar') {\n * return;\n * }\n * const { value } = current.ctx;\n * const y =\n * typeof value === 'number'\n * ? value\n * : value && 'y' in value\n * ? value.y\n * : undefined;\n * return y !== undefined && y >= limit\n * ? current.addClass('ct-over')\n * : undefined;\n * });\n * }\n * });\n *\n * barChart('#chart', { series: [[5, 4, 3, 7]] }, { plugins: [threshold(5)] });\n * ```\n */\nexport interface ChartPlugin<TOptions = unknown> {\n /** Names the plugin. Prefix your custom events with it to keep them apart. */\n readonly name: string;\n /**\n * The custom events this plugin emits with `chart.emit()`, each declared\n * in {@link ChartEvents}. They're known before any plugin installs, so\n * another plugin may listen to them.\n */\n readonly provides?: readonly CustomEventName[];\n /**\n * Sets the plugin up: runs once, before the first render, with the\n * chart's handle. Listeners registered here stay for every later render,\n * after updates and resizes too, and `off(name)` without a listener\n * leaves them alone: remove one with its reference.\n *\n * Return a function to undo what `install` set up outside the chart,\n * such as a listener on the document: `destroy()` calls it once, after\n * the chart's output is removed. `detach()` doesn't.\n * @param chart The chart's handle, to listen to events and emit them.\n * @param options The options of a `[plugin, options]` entry, if any.\n * @returns A cleanup function for `destroy()`, or anything else, which is\n * ignored (so `install: chart => chart.on(…)` stays valid).\n */\n install(chart: ChartHandle, options?: TOptions): unknown;\n /**\n * Gives the keyframes of a node's update animation, for nodes that don't\n * move well number by number, such as a path the plugin draws. A\n * renderer that animates updates (`smilAnimations()` from\n * `chartist/live`) asks it once per update, never per frame, with the\n * progress points of the chart's easing: 0 is the previous node, 1 the\n * new one, and points beyond them come from an easing that overshoots.\n * Plugins are asked in their order, before the layer that drew the node;\n * the first one that returns keyframes wins.\n *\n * @example\n * ```ts\n * import type { ChartPlugin } from 'chartist';\n *\n * // Turns the gauge needle the plugin draws (its angle in `ct:angle`),\n * // instead of morphing its path.\n * const needle: ChartPlugin = {\n * name: 'needle',\n * install() {},\n * keyframes(previous, next, progress) {\n * if (!next.classes.includes('needle')) {\n * return undefined;\n * }\n * const from = Number(previous.attrs['ct:angle']);\n * const to = Number(next.attrs['ct:angle']);\n * return progress.map(p => ({\n * transform: `rotate(${from + (to - from) * p} 100 100)`\n * }));\n * }\n * };\n * ```\n * @param previous The node in the previous scene\n * @param next The node in the new scene\n * @param progress The progress points to give attributes for\n * @returns One set of attributes per progress point, or nothing.\n */\n keyframes?(\n previous: SceneNode,\n next: SceneNode,\n progress: readonly number[]\n ): Keyframes | undefined;\n}\n\n/**\n * A plugin paired with its options, as {@link withOptions} creates it.\n * `install` receives the options as its second argument.\n */\nexport type PluginWithOptions<TOptions = unknown> = readonly [\n ChartPlugin<TOptions>,\n TOptions\n];\n\n/**\n * An entry of a chart's `plugins`: a plugin, or a plugin with its options.\n * Prefer {@link withOptions} (it checks the options) or a function that\n * returns a plugin over a bare `[plugin, options]` pair. A 1.x plugin (a\n * plain function) throws; convert it with `fromLegacyPlugin()` from\n * `chartist/compat`.\n */\nexport type PluginEntry =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ChartPlugin<any> | PluginWithOptions<any>;\n\n/**\n * The config of {@link chart}: the data, the layers that draw it and the\n * axes they draw on, plus size, padding, plugins and listeners.\n *\n * Without `axes`, layers draw into the whole chart area; the pie layer\n * needs `coordinates: 'polar'`. {@link toScene} takes the same config.\n */\nexport interface ChartConfig extends PipelineOptions {\n /**\n * Plugins to install before the first render, in order: plugins, or\n * plugins with their options from {@link withOptions}.\n */\n readonly plugins?: readonly PluginEntry[];\n /**\n * Phase listeners by phase name (or `'*'` for all phases). They're\n * registered before the first render, so they see it too.\n */\n readonly on?: PhaseListeners;\n /** Turns the scene into output; the DOM renderer by default. */\n readonly renderer?: Renderer;\n /**\n * Overrides that apply while their condition matches, created with\n * `responsive([...])`: entries of a media query string or a\n * `container()` condition, and a partial config. The chart renders again\n * when the matching entries change.\n */\n readonly responsive?: ResponsiveSet<ChartOverrides>;\n}\n\n/**\n * The part of a {@link ChartConfig} that responsive entries can override:\n * everything but `responsive`, `plugins`, `on` and `renderer`. The\n * matching entries merge over the config in order, shallowly.\n */\nexport type ChartOverrides = Partial<\n Omit<ChartConfig, 'responsive' | 'plugins' | 'on' | 'renderer'>\n>;\n\n/**\n * The handle {@link chart} returns: update or remove the chart, and listen\n * to its events. Plugins get the same handle in `install`. The methods\n * other than `destroy` and `emit` return the handle, so calls chain.\n */\nexport interface ChartHandle {\n /** The element the chart renders into (undefined in `toScene`). */\n readonly container?: Element;\n /**\n * Shallow-merges the changes into the config and renders again. Plugins\n * and listeners stay; `plugins` and `on` can't change.\n */\n update(config: Partial<Omit<ChartConfig, 'plugins' | 'on'>>): this;\n /**\n * Stops reacting to container size changes (and media queries in\n * presets). The output and the listeners stay.\n */\n detach(): this;\n /** Detaches, removes the output and clears all listeners. */\n destroy(): void;\n /**\n * Emits a custom event (declared in {@link ChartEvents}), e.g. from a\n * plugin. Phase names are reserved: emitting one throws.\n */\n emit<K extends CustomEventName>(name: K, payload: ChartEvents[K]): void;\n /**\n * Listens to a phase event, which fires on every render. Listeners of\n * `resolve` to `scene` may return a new payload to change what's drawn;\n * `compose` listeners may return `null` to drop a node.\n */\n on<K extends PhaseName>(name: K, listener: PhaseListener<K>): this;\n /** Listens to every phase event, with the phase name and its payload. */\n on(name: '*', listener: AllPhasesListener): this;\n /** Listens to a custom event, declared in {@link ChartEvents}. */\n on<K extends CustomEventName>(\n name: K,\n listener: (payload: ChartEvents[K]) => void\n ): this;\n /**\n * Removes a phase listener, whoever added it. Without a listener,\n * removes the listeners of the phase added through `on` and the\n * config's `on`; plugins keep theirs.\n */\n off<K extends PhaseName>(name: K, listener?: PhaseListener<K>): this;\n /**\n * Removes a listener of all phases, or without a listener, those added\n * through `on`.\n */\n off(name: '*', listener?: AllPhasesListener): this;\n /**\n * Removes a custom event listener, or without a listener, the event's\n * listeners added through `on`.\n */\n off<K extends CustomEventName>(\n name: K,\n listener?: (payload: ChartEvents[K]) => void\n ): this;\n}\n\n/**\n * Pairs a plugin with its options for a chart's `plugins`, and checks the\n * options against the plugin's options type. `install` receives them as\n * its second argument.\n *\n * @example\n * ```ts\n * import { lineChart, withOptions, type ChartPlugin } from 'chartist';\n *\n * const lastPoint: ChartPlugin<{ className: string }> = {\n * name: 'last-point',\n * install(chart, options) {\n * chart.on('compose', current => {\n * if (current.role !== 'series') {\n * return;\n * }\n * const last = current.children.at(-1);\n * return last && options\n * ? current.replace(last, last.addClass(options.className))\n * : undefined;\n * });\n * }\n * };\n *\n * lineChart(\n * '#chart',\n * { series: [[1, 3, 2, 5]] },\n * { plugins: [withOptions(lastPoint, { className: 'ct-last' })] }\n * );\n * ```\n */\nexport function withOptions<TOptions>(\n plugin: ChartPlugin<TOptions>,\n options: TOptions\n): PluginWithOptions<TOptions> {\n return [plugin, options];\n}\n\n/**\n * The handle without event typing, for code that routes event names it\n * doesn't know (the 1.x chart classes, compat). Internal.\n */\nexport interface UntypedEvents {\n on(name: string, listener: (payload: unknown) => void): unknown;\n off(name: string, listener?: (payload: unknown) => void): unknown;\n emit(name: string, payload?: unknown): void;\n}\n\n/** The same handle, seen without event typing. Internal. */\nexport const untyped = (handle: ChartHandle): UntypedEvents =>\n handle as unknown as UntypedEvents;\n","/**\n * Repairs a value range that's empty because high is at or below low, from\n * flat data or a misconfigured `high`/`low`: sets the bound on the other\n * side of zero to 0, or gives `0` to `1` when there are no values. Chart\n * code that overrides a bound after `getHighLow` calls it again.\n *\n * @param highLow The range to check.\n * @returns The range, or the repaired one.\n */\nexport function nonEmptyRange(highLow: {\n readonly high: number;\n readonly low: number;\n}): { high: number; low: number } {\n const { high, low } = highLow;\n if (high > low) {\n return { high, low };\n }\n if (low === 0) {\n // Both are 0.\n return { high: 1, low };\n }\n if (low < 0) {\n // The same negative value for both.\n return { high: 0, low };\n }\n if (high > 0) {\n // The same positive value for both.\n return { high, low: 0 };\n }\n // No values: high and low are still -Number.MAX_VALUE and Number.MAX_VALUE.\n return { high: 1, low: 0 };\n}\n","/**\n * The compat plugin: 1.x events, `Svg` wrappers and 1.x plugins on v2\n * charts. Opt-in: `plugins: [compat]`, or convert a 1.x plugin with\n * `fromLegacyPlugin()`.\n *\n * Imports only from the package root, so the built `chartist/compat` entry\n * shares the core with `chartist` instead of bundling a copy.\n */\nimport {\n AutoScaleAxis,\n BarChart,\n LineChart,\n PieChart,\n Svg,\n StepAxis,\n axisUnits,\n findAll,\n getHighLow,\n isNumeric,\n normalizeData,\n safeHasProperty,\n serialMap,\n type ChartHandle,\n type ChartPlugin,\n type ChartRect,\n type Data,\n type Layout,\n type PresetState,\n type NormalizedSeries,\n type AxisLabelContext,\n type PieLabelContext,\n type RoleNode,\n type SceneNode\n} from '../index';\nimport { untyped } from '../chart/types';\nimport { nonEmptyRange } from '../core/data/range';\nimport type {\n AnimationEvent,\n AreaDrawEvent,\n AxesDrawEvent,\n BarChartCreatedEvent,\n BarDrawEvent,\n DataEvent,\n LineChartCreatedEvent,\n LineDrawEvent,\n OptionsChangedEvent,\n PieChartCreatedEvent,\n PointDrawEvent,\n SliceDrawEvent,\n SliceLabelDrawEvent\n} from '../index';\n\n// With chartist/compat, the 1.x events are typed on every chart handle.\ndeclare module '../chart/types' {\n interface ChartEvents {\n /**\n * 1.x: the chart's data, before the first render (`type: 'initial'`)\n * and after an update with new data (`type: 'update'`). Listeners can\n * change it in place. Needs the {@link compat} plugin.\n */\n data: DataEvent;\n /**\n * 1.x: the responsive options changed, with the options before and\n * after. Needs the {@link compat} plugin.\n */\n optionsChanged: OptionsChangedEvent;\n /**\n * 1.x: an element was drawn: a grid line, label, point, line, area,\n * bar or slice, with its live `element`. Check `type` to narrow it.\n * Needs the {@link compat} plugin.\n */\n draw:\n | PointDrawEvent\n | LineDrawEvent\n | AreaDrawEvent\n | BarDrawEvent\n | SliceDrawEvent\n | SliceLabelDrawEvent\n | AxesDrawEvent;\n /**\n * 1.x: the chart is drawn and in the DOM, after its `draw` events,\n * with the `svg`, the chart area and the axes. Needs the {@link compat}\n * plugin.\n */\n created:\n | LineChartCreatedEvent\n | BarChartCreatedEvent\n | PieChartCreatedEvent;\n /**\n * 1.x: an SMIL animation began, started with `animate()` on an element\n * of the chart, such as the `element` of a `draw` event. Needs the\n * {@link compat} plugin.\n */\n animationBegin: AnimationEvent;\n /**\n * 1.x: an SMIL animation ended, started with `animate()` on an element\n * of the chart. Needs the {@link compat} plugin.\n */\n animationEnd: AnimationEvent;\n }\n}\n\n/** The 1.x events the compat plugin emits. */\nconst LEGACY_EVENTS = [\n 'data',\n 'optionsChanged',\n 'draw',\n 'created',\n 'animationBegin',\n 'animationEnd'\n] as const;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype LegacyPlugin = (chart: any, options?: any) => void;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyOptions = any;\n\ninterface CompatState {\n preset?: PresetState<Data, AnyOptions>;\n /** The data object of the last `data` event, and its mutable copy. */\n source?: unknown;\n copy?: Data;\n layout?: Layout;\n svg?: Svg;\n /** 1.x chart instances whose `svg` field follows the chart's. */\n instances: { svg?: Svg }[];\n}\n\nconst states = new WeakMap<ChartHandle, CompatState>();\n\n/**\n * Where `Svg#animate()` looks for the emitter of an element's animations\n * when it gets none (on the element or an ancestor). The core reads the\n * same global symbol.\n */\nconst ANIMATION_EMITTER = Symbol.for('chartist.animationEmitter');\n\n/**\n * Where a preset's chart handle holds its preset state from the moment\n * plugins install. The core sets the same global symbol.\n */\nconst PRESET_STATE = Symbol.for('chartist.presetState');\n\n/**\n * Set on the chart handle, so the chart never hands its renderer the\n * previous render: 1.x draw listeners and plugins expect new elements on\n * every render. The core reads the same global symbol.\n */\nconst REPLACES_OUTPUT = Symbol.for('chartist.replacesOutput');\n\nconst presetOf = (handle: ChartHandle) =>\n (handle as { [PRESET_STATE]?: PresetState<Data, AnyOptions> })[PRESET_STATE];\n\n/** The 1.x class of each preset, for 0.x and 1.x type checks in plugins. */\nconst CLASSES: Record<string, { prototype: object }> = {\n line: LineChart,\n bar: BarChart,\n pie: PieChart\n};\n\n/** Copies plain arrays and objects; other values are kept by reference. */\nfunction mutableCopy<T>(value: T): T {\n if (Array.isArray(value)) {\n return value.map(mutableCopy) as T;\n }\n if (value && typeof value === 'object') {\n const proto = Object.getPrototypeOf(value);\n if (proto === Object.prototype || proto === null) {\n return Object.fromEntries(\n Object.entries(value).map(([key, entry]) => [key, mutableCopy(entry)])\n ) as T;\n }\n }\n return value;\n}\n\nconst isLegacyAxisClass = (\n type: unknown\n): type is new (...args: unknown[]) => unknown =>\n typeof type === 'function' &&\n typeof (type as { prototype?: { projectValue?: unknown } }).prototype\n ?.projectValue === 'function';\n\nfunction chartRectOf(layout: Layout): ChartRect {\n const { area, padding } = layout;\n return {\n x1: area.x1,\n x2: area.x2,\n y1: area.y1,\n y2: area.y2,\n padding,\n width() {\n return this.x2 - this.x1;\n },\n height() {\n return this.y1 - this.y2;\n }\n };\n}\n\n/** The 1.x axes, constructed as 1.x `LineChart.createChart` does. */\nfunction lineAxes(options: AnyOptions, data: Data, chartRect: ChartRect) {\n const normalized = normalizeData(\n data as Data<NormalizedSeries[]>,\n options.reverseData,\n true\n );\n const series = normalized.series as NormalizedSeries[];\n const axisX = isLegacyAxisClass(options.axisX.type)\n ? new options.axisX.type(axisUnits.x, series, chartRect, options.axisX)\n : new StepAxis(axisUnits.x, series, chartRect, {\n ...options.axisX,\n ticks: normalized.labels,\n stretch: options.fullWidth\n });\n const axisY = isLegacyAxisClass(options.axisY.type)\n ? new options.axisY.type(axisUnits.y, series, chartRect, options.axisY)\n : new AutoScaleAxis(axisUnits.y, series, chartRect, {\n ...options.axisY,\n high: isNumeric(options.high) ? options.high : options.axisY.high,\n low: isNumeric(options.low) ? options.low : options.axisY.low\n });\n return { axisX, axisY };\n}\n\n/** Sums per index across series, as 1.x `BarChart` stacks them. */\nfunction serialSums(series: NormalizedSeries[]) {\n return serialMap(series, (...values) =>\n values.reduce<{ x: number; y: number }>(\n (sum, value) => ({\n x: sum.x + (safeHasProperty(value, 'x') ? (value.x as number) : 0),\n y: sum.y + (safeHasProperty(value, 'y') ? (value.y as number) : 0)\n }),\n { x: 0, y: 0 }\n )\n );\n}\n\n/** The 1.x axes, constructed as 1.x `BarChart.createChart` does. */\nfunction barAxes(options: AnyOptions, data: Data, chartRect: ChartRect) {\n const horizontal = Boolean(options.horizontalBars);\n const valueDimension = horizontal ? 'x' : 'y';\n const labelDimension = horizontal ? 'y' : 'x';\n const normalized = normalizeData(\n data as Data<NormalizedSeries[]>,\n options.reverseData,\n valueDimension,\n true\n );\n const series = normalized.series as NormalizedSeries[];\n const found =\n options.stackBars && options.stackMode !== true && series.length\n ? getHighLow([serialSums(series)], options, valueDimension)\n : getHighLow(series, options, valueDimension);\n // The chart-level bounds win, but can empty the range again (#1057).\n const highLow = nonEmptyRange({\n high: typeof options.high === 'number' ? options.high : found.high,\n low: typeof options.low === 'number' ? options.low : found.low\n });\n const valueOptions = horizontal ? options.axisX : options.axisY;\n const labelOptions = horizontal ? options.axisY : options.axisX;\n const ValueAxis = isLegacyAxisClass(valueOptions.type)\n ? valueOptions.type\n : AutoScaleAxis;\n const valueAxis = new ValueAxis(\n axisUnits[valueDimension],\n series,\n chartRect,\n {\n ...valueOptions,\n highLow,\n referenceValue: 0\n }\n );\n const labelAxis = isLegacyAxisClass(labelOptions.type)\n ? new labelOptions.type(\n axisUnits[labelDimension],\n series,\n chartRect,\n labelOptions\n )\n : new StepAxis(axisUnits[labelDimension], series, chartRect, {\n ticks:\n options.distributeSeries && options.stackBars\n ? normalized.labels.slice(0, 1)\n : normalized.labels\n });\n return horizontal\n ? { axisX: valueAxis, axisY: labelAxis }\n : { axisX: labelAxis, axisY: valueAxis };\n}\n\nconst AXES: Record<\n string,\n (\n options: AnyOptions,\n data: Data,\n chartRect: ChartRect\n ) => { axisX: unknown; axisY: unknown }\n> = {\n line: lineAxes,\n bar: barAxes,\n // Pie charts have no axes.\n pie: () => ({ axisX: undefined, axisY: undefined })\n};\n\n/** 1.x `draw` payloads in 1.x order, then `created`. */\nfunction emitDrawEvents(\n handle: ChartHandle,\n state: CompatState,\n scene: SceneNode,\n svgElement: Element,\n elementOf: (node: SceneNode) => Element | undefined\n) {\n const options = state.preset?.options as AnyOptions;\n const data = (state.copy ?? state.preset?.data) as Data;\n const chartRect = chartRectOf(state.layout!);\n const { axisX, axisY } = AXES[state.preset!.kind](options, data, chartRect);\n const axisOf = (dimension?: string) => (dimension === 'x' ? axisX : axisY);\n const wrap = (element: Element) => new Svg(element);\n const draw = (payload: Record<string, unknown>) =>\n untyped(handle).emit('draw', payload);\n const parts = (node: SceneNode) => {\n const element = elementOf(node)!;\n return { element: wrap(element), group: wrap(element.parentElement!) };\n };\n\n // Axes: per tick its grid line, then its label, in the order the axes\n // appear in the chart (X first for lines, the label axis first for bars).\n const grids = findAll(scene, { role: 'grid' });\n // Only axis labels; pie labels belong to their slice.\n const allLabels = findAll(scene, { role: 'label' });\n const labels = allLabels.filter(\n (n): n is RoleNode<'label'> & { ctx: AxisLabelContext } =>\n n.ctx.kind === 'axis'\n );\n const sliceLabels = allLabels.filter(\n (n): n is RoleNode<'label'> & { ctx: PieLabelContext } =>\n n.ctx.kind === 'pie'\n );\n const order = [\n ...new Set([...grids, ...labels].map(n => n.ctx.axis.dimension))\n ];\n for (const dimension of order) {\n const onAxis = (node: { ctx: { axis: { dimension: string } } }) =>\n node.ctx.axis.dimension === dimension;\n const indexes = [\n ...new Set([...grids, ...labels].filter(onAxis).map(n => n.ctx.index))\n ].sort((a, b) => a - b);\n for (const index of indexes) {\n const grid = grids.find(n => onAxis(n) && n.ctx.index === index);\n if (grid) {\n const { x1, y1, x2, y2 } = grid.attrs;\n draw({\n type: 'grid',\n axis: axisOf(dimension),\n index,\n ...parts(grid),\n x1,\n y1,\n x2,\n y2\n });\n }\n const label = labels.find(n => onAxis(n) && n.ctx.index === index);\n if (label) {\n const { x, y, width, height } = label.attrs;\n draw({\n type: 'label',\n axis: axisOf(dimension),\n index,\n ...parts(label),\n text: label.ctx.text,\n x,\n y,\n width,\n height\n });\n }\n }\n }\n for (const background of findAll(scene, { role: 'gridBackground' })) {\n draw({ type: 'gridBackground', ...parts(background) });\n }\n\n // Series: points, then the line, then the areas in creation order.\n const rawSeries = (data.series ?? []) as unknown[];\n for (const series of findAll(scene, { role: 'series' })) {\n const seriesIndex = series.ctx.seriesIndex;\n const original =\n rawSeries[\n options.reverseData ? rawSeries.length - 1 - seriesIndex : seriesIndex\n ];\n const common = { series: original, seriesIndex, axisX, axisY };\n const children = series.children;\n const slice = children.find(n => n.role === 'slice');\n if (slice) {\n const ctx = slice.ctx;\n draw({\n type: 'slice',\n value: ctx.value,\n totalDataSum: ctx.totalDataSum,\n index: ctx.index,\n meta: ctx.meta,\n series: ctx.series,\n ...parts(slice),\n path: ctx.path.clone(),\n center: ctx.center,\n radius: ctx.radius,\n startAngle: ctx.startAngle,\n endAngle: ctx.endAngle,\n chartRect\n });\n const label = sliceLabels.find(n => n.ctx.index === ctx.index);\n if (label) {\n const labelCtx = label.ctx;\n draw({\n type: 'label',\n index: labelCtx.index,\n ...parts(label),\n text: labelCtx.text,\n chartRect,\n series: labelCtx.series,\n meta: labelCtx.meta,\n x: labelCtx.x,\n y: labelCtx.y\n });\n }\n continue;\n }\n for (const barNode of children.filter(n => n.role === 'bar')) {\n const ctx = barNode.ctx!;\n draw({\n type: 'bar',\n value: ctx.value,\n index: ctx.valueIndex,\n meta: ctx.meta,\n series: ctx.series,\n seriesIndex,\n axisX,\n axisY,\n chartRect,\n ...parts(barNode),\n x1: ctx.x1,\n y1: ctx.y1,\n x2: ctx.x2,\n y2: ctx.y2\n });\n }\n for (const point of children.filter(n => n.role === 'point')) {\n const ctx = point.ctx!;\n draw({\n type: 'point',\n value: ctx.value,\n index: ctx.valueIndex,\n meta: ctx.meta,\n ...common,\n ...parts(point),\n x: ctx.x,\n y: ctx.y,\n chartRect\n });\n }\n const shapes = [\n ...children.filter(n => n.role === 'line'),\n // Areas are inserted first, so the DOM order is the reverse.\n ...children.filter(n => n.role === 'area').reverse()\n ];\n for (const shape of shapes) {\n const ctx = shape.ctx!;\n draw({\n type: shape.role,\n values: ctx.values,\n path: ctx.path.clone(),\n chartRect,\n index: seriesIndex,\n ...common,\n meta: ctx.meta,\n ...parts(shape)\n });\n }\n }\n\n // 0.x plugins also read `bounds`, the value axis's scale, which 0.x\n // passed next to the axes (auto scale axes only, as in 0.x).\n const valueAxis = options.horizontalBars ? axisX : axisY;\n untyped(handle).emit(\n 'created',\n state.preset!.kind === 'pie'\n ? { chartRect, svg: wrap(svgElement), options }\n : {\n chartRect,\n axisX,\n axisY,\n bounds: (valueAxis as { bounds?: unknown }).bounds,\n svg: wrap(svgElement),\n options\n }\n );\n}\n\n/** Turns the 1.x events on for a chart, once. */\nfunction enable(handle: ChartHandle): CompatState {\n const existing = states.get(handle);\n if (existing) {\n return existing;\n }\n const state: CompatState = { instances: [] };\n states.set(handle, state);\n (handle as { [REPLACES_OUTPUT]?: boolean })[REPLACES_OUTPUT] = true;\n\n handle.on('resolve', ({ config }) => {\n state.preset = config.preset as CompatState['preset'];\n if (config.data !== state.source) {\n // 1.x data handlers mutate the data; they get a copy, and the copy\n // is used from now on (as 1.x keeps its mutated data).\n state.copy = mutableCopy(config.data) as Data;\n untyped(handle).emit('data', {\n type: state.source === undefined ? 'initial' : 'update',\n data: state.copy\n });\n state.source = config.data;\n }\n return { config: { ...config, data: state.copy as typeof config.data } };\n });\n handle.on('layout', layout => {\n state.layout = layout;\n });\n handle.on('responsive', change =>\n 'previousOptions' in change\n ? untyped(handle).emit('optionsChanged', {\n previousOptions: change.previousOptions,\n currentOptions: change.currentOptions\n })\n : undefined\n );\n handle.on('mount', ({ scene, output, elementOf }) => {\n const svg = (output as { svg?: Element }).svg;\n if (!svg) {\n throw new Error('Chartist: the compat plugin requires the DOM renderer');\n }\n state.svg = new Svg(svg);\n // Set before the draw events, so listeners can query the chart.\n for (const instance of state.instances) {\n instance.svg = state.svg;\n }\n // Animations of the chart's elements emit animationBegin and\n // animationEnd on the chart, as 1.x did with the chart's emitter.\n (svg as { [ANIMATION_EMITTER]?: unknown })[ANIMATION_EMITTER] = {\n emit: (event: string, payload: unknown) =>\n untyped(handle).emit(event, payload)\n };\n if (state.preset) {\n emitDrawEvents(handle, state, scene, svg, elementOf);\n }\n });\n return state;\n}\n\n/** 1.x `optionsProvider`: the options in effect, after responsive options. */\nfunction optionsProviderOf(getOptions: () => unknown) {\n return {\n getCurrentOptions: getOptions,\n // The preset watches the media queries and stops on `detach()`.\n removeMediaQueryListeners: () => undefined\n };\n}\n\n/**\n * A 1.x-style chart object for 1.x plugins on the functional API. For a\n * preset it is an instance of the preset's 1.x class (without running its\n * constructor), so type checks such as `chart instanceof LineChart` hold;\n * for `chart()` compositions a plain object.\n */\nfunction legacyChart(handle: ChartHandle, state: CompatState) {\n const preset = presetOf(handle);\n const chart = {\n get container() {\n return handle.container;\n },\n get data() {\n return state.copy ?? preset?.data;\n },\n get options() {\n return preset?.options;\n },\n get svg() {\n return state.svg;\n },\n eventEmitter: {\n on: (event: string, listener: (payload: unknown) => void) =>\n untyped(handle).on(event, listener),\n off: (event: string, listener?: (payload: unknown) => void) =>\n untyped(handle).off(event, listener),\n emit: (event: string, payload: unknown) =>\n untyped(handle).emit(event, payload)\n },\n optionsProvider: optionsProviderOf(() => preset?.options),\n on(event: string, listener: (payload: unknown) => void) {\n untyped(handle).on(event, listener);\n return chart;\n },\n off(event: string, listener?: (payload: unknown) => void) {\n untyped(handle).off(event, listener);\n return chart;\n },\n update(data?: unknown, options?: unknown, override?: boolean) {\n if (preset) {\n preset.update(data as never, options as never, override);\n } else {\n handle.update(data ? { data: data as never } : {});\n }\n return chart;\n },\n detach() {\n if (preset) {\n preset.detach();\n } else {\n handle.detach();\n }\n return chart;\n }\n };\n // The fields above are own properties, so they shadow the class's.\n const type = preset && CLASSES[preset.kind];\n return type ? Object.setPrototypeOf(chart, type.prototype) : chart;\n}\n\n/**\n * Runs a 1.x plugin function as a v2 plugin, with the given chart object.\n * Used by the 1.x chart classes, which pass themselves.\n */\nfunction legacyPlugin(\n plugin: LegacyPlugin,\n options?: unknown,\n chart?: unknown\n): ChartPlugin {\n return {\n name: plugin.name || 'legacy-plugin',\n provides: LEGACY_EVENTS,\n install(handle) {\n const state = enable(handle);\n if (chart) {\n // A 1.x chart instance: keep its `svg` field current, as 1.x did.\n state.instances.push(chart as { svg?: Svg });\n // The 1.x classes run on a preset and have no options provider;\n // plugins call it for the options in effect.\n const instance = chart as { optionsProvider?: unknown };\n if (!instance.optionsProvider) {\n instance.optionsProvider = optionsProviderOf(\n () => presetOf(handle)?.options\n );\n }\n }\n const chartObject = chart ?? legacyChart(handle, state);\n // As 1.x: plugins without options are called with the chart only.\n if (options === undefined) {\n plugin(chartObject);\n } else {\n plugin(chartObject, options);\n }\n }\n };\n}\n\n/**\n * The compat plugin. Restores the 1.x events (`data`, `optionsChanged`,\n * `draw`, `created`, `animationBegin`, `animationEnd`) with 1.x payloads.\n * With it, the 1.x chart classes also run 1.x plugin functions.\n *\n * Add it to `plugins`, of a 1.x class, a preset or `chart()`. The `draw`\n * events come in the 1.x order, right after the chart is in the DOM, so\n * `element` is a live element; then `created`. Animations started with\n * `animate()` on the chart's elements emit `animationBegin` and\n * `animationEnd`. Importing\n * `chartist/compat` also types the 1.x events on every chart handle. It\n * needs the DOM renderer, and the `draw` and `created` events need a\n * chart made by a preset or a 1.x class.\n *\n * @example\n * ```ts\n * import { lineChart } from 'chartist';\n * import { compat } from 'chartist/compat';\n *\n * const chart = lineChart(\n * '#chart',\n * {\n * labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],\n * series: [[12, 9, 7, 8, 5]]\n * },\n * { plugins: [compat] }\n * );\n *\n * // Registered after the first render, so it runs from the next one on.\n * chart.on('draw', data => {\n * if (data.type === 'point' && data.index === 4) {\n * data.element.addClass('is-friday');\n * }\n * });\n * ```\n */\nexport const compat: ChartPlugin & { legacyPlugin: typeof legacyPlugin } = {\n name: 'compat',\n provides: LEGACY_EVENTS,\n install: handle => void enable(handle),\n legacyPlugin\n};\n\n/**\n * Converts a 1.x plugin function into a v2 plugin for `chart()` and the\n * preset functions. It turns the 1.x events on for the chart and calls the\n * plugin with a 1.x-style chart object (`container`, `data`, `options`,\n * `svg`, `eventEmitter`, `on`, `off`, `update`, `detach`). You don't need\n * {@link compat} in the list as well.\n *\n * @param plugin The 1.x plugin: a function that gets the chart (and its\n * options)\n * @param options The plugin's options; without them, the plugin is called\n * with the chart only, as in 1.x\n * @example\n * ```ts\n * import { lineChart, type Plugin } from 'chartist';\n * import { fromLegacyPlugin } from 'chartist/compat';\n *\n * // A 1.x plugin: a function that gets the chart and its options.\n * const caption: Plugin = (chart, options) => {\n * chart.on('created', () => {\n * chart.container.setAttribute('aria-label', options.text);\n * });\n * };\n *\n * lineChart(\n * '#chart',\n * { series: [[1, 3, 2, 4]] },\n * { plugins: [fromLegacyPlugin(caption, { text: 'Visitors per week' })] }\n * );\n * ```\n */\nexport function fromLegacyPlugin(\n plugin: LegacyPlugin,\n options?: unknown\n): ChartPlugin {\n return legacyPlugin(plugin, options);\n}\n\n// The types of the 1.x events and plugins this plugin turns on.\nexport type * from './types';\n","/**\n * The global `Chartist` that plugin scripts of the 0.x and 1.x era read.\n * They register on `Chartist.plugins`, check the chart type with\n * `instanceof Chartist.Line`, and call helpers such as `Chartist.extend`.\n * Importing `chartist/compat` (any build: module, CommonJS or the UMD\n * script) sets this up, so such a script works when it loads after it.\n *\n * The names are added to the global only, never exported: the module\n * builds keep the 1.x and v2 names.\n */\nimport * as core from '../index';\nimport {\n BarChart,\n LineChart,\n PieChart,\n normalizeData,\n type Data\n} from '../index';\n\n/**\n * 0.x: the values of each series as plain numbers (`undefined` for holes),\n * normalized as the 1.x charts do; reversed when `reverse` is true. Line\n * and bar data give an array per series, pie data one array.\n */\nexport function getDataArray(\n data: Data,\n reverse?: boolean\n): (number | undefined)[] | (number | undefined)[][] {\n return normalizeData(data as Data<never>, reverse).series as\n | (number | undefined)[]\n | (number | undefined)[][];\n}\n\n/** The 0.x names plugin scripts use, next to the library's own. */\nconst LEGACY_NAMES = {\n // 0.x names of the chart classes, for `chart instanceof Chartist.Line`.\n Line: LineChart,\n Bar: BarChart,\n Pie: PieChart,\n getDataArray\n};\n\ntype Root = { Chartist?: Record<string, unknown>; document?: unknown };\n\n/**\n * Adds the core, compat and the 0.x names to the global `Chartist`, only\n * what it lacks: a global set by the UMD build or by plugin scripts keeps\n * its values, and `plugins` keeps what scripts registered. If the global\n * belongs to another copy of Chartist (say the UMD build next to these\n * modules), it is left alone with a warning: mixing two copies breaks the\n * plugins' type checks. Outside a browser it does nothing.\n */\nexport function installGlobal(\n compat: Record<string, unknown>,\n root: Root = globalThis as Root\n): void {\n if (root.document === undefined) {\n return;\n }\n const existing = root.Chartist;\n if (existing && 'LineChart' in existing && existing.LineChart !== LineChart) {\n // A hint for developers, as the warnings for 1.x events without compat.\n // eslint-disable-next-line no-console\n console.warn(\n 'Chartist: the global `Chartist` belongs to another copy of Chartist, so chartist/compat leaves it alone. Load Chartist once: as modules, or as the UMD build with compat.umd.js.'\n );\n return;\n }\n const target = existing ?? (root.Chartist = {});\n const add = (name: string, value: unknown) => {\n if (!(name in target)) {\n target[name] = value;\n }\n };\n for (const [name, value] of Object.entries(core)) {\n add(name, value);\n }\n for (const [name, value] of Object.entries(compat)) {\n add(name, value);\n }\n add('plugins', {});\n for (const [name, value] of Object.entries(LEGACY_NAMES)) {\n add(name, value);\n }\n}\n","/**\n * The published entry of `chartist/compat`, in every build. Next to the\n * compat API, importing it sets up the global `Chartist` for plugin\n * scripts of the 0.x and 1.x era (see ./global.ts). That's why\n * package.json lists the compat files under `sideEffects`.\n */\nimport * as compat from './index';\nimport { installGlobal } from './global';\n\nexport * from './index';\n\ninstallGlobal(compat);\n"],"mappings":"wZA8TA,MAAaQ,EAAW,GACtBC,ECtTF,SAAgBC,EAAc,EAGI,CAChC,GAAM,CAAE,OAAM,OAAQC,EAiBtB,OAhBIC,EAAOC,EACF,CAAE,OAAM,KAAI,EAEjBA,IAAQ,EAEH,CAAE,KAAM,EAAG,KAAI,EAEpBA,EAAM,EAED,CAAE,KAAM,E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EAmG,EAAc/H,CAAM"}
|
package/dist/compat.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("./index.umd.js")):typeof define==`function`&&define.amd?define([`exports`,`./index.umd.js`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.Chartist=e.Chartist||{},e.Chartist))})(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var n=Object.create,r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,c=(e,t)=>{let n={};for(var i in e)r(n,i,{get:e[i],enumerable:!0});return t||r(n,Symbol.toStringTag,{value:`Module`}),n},l=(e,t,n,o)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=a(t),l=0,u=c.length,d;l<u;l++)d=c[l],!s.call(e,d)&&d!==n&&r(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(o=i(t,d))||o.enumerable});return e};t=((e,t,i)=>(i=e==null?{}:n(o(e)),l(t||!e||!e.__esModule||!s.call(e,`default`)?r(i,`default`,{value:e,enumerable:!0}):i,e)))(t,1);let u=e=>e;function d(e){let{high:t,low:n}=e;return t>n?{high:t,low:n}:n===0?{high:1,low:n}:n<0?{high:0,low:n}:t>0?{high:t,low:0}:{high:1,low:0}}var f=/* @__PURE__ */ c({compat:()=>
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("./index.umd.js")):typeof define==`function`&&define.amd?define([`exports`,`./index.umd.js`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.Chartist=e.Chartist||{},e.Chartist))})(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var n=Object.create,r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,c=(e,t)=>{let n={};for(var i in e)r(n,i,{get:e[i],enumerable:!0});return t||r(n,Symbol.toStringTag,{value:`Module`}),n},l=(e,t,n,o)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=a(t),l=0,u=c.length,d;l<u;l++)d=c[l],!s.call(e,d)&&d!==n&&r(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(o=i(t,d))||o.enumerable});return e};t=((e,t,i)=>(i=e==null?{}:n(o(e)),l(t||!e||!e.__esModule||!s.call(e,`default`)?r(i,`default`,{value:e,enumerable:!0}):i,e)))(t,1);let u=e=>e;function d(e){let{high:t,low:n}=e;return t>n?{high:t,low:n}:n===0?{high:1,low:n}:n<0?{high:0,low:n}:t>0?{high:t,low:0}:{high:1,low:0}}var f=/* @__PURE__ */ c({compat:()=>M,fromLegacyPlugin:()=>N});let p=[`data`,`optionsChanged`,`draw`,`created`,`animationBegin`,`animationEnd`],m=/* @__PURE__ */ new WeakMap,h=Symbol.for(`chartist.animationEmitter`),g=Symbol.for(`chartist.presetState`),_=Symbol.for(`chartist.replacesOutput`),v=e=>e[g],y={line:t.LineChart,bar:t.BarChart,pie:t.PieChart};function b(e){if(Array.isArray(e))return e.map(b);if(e&&typeof e==`object`){let t=Object.getPrototypeOf(e);if(t===Object.prototype||t===null)return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,b(t)]))}return e}let x=e=>typeof e==`function`&&typeof e.prototype?.projectValue==`function`;function S(e){let{area:t,padding:n}=e;return{x1:t.x1,x2:t.x2,y1:t.y1,y2:t.y2,padding:n,width(){return this.x2-this.x1},height(){return this.y1-this.y2}}}function C(e,n,r){let i=(0,t.normalizeData)(n,e.reverseData,!0),a=i.series;return{axisX:x(e.axisX.type)?new e.axisX.type(t.axisUnits.x,a,r,e.axisX):new t.StepAxis(t.axisUnits.x,a,r,{...e.axisX,ticks:i.labels,stretch:e.fullWidth}),axisY:x(e.axisY.type)?new e.axisY.type(t.axisUnits.y,a,r,e.axisY):new t.AutoScaleAxis(t.axisUnits.y,a,r,{...e.axisY,high:(0,t.isNumeric)(e.high)?e.high:e.axisY.high,low:(0,t.isNumeric)(e.low)?e.low:e.axisY.low})}}function w(e){return(0,t.serialMap)(e,(...e)=>e.reduce((e,n)=>({x:e.x+((0,t.safeHasProperty)(n,`x`)?n.x:0),y:e.y+((0,t.safeHasProperty)(n,`y`)?n.y:0)}),{x:0,y:0}))}function T(e,n,r){let i=!!e.horizontalBars,a=i?`x`:`y`,o=i?`y`:`x`,s=(0,t.normalizeData)(n,e.reverseData,a,!0),c=s.series,l=e.stackBars&&e.stackMode!==!0&&c.length?(0,t.getHighLow)([w(c)],e,a):(0,t.getHighLow)(c,e,a),u=d({high:typeof e.high==`number`?e.high:l.high,low:typeof e.low==`number`?e.low:l.low}),f=i?e.axisX:e.axisY,p=i?e.axisY:e.axisX,m=new(x(f.type)?f.type:t.AutoScaleAxis)(t.axisUnits[a],c,r,{...f,highLow:u,referenceValue:0}),h=x(p.type)?new p.type(t.axisUnits[o],c,r,p):new t.StepAxis(t.axisUnits[o],c,r,{ticks:e.distributeSeries&&e.stackBars?s.labels.slice(0,1):s.labels});return i?{axisX:m,axisY:h}:{axisX:h,axisY:m}}let E={line:C,bar:T,pie:()=>({axisX:void 0,axisY:void 0})};function D(e,n,r,i,a){let o=n.preset?.options,s=n.copy??n.preset?.data,c=S(n.layout),{axisX:l,axisY:d}=E[n.preset.kind](o,s,c),f=e=>e===`x`?l:d,p=e=>new t.Svg(e),m=t=>u(e).emit(`draw`,t),h=e=>{let t=a(e);return{element:p(t),group:p(t.parentElement)}},g=(0,t.findAll)(r,{role:`grid`}),_=(0,t.findAll)(r,{role:`label`}),v=_.filter(e=>e.ctx.kind===`axis`),y=_.filter(e=>e.ctx.kind===`pie`),b=[...new Set([...g,...v].map(e=>e.ctx.axis.dimension))];for(let e of b){let t=t=>t.ctx.axis.dimension===e,n=[...new Set([...g,...v].filter(t).map(e=>e.ctx.index))].sort((e,t)=>e-t);for(let r of n){let n=g.find(e=>t(e)&&e.ctx.index===r);if(n){let{x1:t,y1:i,x2:a,y2:o}=n.attrs;m({type:`grid`,axis:f(e),index:r,...h(n),x1:t,y1:i,x2:a,y2:o})}let i=v.find(e=>t(e)&&e.ctx.index===r);if(i){let{x:t,y:n,width:a,height:o}=i.attrs;m({type:`label`,axis:f(e),index:r,...h(i),text:i.ctx.text,x:t,y:n,width:a,height:o})}}}for(let e of(0,t.findAll)(r,{role:`gridBackground`}))m({type:`gridBackground`,...h(e)});let x=s.series??[];for(let e of(0,t.findAll)(r,{role:`series`})){let t=e.ctx.seriesIndex,n={series:x[o.reverseData?x.length-1-t:t],seriesIndex:t,axisX:l,axisY:d},r=e.children,i=r.find(e=>e.role===`slice`);if(i){let e=i.ctx;m({type:`slice`,value:e.value,totalDataSum:e.totalDataSum,index:e.index,meta:e.meta,series:e.series,...h(i),path:e.path.clone(),center:e.center,radius:e.radius,startAngle:e.startAngle,endAngle:e.endAngle,chartRect:c});let t=y.find(t=>t.ctx.index===e.index);if(t){let e=t.ctx;m({type:`label`,index:e.index,...h(t),text:e.text,chartRect:c,series:e.series,meta:e.meta,x:e.x,y:e.y})}continue}for(let e of r.filter(e=>e.role===`bar`)){let n=e.ctx;m({type:`bar`,value:n.value,index:n.valueIndex,meta:n.meta,series:n.series,seriesIndex:t,axisX:l,axisY:d,chartRect:c,...h(e),x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2})}for(let e of r.filter(e=>e.role===`point`)){let t=e.ctx;m({type:`point`,value:t.value,index:t.valueIndex,meta:t.meta,...n,...h(e),x:t.x,y:t.y,chartRect:c})}let a=[...r.filter(e=>e.role===`line`),...r.filter(e=>e.role===`area`).reverse()];for(let e of a){let r=e.ctx;m({type:e.role,values:r.values,path:r.path.clone(),chartRect:c,index:t,...n,meta:r.meta,...h(e)})}}let C=o.horizontalBars?l:d;u(e).emit(`created`,n.preset.kind===`pie`?{chartRect:c,svg:p(i),options:o}:{chartRect:c,axisX:l,axisY:d,bounds:C.bounds,svg:p(i),options:o})}function O(e){let n=m.get(e);if(n)return n;let r={instances:[]};return m.set(e,r),e[_]=!0,e.on(`resolve`,({config:t})=>(r.preset=t.preset,t.data!==r.source&&(r.copy=b(t.data),u(e).emit(`data`,{type:r.source===void 0?`initial`:`update`,data:r.copy}),r.source=t.data),{config:{...t,data:r.copy}})),e.on(`layout`,e=>{r.layout=e}),e.on(`responsive`,t=>`previousOptions`in t?u(e).emit(`optionsChanged`,{previousOptions:t.previousOptions,currentOptions:t.currentOptions}):void 0),e.on(`mount`,({scene:n,output:i,elementOf:a})=>{let o=i.svg;if(!o)throw Error(`Chartist: the compat plugin requires the DOM renderer`);r.svg=new t.Svg(o);for(let e of r.instances)e.svg=r.svg;o[h]={emit:(t,n)=>u(e).emit(t,n)},r.preset&&D(e,r,n,o,a)}),r}function k(e){return{getCurrentOptions:e,removeMediaQueryListeners:()=>void 0}}function A(e,t){let n=v(e),r={get container(){return e.container},get data(){return t.copy??n?.data},get options(){return n?.options},get svg(){return t.svg},eventEmitter:{on:(t,n)=>u(e).on(t,n),off:(t,n)=>u(e).off(t,n),emit:(t,n)=>u(e).emit(t,n)},optionsProvider:k(()=>n?.options),on(t,n){return u(e).on(t,n),r},off(t,n){return u(e).off(t,n),r},update(t,i,a){return n?n.update(t,i,a):e.update(t?{data:t}:{}),r},detach(){return n?n.detach():e.detach(),r}},i=n&&y[n.kind];return i?Object.setPrototypeOf(r,i.prototype):r}function j(e,t,n){return{name:e.name||`legacy-plugin`,provides:p,install(r){let i=O(r);if(n){i.instances.push(n);let e=n;e.optionsProvider||=k(()=>v(r)?.options)}let a=n??A(r,i);t===void 0?e(a):e(a,t)}}}let M={name:`compat`,provides:p,install:e=>void O(e),legacyPlugin:j};function N(e,t){return j(e,t)}function P(e,n){return(0,t.normalizeData)(e,n).series}let F={Line:t.LineChart,Bar:t.BarChart,Pie:t.PieChart,getDataArray:P};function I(e,n=globalThis){if(n.document===void 0)return;let r=n.Chartist;if(r&&`LineChart`in r&&r.LineChart!==t.LineChart){console.warn("Chartist: the global `Chartist` belongs to another copy of Chartist, so chartist/compat leaves it alone. Load Chartist once: as modules, or as the UMD build with compat.umd.js.");return}let i=r??(n.Chartist={}),a=(e,t)=>{e in i||(i[e]=t)};for(let[e,n]of Object.entries(t))a(e,n);for(let[t,n]of Object.entries(e))a(t,n);a(`plugins`,{});for(let[e,t]of Object.entries(F))a(e,t)}I(f),e.compat=M,e.fromLegacyPlugin=N});
|
|
2
2
|
//# sourceMappingURL=compat.umd.js.map
|
package/dist/compat.umd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compat.umd.js","names":["LineChart","BarChart","PieChart","normalizeData","axisUnits","StepAxis","AutoScaleAxis","isNumeric","serialMap","safeHasProperty","getHighLow","Svg","findAll","normalizeData","LineChart","BarChart","PieChart","core","compat","factory","global","exports","__create","__defProp","__getOwnPropDesc","__getOwnPropNames","__getProtoOf","__hasOwnProp","__exportAll","target","name","all","no_symbols","__copyProps","from","keys","i","n","key","to","except","k","desc","mod","isNodeMode","src_index","untyped","handle","nonEmptyRange","highLow","high","low","compat_exports","compat","fromLegacyPlugin","LEGACY_EVENTS","states","ANIMATION_EMITTER","PRESET_STATE","presetOf","CLASSES","mutableCopy","value","proto","entry","isLegacyAxisClass","type","chartRectOf","layout","area","lineAxes","normalized","data","options","series","chartRect","serialSums","values","sum","barAxes","horizontal","valueDimension","labelDimension","found","valueOptions","labelOptions","valueAxis","labelAxis","AXES","emitDrawEvents","state","axisOf","dimension","axisX","axisY","wrap","element","draw","payload","parts","elementOf","node","grids","scene","allLabels","labels","sliceLabels","order","onAxis","indexes","a","b","index","grid","label","background","rawSeries","seriesIndex","common","children","slice","ctx","labelCtx","barNode","point","shapes","shape","svgElement","enable","existing","config","change","svg","output","instance","event","optionsProviderOf","getOptions","legacyChart","preset","chart","listener","override","legacyPlugin","plugin","chartObject","getDataArray","reverse","LEGACY_NAMES","installGlobal","root","add"],"sources":["../src/chart/types.ts","../src/core/data/range.ts","../src/compat/index.ts","../src/compat/global.ts","../src/compat/entry.ts"],"sourcesContent":["import type { PipelineOptions } from '../pipeline/phases';\nimport type {\n AllPhasesListener,\n PhaseListener,\n PhaseListeners,\n PhaseName\n} from '../pipeline/types';\nimport type { Renderer } from '../render/types';\nimport type { ResponsiveSet } from '../responsive/responsive';\n\n/**\n * The custom events a chart can emit, by name, with their payloads. The\n * core emits only `responsive`. A plugin that emits events of its own\n * declares them here (TypeScript merges your declaration into Chartist's),\n * so `on()`, `off()` and `emit()` check the names and payloads:\n *\n * ```ts\n * declare module 'chartist' {\n * interface ChartEvents {\n * 'legend:click': { readonly seriesIndex: number };\n * }\n * }\n * ```\n *\n * `chartist/compat` declares the 1.x events (`draw`, `created`, …).\n * @experimental\n */\nexport interface ChartEvents {\n /**\n * Responsive entries changed which overrides apply: the config before\n * and after (`chart()`), or the options before and after (presets).\n */\n responsive:\n | {\n readonly previousConfig: ChartConfig;\n readonly currentConfig: ChartConfig;\n }\n | { readonly previousOptions: unknown; readonly currentOptions: unknown };\n}\n\n/**\n * The name of a custom event: a key of {@link ChartEvents}. Plugins list\n * the names they emit in `provides`.\n */\nexport type CustomEventName = keyof ChartEvents & string;\n\n/**\n * A plugin: a name and an `install` function that registers listeners on\n * the chart. Plugins go into `plugins`, in the config of {@link chart} or\n * the options of the presets. They install in order, so with two\n * listeners on the same event, the earlier plugin's runs first.\n *\n * For options, write a function that takes them and returns the plugin, or\n * read them from the second argument of `install` and pass the plugin\n * with {@link withOptions}.\n *\n * @example\n * ```ts\n * import { barChart, type ChartPlugin } from 'chartist';\n *\n * // Bars at or above the limit get the class ct-over.\n * const threshold = (limit: number): ChartPlugin => ({\n * name: 'threshold',\n * install(chart) {\n * chart.on('compose', current => {\n * if (current.role !== 'bar') {\n * return;\n * }\n * const { value } = current.ctx;\n * const y =\n * typeof value === 'number'\n * ? value\n * : value && 'y' in value\n * ? value.y\n * : undefined;\n * return y !== undefined && y >= limit\n * ? current.addClass('ct-over')\n * : undefined;\n * });\n * }\n * });\n *\n * barChart('#chart', { series: [[5, 4, 3, 7]] }, { plugins: [threshold(5)] });\n * ```\n * @experimental\n */\nexport interface ChartPlugin<TOptions = unknown> {\n /** Names the plugin. Prefix your custom events with it to keep them apart. */\n readonly name: string;\n /**\n * The custom events this plugin emits with `chart.emit()`, each declared\n * in {@link ChartEvents}. They're known before any plugin installs, so\n * another plugin may listen to them.\n */\n readonly provides?: readonly CustomEventName[];\n /**\n * Sets the plugin up: runs once, before the first render, with the\n * chart's handle. Listeners registered here stay for every later render,\n * after updates and resizes too, and `off(name)` without a listener\n * leaves them alone: remove one with its reference.\n * @param chart The chart's handle, to listen to events and emit them.\n * @param options The options of a `[plugin, options]` entry, if any.\n */\n install(chart: ChartHandle, options?: TOptions): void;\n}\n\n/**\n * A plugin paired with its options, as {@link withOptions} creates it.\n * `install` receives the options as its second argument.\n */\nexport type PluginWithOptions<TOptions = unknown> = readonly [\n ChartPlugin<TOptions>,\n TOptions\n];\n\n/**\n * An entry of a chart's `plugins`: a plugin, or a plugin with its options.\n * Prefer {@link withOptions} (it checks the options) or a function that\n * returns a plugin over a bare `[plugin, options]` pair. A 1.x plugin (a\n * plain function) throws; convert it with `fromLegacyPlugin()` from\n * `chartist/compat`.\n */\nexport type PluginEntry =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ChartPlugin<any> | PluginWithOptions<any>;\n\n/**\n * The config of {@link chart}: the data, the layers that draw it and the\n * axes they draw on, plus size, padding, plugins and listeners.\n *\n * Without `axes`, layers draw into the whole chart area; the pie layer\n * needs `coordinates: 'polar'`. {@link toScene} takes the same config.\n * @experimental\n */\nexport interface ChartConfig extends PipelineOptions {\n /**\n * Plugins to install before the first render, in order: plugins, or\n * plugins with their options from {@link withOptions}.\n */\n readonly plugins?: readonly PluginEntry[];\n /**\n * Phase listeners by phase name (or `'*'` for all phases). They're\n * registered before the first render, so they see it too.\n */\n readonly on?: PhaseListeners;\n /** Turns the scene into output; the DOM renderer by default. */\n readonly renderer?: Renderer;\n /**\n * Overrides that apply while their condition matches, created with\n * `responsive([...])`: entries of a media query string or a\n * `container()` condition, and a partial config. The chart renders again\n * when the matching entries change.\n */\n readonly responsive?: ResponsiveSet<ChartOverrides>;\n}\n\n/**\n * The part of a {@link ChartConfig} that responsive entries can override:\n * everything but `responsive`, `plugins`, `on` and `renderer`. The\n * matching entries merge over the config in order, shallowly.\n * @experimental\n */\nexport type ChartOverrides = Partial<\n Omit<ChartConfig, 'responsive' | 'plugins' | 'on' | 'renderer'>\n>;\n\n/**\n * The handle {@link chart} returns: update or remove the chart, and listen\n * to its events. Plugins get the same handle in `install`. The methods\n * other than `destroy` and `emit` return the handle, so calls chain.\n * @experimental\n */\nexport interface ChartHandle {\n /** The element the chart renders into (undefined in `toScene`). */\n readonly container?: Element;\n /**\n * Shallow-merges the changes into the config and renders again. Plugins\n * and listeners stay; `plugins` and `on` can't change.\n */\n update(config: Partial<Omit<ChartConfig, 'plugins' | 'on'>>): this;\n /**\n * Stops reacting to container size changes (and media queries in\n * presets). The output and the listeners stay.\n */\n detach(): this;\n /** Detaches, removes the output and clears all listeners. */\n destroy(): void;\n /**\n * Emits a custom event (declared in {@link ChartEvents}), e.g. from a\n * plugin. Phase names are reserved: emitting one throws.\n */\n emit<K extends CustomEventName>(name: K, payload: ChartEvents[K]): void;\n /**\n * Listens to a phase event, which fires on every render. Listeners of\n * `resolve` to `scene` may return a new payload to change what's drawn;\n * `compose` listeners may return `null` to drop a node.\n */\n on<K extends PhaseName>(name: K, listener: PhaseListener<K>): this;\n /** Listens to every phase event, with the phase name and its payload. */\n on(name: '*', listener: AllPhasesListener): this;\n /** Listens to a custom event, declared in {@link ChartEvents}. */\n on<K extends CustomEventName>(\n name: K,\n listener: (payload: ChartEvents[K]) => void\n ): this;\n /**\n * Removes a phase listener, whoever added it. Without a listener,\n * removes the listeners of the phase added through `on` and the\n * config's `on`; plugins keep theirs.\n */\n off<K extends PhaseName>(name: K, listener?: PhaseListener<K>): this;\n /**\n * Removes a listener of all phases, or without a listener, those added\n * through `on`.\n */\n off(name: '*', listener?: AllPhasesListener): this;\n /**\n * Removes a custom event listener, or without a listener, the event's\n * listeners added through `on`.\n */\n off<K extends CustomEventName>(\n name: K,\n listener?: (payload: ChartEvents[K]) => void\n ): this;\n}\n\n/**\n * Pairs a plugin with its options for a chart's `plugins`, and checks the\n * options against the plugin's options type. `install` receives them as\n * its second argument.\n *\n * @example\n * ```ts\n * import { lineChart, withOptions, type ChartPlugin } from 'chartist';\n *\n * const lastPoint: ChartPlugin<{ className: string }> = {\n * name: 'last-point',\n * install(chart, options) {\n * chart.on('compose', current => {\n * if (current.role !== 'series') {\n * return;\n * }\n * const last = current.children.at(-1);\n * return last && options\n * ? current.replace(last, last.addClass(options.className))\n * : undefined;\n * });\n * }\n * };\n *\n * lineChart(\n * '#chart',\n * { series: [[1, 3, 2, 5]] },\n * { plugins: [withOptions(lastPoint, { className: 'ct-last' })] }\n * );\n * ```\n * @experimental\n */\nexport function withOptions<TOptions>(\n plugin: ChartPlugin<TOptions>,\n options: TOptions\n): PluginWithOptions<TOptions> {\n return [plugin, options];\n}\n\n/**\n * The handle without event typing, for code that routes event names it\n * doesn't know (the 1.x chart classes, compat). Internal.\n */\nexport interface UntypedEvents {\n on(name: string, listener: (payload: unknown) => void): unknown;\n off(name: string, listener?: (payload: unknown) => void): unknown;\n emit(name: string, payload?: unknown): void;\n}\n\n/** The same handle, seen without event typing. Internal. */\nexport const untyped = (handle: ChartHandle): UntypedEvents =>\n handle as unknown as UntypedEvents;\n","/**\n * Repairs a value range that's empty because high is at or below low, from\n * flat data or a misconfigured `high`/`low`: sets the bound on the other\n * side of zero to 0, or gives `0` to `1` when there are no values. Chart\n * code that overrides a bound after `getHighLow` calls it again.\n *\n * @param highLow The range to check.\n * @returns The range, or the repaired one.\n */\nexport function nonEmptyRange(highLow: {\n readonly high: number;\n readonly low: number;\n}): { high: number; low: number } {\n const { high, low } = highLow;\n if (high > low) {\n return { high, low };\n }\n if (low === 0) {\n // Both are 0.\n return { high: 1, low };\n }\n if (low < 0) {\n // The same negative value for both.\n return { high: 0, low };\n }\n if (high > 0) {\n // The same positive value for both.\n return { high, low: 0 };\n }\n // No values: high and low are still -Number.MAX_VALUE and Number.MAX_VALUE.\n return { high: 1, low: 0 };\n}\n","/**\n * The compat plugin: 1.x events, `Svg` wrappers and 1.x plugins on v2\n * charts. Opt-in: `plugins: [compat]`, or convert a 1.x plugin with\n * `fromLegacyPlugin()`.\n *\n * Imports only from the package root, so the built `chartist/compat` entry\n * shares the core with `chartist` instead of bundling a copy.\n */\nimport {\n AutoScaleAxis,\n BarChart,\n LineChart,\n PieChart,\n Svg,\n StepAxis,\n axisUnits,\n findAll,\n getHighLow,\n isNumeric,\n normalizeData,\n safeHasProperty,\n serialMap,\n type ChartHandle,\n type ChartPlugin,\n type ChartRect,\n type Data,\n type Layout,\n type PresetState,\n type NormalizedSeries,\n type AxisLabelContext,\n type PieLabelContext,\n type RoleNode,\n type SceneNode\n} from '../index';\nimport { untyped } from '../chart/types';\nimport { nonEmptyRange } from '../core/data/range';\nimport type {\n AnimationEvent,\n AreaDrawEvent,\n AxesDrawEvent,\n BarChartCreatedEvent,\n BarDrawEvent,\n DataEvent,\n LineChartCreatedEvent,\n LineDrawEvent,\n OptionsChangedEvent,\n PieChartCreatedEvent,\n PointDrawEvent,\n SliceDrawEvent,\n SliceLabelDrawEvent\n} from '../index';\n\n// With chartist/compat, the 1.x events are typed on every chart handle.\ndeclare module '../chart/types' {\n interface ChartEvents {\n /**\n * 1.x: the chart's data, before the first render (`type: 'initial'`)\n * and after an update with new data (`type: 'update'`). Listeners can\n * change it in place. Needs the {@link compat} plugin.\n */\n data: DataEvent;\n /**\n * 1.x: the responsive options changed, with the options before and\n * after. Needs the {@link compat} plugin.\n */\n optionsChanged: OptionsChangedEvent;\n /**\n * 1.x: an element was drawn: a grid line, label, point, line, area,\n * bar or slice, with its live `element`. Check `type` to narrow it.\n * Needs the {@link compat} plugin.\n */\n draw:\n | PointDrawEvent\n | LineDrawEvent\n | AreaDrawEvent\n | BarDrawEvent\n | SliceDrawEvent\n | SliceLabelDrawEvent\n | AxesDrawEvent;\n /**\n * 1.x: the chart is drawn and in the DOM, after its `draw` events,\n * with the `svg`, the chart area and the axes. Needs the {@link compat}\n * plugin.\n */\n created:\n | LineChartCreatedEvent\n | BarChartCreatedEvent\n | PieChartCreatedEvent;\n /**\n * 1.x: an SMIL animation began, started with `animate()` on an element\n * of the chart, such as the `element` of a `draw` event. Needs the\n * {@link compat} plugin.\n */\n animationBegin: AnimationEvent;\n /**\n * 1.x: an SMIL animation ended, started with `animate()` on an element\n * of the chart. Needs the {@link compat} plugin.\n */\n animationEnd: AnimationEvent;\n }\n}\n\n/** The 1.x events the compat plugin emits. */\nconst LEGACY_EVENTS = [\n 'data',\n 'optionsChanged',\n 'draw',\n 'created',\n 'animationBegin',\n 'animationEnd'\n] as const;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype LegacyPlugin = (chart: any, options?: any) => void;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyOptions = any;\n\ninterface CompatState {\n preset?: PresetState<Data, AnyOptions>;\n /** The data object of the last `data` event, and its mutable copy. */\n source?: unknown;\n copy?: Data;\n layout?: Layout;\n svg?: Svg;\n /** 1.x chart instances whose `svg` field follows the chart's. */\n instances: { svg?: Svg }[];\n}\n\nconst states = new WeakMap<ChartHandle, CompatState>();\n\n/**\n * Where `Svg#animate()` looks for the emitter of an element's animations\n * when it gets none (on the element or an ancestor). The core reads the\n * same global symbol.\n */\nconst ANIMATION_EMITTER = Symbol.for('chartist.animationEmitter');\n\n/**\n * Where a preset's chart handle holds its preset state from the moment\n * plugins install. The core sets the same global symbol.\n */\nconst PRESET_STATE = Symbol.for('chartist.presetState');\n\nconst presetOf = (handle: ChartHandle) =>\n (handle as { [PRESET_STATE]?: PresetState<Data, AnyOptions> })[PRESET_STATE];\n\n/** The 1.x class of each preset, for 0.x and 1.x type checks in plugins. */\nconst CLASSES: Record<string, { prototype: object }> = {\n line: LineChart,\n bar: BarChart,\n pie: PieChart\n};\n\n/** Copies plain arrays and objects; other values are kept by reference. */\nfunction mutableCopy<T>(value: T): T {\n if (Array.isArray(value)) {\n return value.map(mutableCopy) as T;\n }\n if (value && typeof value === 'object') {\n const proto = Object.getPrototypeOf(value);\n if (proto === Object.prototype || proto === null) {\n return Object.fromEntries(\n Object.entries(value).map(([key, entry]) => [key, mutableCopy(entry)])\n ) as T;\n }\n }\n return value;\n}\n\nconst isLegacyAxisClass = (\n type: unknown\n): type is new (...args: unknown[]) => unknown =>\n typeof type === 'function' &&\n typeof (type as { prototype?: { projectValue?: unknown } }).prototype\n ?.projectValue === 'function';\n\nfunction chartRectOf(layout: Layout): ChartRect {\n const { area, padding } = layout;\n return {\n x1: area.x1,\n x2: area.x2,\n y1: area.y1,\n y2: area.y2,\n padding,\n width() {\n return this.x2 - this.x1;\n },\n height() {\n return this.y1 - this.y2;\n }\n };\n}\n\n/** The 1.x axes, constructed as 1.x `LineChart.createChart` does. */\nfunction lineAxes(options: AnyOptions, data: Data, chartRect: ChartRect) {\n const normalized = normalizeData(\n data as Data<NormalizedSeries[]>,\n options.reverseData,\n true\n );\n const series = normalized.series as NormalizedSeries[];\n const axisX = isLegacyAxisClass(options.axisX.type)\n ? new options.axisX.type(axisUnits.x, series, chartRect, options.axisX)\n : new StepAxis(axisUnits.x, series, chartRect, {\n ...options.axisX,\n ticks: normalized.labels,\n stretch: options.fullWidth\n });\n const axisY = isLegacyAxisClass(options.axisY.type)\n ? new options.axisY.type(axisUnits.y, series, chartRect, options.axisY)\n : new AutoScaleAxis(axisUnits.y, series, chartRect, {\n ...options.axisY,\n high: isNumeric(options.high) ? options.high : options.axisY.high,\n low: isNumeric(options.low) ? options.low : options.axisY.low\n });\n return { axisX, axisY };\n}\n\n/** Sums per index across series, as 1.x `BarChart` stacks them. */\nfunction serialSums(series: NormalizedSeries[]) {\n return serialMap(series, (...values) =>\n values.reduce<{ x: number; y: number }>(\n (sum, value) => ({\n x: sum.x + (safeHasProperty(value, 'x') ? (value.x as number) : 0),\n y: sum.y + (safeHasProperty(value, 'y') ? (value.y as number) : 0)\n }),\n { x: 0, y: 0 }\n )\n );\n}\n\n/** The 1.x axes, constructed as 1.x `BarChart.createChart` does. */\nfunction barAxes(options: AnyOptions, data: Data, chartRect: ChartRect) {\n const horizontal = Boolean(options.horizontalBars);\n const valueDimension = horizontal ? 'x' : 'y';\n const labelDimension = horizontal ? 'y' : 'x';\n const normalized = normalizeData(\n data as Data<NormalizedSeries[]>,\n options.reverseData,\n valueDimension,\n true\n );\n const series = normalized.series as NormalizedSeries[];\n const found =\n options.stackBars && options.stackMode !== true && series.length\n ? getHighLow([serialSums(series)], options, valueDimension)\n : getHighLow(series, options, valueDimension);\n // The chart-level bounds win, but can empty the range again (#1057).\n const highLow = nonEmptyRange({\n high: typeof options.high === 'number' ? options.high : found.high,\n low: typeof options.low === 'number' ? options.low : found.low\n });\n const valueOptions = horizontal ? options.axisX : options.axisY;\n const labelOptions = horizontal ? options.axisY : options.axisX;\n const ValueAxis = isLegacyAxisClass(valueOptions.type)\n ? valueOptions.type\n : AutoScaleAxis;\n const valueAxis = new ValueAxis(\n axisUnits[valueDimension],\n series,\n chartRect,\n {\n ...valueOptions,\n highLow,\n referenceValue: 0\n }\n );\n const labelAxis = isLegacyAxisClass(labelOptions.type)\n ? new labelOptions.type(\n axisUnits[labelDimension],\n series,\n chartRect,\n labelOptions\n )\n : new StepAxis(axisUnits[labelDimension], series, chartRect, {\n ticks:\n options.distributeSeries && options.stackBars\n ? normalized.labels.slice(0, 1)\n : normalized.labels\n });\n return horizontal\n ? { axisX: valueAxis, axisY: labelAxis }\n : { axisX: labelAxis, axisY: valueAxis };\n}\n\nconst AXES: Record<\n string,\n (\n options: AnyOptions,\n data: Data,\n chartRect: ChartRect\n ) => { axisX: unknown; axisY: unknown }\n> = {\n line: lineAxes,\n bar: barAxes,\n // Pie charts have no axes.\n pie: () => ({ axisX: undefined, axisY: undefined })\n};\n\n/** 1.x `draw` payloads in 1.x order, then `created`. */\nfunction emitDrawEvents(\n handle: ChartHandle,\n state: CompatState,\n scene: SceneNode,\n svgElement: Element,\n elementOf: (node: SceneNode) => Element | undefined\n) {\n const options = state.preset?.options as AnyOptions;\n const data = (state.copy ?? state.preset?.data) as Data;\n const chartRect = chartRectOf(state.layout!);\n const { axisX, axisY } = AXES[state.preset!.kind](options, data, chartRect);\n const axisOf = (dimension?: string) => (dimension === 'x' ? axisX : axisY);\n const wrap = (element: Element) => new Svg(element);\n const draw = (payload: Record<string, unknown>) =>\n untyped(handle).emit('draw', payload);\n const parts = (node: SceneNode) => {\n const element = elementOf(node)!;\n return { element: wrap(element), group: wrap(element.parentElement!) };\n };\n\n // Axes: per tick its grid line, then its label, in the order the axes\n // appear in the chart (X first for lines, the label axis first for bars).\n const grids = findAll(scene, { role: 'grid' });\n // Only axis labels; pie labels belong to their slice.\n const allLabels = findAll(scene, { role: 'label' });\n const labels = allLabels.filter(\n (n): n is RoleNode<'label'> & { ctx: AxisLabelContext } =>\n n.ctx.kind === 'axis'\n );\n const sliceLabels = allLabels.filter(\n (n): n is RoleNode<'label'> & { ctx: PieLabelContext } =>\n n.ctx.kind === 'pie'\n );\n const order = [\n ...new Set([...grids, ...labels].map(n => n.ctx.axis.dimension))\n ];\n for (const dimension of order) {\n const onAxis = (node: { ctx: { axis: { dimension: string } } }) =>\n node.ctx.axis.dimension === dimension;\n const indexes = [\n ...new Set([...grids, ...labels].filter(onAxis).map(n => n.ctx.index))\n ].sort((a, b) => a - b);\n for (const index of indexes) {\n const grid = grids.find(n => onAxis(n) && n.ctx.index === index);\n if (grid) {\n const { x1, y1, x2, y2 } = grid.attrs;\n draw({\n type: 'grid',\n axis: axisOf(dimension),\n index,\n ...parts(grid),\n x1,\n y1,\n x2,\n y2\n });\n }\n const label = labels.find(n => onAxis(n) && n.ctx.index === index);\n if (label) {\n const { x, y, width, height } = label.attrs;\n draw({\n type: 'label',\n axis: axisOf(dimension),\n index,\n ...parts(label),\n text: label.ctx.text,\n x,\n y,\n width,\n height\n });\n }\n }\n }\n for (const background of findAll(scene, { role: 'gridBackground' })) {\n draw({ type: 'gridBackground', ...parts(background) });\n }\n\n // Series: points, then the line, then the areas in creation order.\n const rawSeries = (data.series ?? []) as unknown[];\n for (const series of findAll(scene, { role: 'series' })) {\n const seriesIndex = series.ctx.seriesIndex;\n const original =\n rawSeries[\n options.reverseData ? rawSeries.length - 1 - seriesIndex : seriesIndex\n ];\n const common = { series: original, seriesIndex, axisX, axisY };\n const children = series.children;\n const slice = children.find(n => n.role === 'slice');\n if (slice) {\n const ctx = slice.ctx;\n draw({\n type: 'slice',\n value: ctx.value,\n totalDataSum: ctx.totalDataSum,\n index: ctx.index,\n meta: ctx.meta,\n series: ctx.series,\n ...parts(slice),\n path: ctx.path.clone(),\n center: ctx.center,\n radius: ctx.radius,\n startAngle: ctx.startAngle,\n endAngle: ctx.endAngle,\n chartRect\n });\n const label = sliceLabels.find(n => n.ctx.index === ctx.index);\n if (label) {\n const labelCtx = label.ctx;\n draw({\n type: 'label',\n index: labelCtx.index,\n ...parts(label),\n text: labelCtx.text,\n chartRect,\n series: labelCtx.series,\n meta: labelCtx.meta,\n x: labelCtx.x,\n y: labelCtx.y\n });\n }\n continue;\n }\n for (const barNode of children.filter(n => n.role === 'bar')) {\n const ctx = barNode.ctx!;\n draw({\n type: 'bar',\n value: ctx.value,\n index: ctx.valueIndex,\n meta: ctx.meta,\n series: ctx.series,\n seriesIndex,\n axisX,\n axisY,\n chartRect,\n ...parts(barNode),\n x1: ctx.x1,\n y1: ctx.y1,\n x2: ctx.x2,\n y2: ctx.y2\n });\n }\n for (const point of children.filter(n => n.role === 'point')) {\n const ctx = point.ctx!;\n draw({\n type: 'point',\n value: ctx.value,\n index: ctx.valueIndex,\n meta: ctx.meta,\n ...common,\n ...parts(point),\n x: ctx.x,\n y: ctx.y,\n chartRect\n });\n }\n const shapes = [\n ...children.filter(n => n.role === 'line'),\n // Areas are inserted first, so the DOM order is the reverse.\n ...children.filter(n => n.role === 'area').reverse()\n ];\n for (const shape of shapes) {\n const ctx = shape.ctx!;\n draw({\n type: shape.role,\n values: ctx.values,\n path: ctx.path.clone(),\n chartRect,\n index: seriesIndex,\n ...common,\n meta: ctx.meta,\n ...parts(shape)\n });\n }\n }\n\n // 0.x plugins also read `bounds`, the value axis's scale, which 0.x\n // passed next to the axes (auto scale axes only, as in 0.x).\n const valueAxis = options.horizontalBars ? axisX : axisY;\n untyped(handle).emit(\n 'created',\n state.preset!.kind === 'pie'\n ? { chartRect, svg: wrap(svgElement), options }\n : {\n chartRect,\n axisX,\n axisY,\n bounds: (valueAxis as { bounds?: unknown }).bounds,\n svg: wrap(svgElement),\n options\n }\n );\n}\n\n/** Turns the 1.x events on for a chart, once. */\nfunction enable(handle: ChartHandle): CompatState {\n const existing = states.get(handle);\n if (existing) {\n return existing;\n }\n const state: CompatState = { instances: [] };\n states.set(handle, state);\n\n handle.on('resolve', ({ config }) => {\n state.preset = config.preset as CompatState['preset'];\n if (config.data !== state.source) {\n // 1.x data handlers mutate the data; they get a copy, and the copy\n // is used from now on (as 1.x keeps its mutated data).\n state.copy = mutableCopy(config.data) as Data;\n untyped(handle).emit('data', {\n type: state.source === undefined ? 'initial' : 'update',\n data: state.copy\n });\n state.source = config.data;\n }\n return { config: { ...config, data: state.copy as typeof config.data } };\n });\n handle.on('layout', layout => {\n state.layout = layout;\n });\n handle.on('responsive', change =>\n 'previousOptions' in change\n ? untyped(handle).emit('optionsChanged', {\n previousOptions: change.previousOptions,\n currentOptions: change.currentOptions\n })\n : undefined\n );\n handle.on('mount', ({ scene, output, elementOf }) => {\n const svg = (output as { svg?: Element }).svg;\n if (!svg) {\n throw new Error('Chartist: the compat plugin requires the DOM renderer');\n }\n state.svg = new Svg(svg);\n // Set before the draw events, so listeners can query the chart.\n for (const instance of state.instances) {\n instance.svg = state.svg;\n }\n // Animations of the chart's elements emit animationBegin and\n // animationEnd on the chart, as 1.x did with the chart's emitter.\n (svg as { [ANIMATION_EMITTER]?: unknown })[ANIMATION_EMITTER] = {\n emit: (event: string, payload: unknown) =>\n untyped(handle).emit(event, payload)\n };\n if (state.preset) {\n emitDrawEvents(handle, state, scene, svg, elementOf);\n }\n });\n return state;\n}\n\n/** 1.x `optionsProvider`: the options in effect, after responsive options. */\nfunction optionsProviderOf(getOptions: () => unknown) {\n return {\n getCurrentOptions: getOptions,\n // The preset watches the media queries and stops on `detach()`.\n removeMediaQueryListeners: () => undefined\n };\n}\n\n/**\n * A 1.x-style chart object for 1.x plugins on the functional API. For a\n * preset it is an instance of the preset's 1.x class (without running its\n * constructor), so type checks such as `chart instanceof LineChart` hold;\n * for `chart()` compositions a plain object.\n */\nfunction legacyChart(handle: ChartHandle, state: CompatState) {\n const preset = presetOf(handle);\n const chart = {\n get container() {\n return handle.container;\n },\n get data() {\n return state.copy ?? preset?.data;\n },\n get options() {\n return preset?.options;\n },\n get svg() {\n return state.svg;\n },\n eventEmitter: {\n on: (event: string, listener: (payload: unknown) => void) =>\n untyped(handle).on(event, listener),\n off: (event: string, listener?: (payload: unknown) => void) =>\n untyped(handle).off(event, listener),\n emit: (event: string, payload: unknown) =>\n untyped(handle).emit(event, payload)\n },\n optionsProvider: optionsProviderOf(() => preset?.options),\n on(event: string, listener: (payload: unknown) => void) {\n untyped(handle).on(event, listener);\n return chart;\n },\n off(event: string, listener?: (payload: unknown) => void) {\n untyped(handle).off(event, listener);\n return chart;\n },\n update(data?: unknown, options?: unknown, override?: boolean) {\n if (preset) {\n preset.update(data as never, options as never, override);\n } else {\n handle.update(data ? { data: data as never } : {});\n }\n return chart;\n },\n detach() {\n if (preset) {\n preset.detach();\n } else {\n handle.detach();\n }\n return chart;\n }\n };\n // The fields above are own properties, so they shadow the class's.\n const type = preset && CLASSES[preset.kind];\n return type ? Object.setPrototypeOf(chart, type.prototype) : chart;\n}\n\n/**\n * Runs a 1.x plugin function as a v2 plugin, with the given chart object.\n * Used by the 1.x chart classes, which pass themselves.\n */\nfunction legacyPlugin(\n plugin: LegacyPlugin,\n options?: unknown,\n chart?: unknown\n): ChartPlugin {\n return {\n name: plugin.name || 'legacy-plugin',\n provides: LEGACY_EVENTS,\n install(handle) {\n const state = enable(handle);\n if (chart) {\n // A 1.x chart instance: keep its `svg` field current, as 1.x did.\n state.instances.push(chart as { svg?: Svg });\n // The 1.x classes run on a preset and have no options provider;\n // plugins call it for the options in effect.\n const instance = chart as { optionsProvider?: unknown };\n if (!instance.optionsProvider) {\n instance.optionsProvider = optionsProviderOf(\n () => presetOf(handle)?.options\n );\n }\n }\n const chartObject = chart ?? legacyChart(handle, state);\n // As 1.x: plugins without options are called with the chart only.\n if (options === undefined) {\n plugin(chartObject);\n } else {\n plugin(chartObject, options);\n }\n }\n };\n}\n\n/**\n * The compat plugin. Restores the 1.x events (`data`, `optionsChanged`,\n * `draw`, `created`, `animationBegin`, `animationEnd`) with 1.x payloads.\n * With it, the 1.x chart classes also run 1.x plugin functions.\n *\n * Add it to `plugins`, of a 1.x class, a preset or `chart()`. The `draw`\n * events come in the 1.x order, right after the chart is in the DOM, so\n * `element` is a live element; then `created`. Animations started with\n * `animate()` on the chart's elements emit `animationBegin` and\n * `animationEnd`. Importing\n * `chartist/compat` also types the 1.x events on every chart handle. It\n * needs the DOM renderer, and the `draw` and `created` events need a\n * chart made by a preset or a 1.x class.\n *\n * @example\n * ```ts\n * import { lineChart } from 'chartist';\n * import { compat } from 'chartist/compat';\n *\n * const chart = lineChart(\n * '#chart',\n * {\n * labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],\n * series: [[12, 9, 7, 8, 5]]\n * },\n * { plugins: [compat] }\n * );\n *\n * // Registered after the first render, so it runs from the next one on.\n * chart.on('draw', data => {\n * if (data.type === 'point' && data.index === 4) {\n * data.element.addClass('is-friday');\n * }\n * });\n * ```\n */\nexport const compat: ChartPlugin & { legacyPlugin: typeof legacyPlugin } = {\n name: 'compat',\n provides: LEGACY_EVENTS,\n install: handle => void enable(handle),\n legacyPlugin\n};\n\n/**\n * Converts a 1.x plugin function into a v2 plugin for `chart()` and the\n * preset functions. It turns the 1.x events on for the chart and calls the\n * plugin with a 1.x-style chart object (`container`, `data`, `options`,\n * `svg`, `eventEmitter`, `on`, `off`, `update`, `detach`). You don't need\n * {@link compat} in the list as well.\n *\n * @param plugin The 1.x plugin: a function that gets the chart (and its\n * options)\n * @param options The plugin's options; without them, the plugin is called\n * with the chart only, as in 1.x\n * @example\n * ```ts\n * import { lineChart, type Plugin } from 'chartist';\n * import { fromLegacyPlugin } from 'chartist/compat';\n *\n * // A 1.x plugin: a function that gets the chart and its options.\n * const caption: Plugin = (chart, options) => {\n * chart.on('created', () => {\n * chart.container.setAttribute('aria-label', options.text);\n * });\n * };\n *\n * lineChart(\n * '#chart',\n * { series: [[1, 3, 2, 4]] },\n * { plugins: [fromLegacyPlugin(caption, { text: 'Visitors per week' })] }\n * );\n * ```\n */\nexport function fromLegacyPlugin(\n plugin: LegacyPlugin,\n options?: unknown\n): ChartPlugin {\n return legacyPlugin(plugin, options);\n}\n\n// The types of the 1.x events and plugins this plugin turns on.\nexport type * from './types';\n","/**\n * The global `Chartist` that plugin scripts of the 0.x and 1.x era read.\n * They register on `Chartist.plugins`, check the chart type with\n * `instanceof Chartist.Line`, and call helpers such as `Chartist.extend`.\n * Importing `chartist/compat` (any build: module, CommonJS or the UMD\n * script) sets this up, so such a script works when it loads after it.\n *\n * The names are added to the global only, never exported: the module\n * builds keep the 1.x and v2 names.\n */\nimport * as core from '../index';\nimport {\n BarChart,\n LineChart,\n PieChart,\n normalizeData,\n type Data\n} from '../index';\n\n/**\n * 0.x: the values of each series as plain numbers (`undefined` for holes),\n * normalized as the 1.x charts do; reversed when `reverse` is true. Line\n * and bar data give an array per series, pie data one array.\n */\nexport function getDataArray(\n data: Data,\n reverse?: boolean\n): (number | undefined)[] | (number | undefined)[][] {\n return normalizeData(data as Data<never>, reverse).series as\n | (number | undefined)[]\n | (number | undefined)[][];\n}\n\n/** The 0.x names plugin scripts use, next to the library's own. */\nconst LEGACY_NAMES = {\n // 0.x names of the chart classes, for `chart instanceof Chartist.Line`.\n Line: LineChart,\n Bar: BarChart,\n Pie: PieChart,\n getDataArray\n};\n\ntype Root = { Chartist?: Record<string, unknown>; document?: unknown };\n\n/**\n * Adds the core, compat and the 0.x names to the global `Chartist`, only\n * what it lacks: a global set by the UMD build or by plugin scripts keeps\n * its values, and `plugins` keeps what scripts registered. If the global\n * belongs to another copy of Chartist (say the UMD build next to these\n * modules), it is left alone with a warning: mixing two copies breaks the\n * plugins' type checks. Outside a browser it does nothing.\n */\nexport function installGlobal(\n compat: Record<string, unknown>,\n root: Root = globalThis as Root\n): void {\n if (root.document === undefined) {\n return;\n }\n const existing = root.Chartist;\n if (existing && 'LineChart' in existing && existing.LineChart !== LineChart) {\n // A hint for developers, as the warnings for 1.x events without compat.\n // eslint-disable-next-line no-console\n console.warn(\n 'Chartist: the global `Chartist` belongs to another copy of Chartist, so chartist/compat leaves it alone. Load Chartist once: as modules, or as the UMD build with compat.umd.js.'\n );\n return;\n }\n const target = existing ?? (root.Chartist = {});\n const add = (name: string, value: unknown) => {\n if (!(name in target)) {\n target[name] = value;\n }\n };\n for (const [name, value] of Object.entries(core)) {\n add(name, value);\n }\n for (const [name, value] of Object.entries(compat)) {\n add(name, value);\n }\n add('plugins', {});\n for (const [name, value] of Object.entries(LEGACY_NAMES)) {\n add(name, value);\n }\n}\n","/**\n * The published entry of `chartist/compat`, in every build. Next to the\n * compat API, importing it sets up the global `Chartist` for plugin\n * scripts of the 0.x and 1.x era (see ./global.ts). That's why\n * package.json lists the compat files under `sideEffects`.\n */\nimport * as compat from './index';\nimport { installGlobal } from './global';\n\nexport * from './index';\n\ninstallGlobal(compat);\n"],"mappings":"u8BAoRA,IAAa8C,EAAW,GACtBC,EC5QF,SAAgBC,EAAc,EAGI,CAChC,GAAM,CAAE,OAAM,OAAQC,EAiBtB,OAhBIC,EAAOC,EACF,CAAE,OAA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IrB,GAAY,cAAeA,GAAYA,EAAS,YAAcnH,EAAAA,UAAW,CAG3E,QAAQ,KACN,kLACF,EACA,MACF,CACA,IAAMe,EAASoG,IAAa,EAAK,SAAW,CAAC,GACvCsB,GAAO,EAAc,IAAmB,CACtCzH,KAAQD,IACZ,EAAOC,GAAQgC,EAEnB,EACA,IAAK,GAAM,CAAChC,EAAMgC,KAAU,OAAO,QAAQ7C,CAAI,EAC7CsI,EAAIzH,EAAMgC,CAAK,EAEjB,IAAK,GAAM,CAAChC,EAAMgC,KAAU,OAAO,QAAQT,CAAM,EAC/CkG,EAAIzH,EAAMgC,CAAK,EAEjByF,EAAI,UAAW,CAAC,CAAC,EACjB,IAAK,GAAM,CAACzH,EAAMgC,KAAU,OAAO,QAAQsF,CAAY,EACrDG,EAAIzH,EAAMgC,CAAK,CAEnB,CCzEAuF,EAAcnI,CAAM"}
|
|
1
|
+
{"version":3,"file":"compat.umd.js","names":["LineChart","BarChart","PieChart","normalizeData","axisUnits","StepAxis","AutoScaleAxis","isNumeric","serialMap","safeHasProperty","getHighLow","Svg","findAll","normalizeData","LineChart","BarChart","PieChart","core","compat","factory","global","exports","__create","__defProp","__getOwnPropDesc","__getOwnPropNames","__getProtoOf","__hasOwnProp","__exportAll","target","name","all","no_symbols","__copyProps","from","keys","i","n","key","to","except","k","desc","mod","isNodeMode","src_index","untyped","handle","nonEmptyRange","highLow","high","low","compat_exports","compat","fromLegacyPlugin","LEGACY_EVENTS","states","ANIMATION_EMITTER","PRESET_STATE","REPLACES_OUTPUT","presetOf","CLASSES","mutableCopy","value","proto","entry","isLegacyAxisClass","type","chartRectOf","layout","area","lineAxes","normalized","data","options","series","chartRect","serialSums","values","sum","barAxes","horizontal","valueDimension","labelDimension","found","valueOptions","labelOptions","valueAxis","labelAxis","AXES","emitDrawEvents","state","axisOf","dimension","axisX","axisY","wrap","element","draw","payload","parts","elementOf","node","grids","scene","allLabels","labels","sliceLabels","order","onAxis","indexes","a","b","index","grid","label","background","rawSeries","seriesIndex","common","children","slice","ctx","labelCtx","barNode","point","shapes","shape","svgElement","enable","existing","config","change","svg","output","instance","event","optionsProviderOf","getOptions","legacyChart","preset","chart","listener","override","legacyPlugin","plugin","chartObject","getDataArray","reverse","LEGACY_NAMES","installGlobal","root","add"],"sources":["../src/chart/types.ts","../src/core/data/range.ts","../src/compat/index.ts","../src/compat/global.ts","../src/compat/entry.ts"],"sourcesContent":["import type { PipelineOptions } from '../pipeline/phases';\nimport type {\n AllPhasesListener,\n PhaseListener,\n PhaseListeners,\n PhaseName\n} from '../pipeline/types';\nimport type { Keyframes, Renderer } from '../render/types';\nimport type { SceneNode } from '../scene/node';\nimport type { ResponsiveSet } from '../responsive/responsive';\n\n/**\n * The custom events a chart can emit, by name, with their payloads. The\n * core emits only `responsive`. A plugin that emits events of its own\n * declares them here (TypeScript merges your declaration into Chartist's),\n * so `on()`, `off()` and `emit()` check the names and payloads:\n *\n * ```ts\n * declare module 'chartist' {\n * interface ChartEvents {\n * 'legend:click': { readonly seriesIndex: number };\n * }\n * }\n * ```\n *\n * `chartist/compat` declares the 1.x events (`draw`, `created`, …).\n */\nexport interface ChartEvents {\n /**\n * Responsive entries changed which overrides apply: the config before\n * and after (`chart()`), or the options before and after (presets).\n */\n responsive:\n | {\n readonly previousConfig: ChartConfig;\n readonly currentConfig: ChartConfig;\n }\n | { readonly previousOptions: unknown; readonly currentOptions: unknown };\n}\n\n/**\n * The name of a custom event: a key of {@link ChartEvents}. Plugins list\n * the names they emit in `provides`.\n */\nexport type CustomEventName = keyof ChartEvents & string;\n\n/**\n * A plugin: a name and an `install` function that registers listeners on\n * the chart. Plugins go into `plugins`, in the config of {@link chart} or\n * the options of the presets. They install in order, so with two\n * listeners on the same event, the earlier plugin's runs first.\n *\n * For options, write a function that takes them and returns the plugin, or\n * read them from the second argument of `install` and pass the plugin\n * with {@link withOptions}.\n *\n * @example\n * ```ts\n * import { barChart, type ChartPlugin } from 'chartist';\n *\n * // Bars at or above the limit get the class ct-over.\n * const threshold = (limit: number): ChartPlugin => ({\n * name: 'threshold',\n * install(chart) {\n * chart.on('compose', current => {\n * if (current.role !== 'bar') {\n * return;\n * }\n * const { value } = current.ctx;\n * const y =\n * typeof value === 'number'\n * ? value\n * : value && 'y' in value\n * ? value.y\n * : undefined;\n * return y !== undefined && y >= limit\n * ? current.addClass('ct-over')\n * : undefined;\n * });\n * }\n * });\n *\n * barChart('#chart', { series: [[5, 4, 3, 7]] }, { plugins: [threshold(5)] });\n * ```\n */\nexport interface ChartPlugin<TOptions = unknown> {\n /** Names the plugin. Prefix your custom events with it to keep them apart. */\n readonly name: string;\n /**\n * The custom events this plugin emits with `chart.emit()`, each declared\n * in {@link ChartEvents}. They're known before any plugin installs, so\n * another plugin may listen to them.\n */\n readonly provides?: readonly CustomEventName[];\n /**\n * Sets the plugin up: runs once, before the first render, with the\n * chart's handle. Listeners registered here stay for every later render,\n * after updates and resizes too, and `off(name)` without a listener\n * leaves them alone: remove one with its reference.\n *\n * Return a function to undo what `install` set up outside the chart,\n * such as a listener on the document: `destroy()` calls it once, after\n * the chart's output is removed. `detach()` doesn't.\n * @param chart The chart's handle, to listen to events and emit them.\n * @param options The options of a `[plugin, options]` entry, if any.\n * @returns A cleanup function for `destroy()`, or anything else, which is\n * ignored (so `install: chart => chart.on(…)` stays valid).\n */\n install(chart: ChartHandle, options?: TOptions): unknown;\n /**\n * Gives the keyframes of a node's update animation, for nodes that don't\n * move well number by number, such as a path the plugin draws. A\n * renderer that animates updates (`smilAnimations()` from\n * `chartist/live`) asks it once per update, never per frame, with the\n * progress points of the chart's easing: 0 is the previous node, 1 the\n * new one, and points beyond them come from an easing that overshoots.\n * Plugins are asked in their order, before the layer that drew the node;\n * the first one that returns keyframes wins.\n *\n * @example\n * ```ts\n * import type { ChartPlugin } from 'chartist';\n *\n * // Turns the gauge needle the plugin draws (its angle in `ct:angle`),\n * // instead of morphing its path.\n * const needle: ChartPlugin = {\n * name: 'needle',\n * install() {},\n * keyframes(previous, next, progress) {\n * if (!next.classes.includes('needle')) {\n * return undefined;\n * }\n * const from = Number(previous.attrs['ct:angle']);\n * const to = Number(next.attrs['ct:angle']);\n * return progress.map(p => ({\n * transform: `rotate(${from + (to - from) * p} 100 100)`\n * }));\n * }\n * };\n * ```\n * @param previous The node in the previous scene\n * @param next The node in the new scene\n * @param progress The progress points to give attributes for\n * @returns One set of attributes per progress point, or nothing.\n */\n keyframes?(\n previous: SceneNode,\n next: SceneNode,\n progress: readonly number[]\n ): Keyframes | undefined;\n}\n\n/**\n * A plugin paired with its options, as {@link withOptions} creates it.\n * `install` receives the options as its second argument.\n */\nexport type PluginWithOptions<TOptions = unknown> = readonly [\n ChartPlugin<TOptions>,\n TOptions\n];\n\n/**\n * An entry of a chart's `plugins`: a plugin, or a plugin with its options.\n * Prefer {@link withOptions} (it checks the options) or a function that\n * returns a plugin over a bare `[plugin, options]` pair. A 1.x plugin (a\n * plain function) throws; convert it with `fromLegacyPlugin()` from\n * `chartist/compat`.\n */\nexport type PluginEntry =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ChartPlugin<any> | PluginWithOptions<any>;\n\n/**\n * The config of {@link chart}: the data, the layers that draw it and the\n * axes they draw on, plus size, padding, plugins and listeners.\n *\n * Without `axes`, layers draw into the whole chart area; the pie layer\n * needs `coordinates: 'polar'`. {@link toScene} takes the same config.\n */\nexport interface ChartConfig extends PipelineOptions {\n /**\n * Plugins to install before the first render, in order: plugins, or\n * plugins with their options from {@link withOptions}.\n */\n readonly plugins?: readonly PluginEntry[];\n /**\n * Phase listeners by phase name (or `'*'` for all phases). They're\n * registered before the first render, so they see it too.\n */\n readonly on?: PhaseListeners;\n /** Turns the scene into output; the DOM renderer by default. */\n readonly renderer?: Renderer;\n /**\n * Overrides that apply while their condition matches, created with\n * `responsive([...])`: entries of a media query string or a\n * `container()` condition, and a partial config. The chart renders again\n * when the matching entries change.\n */\n readonly responsive?: ResponsiveSet<ChartOverrides>;\n}\n\n/**\n * The part of a {@link ChartConfig} that responsive entries can override:\n * everything but `responsive`, `plugins`, `on` and `renderer`. The\n * matching entries merge over the config in order, shallowly.\n */\nexport type ChartOverrides = Partial<\n Omit<ChartConfig, 'responsive' | 'plugins' | 'on' | 'renderer'>\n>;\n\n/**\n * The handle {@link chart} returns: update or remove the chart, and listen\n * to its events. Plugins get the same handle in `install`. The methods\n * other than `destroy` and `emit` return the handle, so calls chain.\n */\nexport interface ChartHandle {\n /** The element the chart renders into (undefined in `toScene`). */\n readonly container?: Element;\n /**\n * Shallow-merges the changes into the config and renders again. Plugins\n * and listeners stay; `plugins` and `on` can't change.\n */\n update(config: Partial<Omit<ChartConfig, 'plugins' | 'on'>>): this;\n /**\n * Stops reacting to container size changes (and media queries in\n * presets). The output and the listeners stay.\n */\n detach(): this;\n /** Detaches, removes the output and clears all listeners. */\n destroy(): void;\n /**\n * Emits a custom event (declared in {@link ChartEvents}), e.g. from a\n * plugin. Phase names are reserved: emitting one throws.\n */\n emit<K extends CustomEventName>(name: K, payload: ChartEvents[K]): void;\n /**\n * Listens to a phase event, which fires on every render. Listeners of\n * `resolve` to `scene` may return a new payload to change what's drawn;\n * `compose` listeners may return `null` to drop a node.\n */\n on<K extends PhaseName>(name: K, listener: PhaseListener<K>): this;\n /** Listens to every phase event, with the phase name and its payload. */\n on(name: '*', listener: AllPhasesListener): this;\n /** Listens to a custom event, declared in {@link ChartEvents}. */\n on<K extends CustomEventName>(\n name: K,\n listener: (payload: ChartEvents[K]) => void\n ): this;\n /**\n * Removes a phase listener, whoever added it. Without a listener,\n * removes the listeners of the phase added through `on` and the\n * config's `on`; plugins keep theirs.\n */\n off<K extends PhaseName>(name: K, listener?: PhaseListener<K>): this;\n /**\n * Removes a listener of all phases, or without a listener, those added\n * through `on`.\n */\n off(name: '*', listener?: AllPhasesListener): this;\n /**\n * Removes a custom event listener, or without a listener, the event's\n * listeners added through `on`.\n */\n off<K extends CustomEventName>(\n name: K,\n listener?: (payload: ChartEvents[K]) => void\n ): this;\n}\n\n/**\n * Pairs a plugin with its options for a chart's `plugins`, and checks the\n * options against the plugin's options type. `install` receives them as\n * its second argument.\n *\n * @example\n * ```ts\n * import { lineChart, withOptions, type ChartPlugin } from 'chartist';\n *\n * const lastPoint: ChartPlugin<{ className: string }> = {\n * name: 'last-point',\n * install(chart, options) {\n * chart.on('compose', current => {\n * if (current.role !== 'series') {\n * return;\n * }\n * const last = current.children.at(-1);\n * return last && options\n * ? current.replace(last, last.addClass(options.className))\n * : undefined;\n * });\n * }\n * };\n *\n * lineChart(\n * '#chart',\n * { series: [[1, 3, 2, 5]] },\n * { plugins: [withOptions(lastPoint, { className: 'ct-last' })] }\n * );\n * ```\n */\nexport function withOptions<TOptions>(\n plugin: ChartPlugin<TOptions>,\n options: TOptions\n): PluginWithOptions<TOptions> {\n return [plugin, options];\n}\n\n/**\n * The handle without event typing, for code that routes event names it\n * doesn't know (the 1.x chart classes, compat). Internal.\n */\nexport interface UntypedEvents {\n on(name: string, listener: (payload: unknown) => void): unknown;\n off(name: string, listener?: (payload: unknown) => void): unknown;\n emit(name: string, payload?: unknown): void;\n}\n\n/** The same handle, seen without event typing. Internal. */\nexport const untyped = (handle: ChartHandle): UntypedEvents =>\n handle as unknown as UntypedEvents;\n","/**\n * Repairs a value range that's empty because high is at or below low, from\n * flat data or a misconfigured `high`/`low`: sets the bound on the other\n * side of zero to 0, or gives `0` to `1` when there are no values. Chart\n * code that overrides a bound after `getHighLow` calls it again.\n *\n * @param highLow The range to check.\n * @returns The range, or the repaired one.\n */\nexport function nonEmptyRange(highLow: {\n readonly high: number;\n readonly low: number;\n}): { high: number; low: number } {\n const { high, low } = highLow;\n if (high > low) {\n return { high, low };\n }\n if (low === 0) {\n // Both are 0.\n return { high: 1, low };\n }\n if (low < 0) {\n // The same negative value for both.\n return { high: 0, low };\n }\n if (high > 0) {\n // The same positive value for both.\n return { high, low: 0 };\n }\n // No values: high and low are still -Number.MAX_VALUE and Number.MAX_VALUE.\n return { high: 1, low: 0 };\n}\n","/**\n * The compat plugin: 1.x events, `Svg` wrappers and 1.x plugins on v2\n * charts. Opt-in: `plugins: [compat]`, or convert a 1.x plugin with\n * `fromLegacyPlugin()`.\n *\n * Imports only from the package root, so the built `chartist/compat` entry\n * shares the core with `chartist` instead of bundling a copy.\n */\nimport {\n AutoScaleAxis,\n BarChart,\n LineChart,\n PieChart,\n Svg,\n StepAxis,\n axisUnits,\n findAll,\n getHighLow,\n isNumeric,\n normalizeData,\n safeHasProperty,\n serialMap,\n type ChartHandle,\n type ChartPlugin,\n type ChartRect,\n type Data,\n type Layout,\n type PresetState,\n type NormalizedSeries,\n type AxisLabelContext,\n type PieLabelContext,\n type RoleNode,\n type SceneNode\n} from '../index';\nimport { untyped } from '../chart/types';\nimport { nonEmptyRange } from '../core/data/range';\nimport type {\n AnimationEvent,\n AreaDrawEvent,\n AxesDrawEvent,\n BarChartCreatedEvent,\n BarDrawEvent,\n DataEvent,\n LineChartCreatedEvent,\n LineDrawEvent,\n OptionsChangedEvent,\n PieChartCreatedEvent,\n PointDrawEvent,\n SliceDrawEvent,\n SliceLabelDrawEvent\n} from '../index';\n\n// With chartist/compat, the 1.x events are typed on every chart handle.\ndeclare module '../chart/types' {\n interface ChartEvents {\n /**\n * 1.x: the chart's data, before the first render (`type: 'initial'`)\n * and after an update with new data (`type: 'update'`). Listeners can\n * change it in place. Needs the {@link compat} plugin.\n */\n data: DataEvent;\n /**\n * 1.x: the responsive options changed, with the options before and\n * after. Needs the {@link compat} plugin.\n */\n optionsChanged: OptionsChangedEvent;\n /**\n * 1.x: an element was drawn: a grid line, label, point, line, area,\n * bar or slice, with its live `element`. Check `type` to narrow it.\n * Needs the {@link compat} plugin.\n */\n draw:\n | PointDrawEvent\n | LineDrawEvent\n | AreaDrawEvent\n | BarDrawEvent\n | SliceDrawEvent\n | SliceLabelDrawEvent\n | AxesDrawEvent;\n /**\n * 1.x: the chart is drawn and in the DOM, after its `draw` events,\n * with the `svg`, the chart area and the axes. Needs the {@link compat}\n * plugin.\n */\n created:\n | LineChartCreatedEvent\n | BarChartCreatedEvent\n | PieChartCreatedEvent;\n /**\n * 1.x: an SMIL animation began, started with `animate()` on an element\n * of the chart, such as the `element` of a `draw` event. Needs the\n * {@link compat} plugin.\n */\n animationBegin: AnimationEvent;\n /**\n * 1.x: an SMIL animation ended, started with `animate()` on an element\n * of the chart. Needs the {@link compat} plugin.\n */\n animationEnd: AnimationEvent;\n }\n}\n\n/** The 1.x events the compat plugin emits. */\nconst LEGACY_EVENTS = [\n 'data',\n 'optionsChanged',\n 'draw',\n 'created',\n 'animationBegin',\n 'animationEnd'\n] as const;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype LegacyPlugin = (chart: any, options?: any) => void;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyOptions = any;\n\ninterface CompatState {\n preset?: PresetState<Data, AnyOptions>;\n /** The data object of the last `data` event, and its mutable copy. */\n source?: unknown;\n copy?: Data;\n layout?: Layout;\n svg?: Svg;\n /** 1.x chart instances whose `svg` field follows the chart's. */\n instances: { svg?: Svg }[];\n}\n\nconst states = new WeakMap<ChartHandle, CompatState>();\n\n/**\n * Where `Svg#animate()` looks for the emitter of an element's animations\n * when it gets none (on the element or an ancestor). The core reads the\n * same global symbol.\n */\nconst ANIMATION_EMITTER = Symbol.for('chartist.animationEmitter');\n\n/**\n * Where a preset's chart handle holds its preset state from the moment\n * plugins install. The core sets the same global symbol.\n */\nconst PRESET_STATE = Symbol.for('chartist.presetState');\n\n/**\n * Set on the chart handle, so the chart never hands its renderer the\n * previous render: 1.x draw listeners and plugins expect new elements on\n * every render. The core reads the same global symbol.\n */\nconst REPLACES_OUTPUT = Symbol.for('chartist.replacesOutput');\n\nconst presetOf = (handle: ChartHandle) =>\n (handle as { [PRESET_STATE]?: PresetState<Data, AnyOptions> })[PRESET_STATE];\n\n/** The 1.x class of each preset, for 0.x and 1.x type checks in plugins. */\nconst CLASSES: Record<string, { prototype: object }> = {\n line: LineChart,\n bar: BarChart,\n pie: PieChart\n};\n\n/** Copies plain arrays and objects; other values are kept by reference. */\nfunction mutableCopy<T>(value: T): T {\n if (Array.isArray(value)) {\n return value.map(mutableCopy) as T;\n }\n if (value && typeof value === 'object') {\n const proto = Object.getPrototypeOf(value);\n if (proto === Object.prototype || proto === null) {\n return Object.fromEntries(\n Object.entries(value).map(([key, entry]) => [key, mutableCopy(entry)])\n ) as T;\n }\n }\n return value;\n}\n\nconst isLegacyAxisClass = (\n type: unknown\n): type is new (...args: unknown[]) => unknown =>\n typeof type === 'function' &&\n typeof (type as { prototype?: { projectValue?: unknown } }).prototype\n ?.projectValue === 'function';\n\nfunction chartRectOf(layout: Layout): ChartRect {\n const { area, padding } = layout;\n return {\n x1: area.x1,\n x2: area.x2,\n y1: area.y1,\n y2: area.y2,\n padding,\n width() {\n return this.x2 - this.x1;\n },\n height() {\n return this.y1 - this.y2;\n }\n };\n}\n\n/** The 1.x axes, constructed as 1.x `LineChart.createChart` does. */\nfunction lineAxes(options: AnyOptions, data: Data, chartRect: ChartRect) {\n const normalized = normalizeData(\n data as Data<NormalizedSeries[]>,\n options.reverseData,\n true\n );\n const series = normalized.series as NormalizedSeries[];\n const axisX = isLegacyAxisClass(options.axisX.type)\n ? new options.axisX.type(axisUnits.x, series, chartRect, options.axisX)\n : new StepAxis(axisUnits.x, series, chartRect, {\n ...options.axisX,\n ticks: normalized.labels,\n stretch: options.fullWidth\n });\n const axisY = isLegacyAxisClass(options.axisY.type)\n ? new options.axisY.type(axisUnits.y, series, chartRect, options.axisY)\n : new AutoScaleAxis(axisUnits.y, series, chartRect, {\n ...options.axisY,\n high: isNumeric(options.high) ? options.high : options.axisY.high,\n low: isNumeric(options.low) ? options.low : options.axisY.low\n });\n return { axisX, axisY };\n}\n\n/** Sums per index across series, as 1.x `BarChart` stacks them. */\nfunction serialSums(series: NormalizedSeries[]) {\n return serialMap(series, (...values) =>\n values.reduce<{ x: number; y: number }>(\n (sum, value) => ({\n x: sum.x + (safeHasProperty(value, 'x') ? (value.x as number) : 0),\n y: sum.y + (safeHasProperty(value, 'y') ? (value.y as number) : 0)\n }),\n { x: 0, y: 0 }\n )\n );\n}\n\n/** The 1.x axes, constructed as 1.x `BarChart.createChart` does. */\nfunction barAxes(options: AnyOptions, data: Data, chartRect: ChartRect) {\n const horizontal = Boolean(options.horizontalBars);\n const valueDimension = horizontal ? 'x' : 'y';\n const labelDimension = horizontal ? 'y' : 'x';\n const normalized = normalizeData(\n data as Data<NormalizedSeries[]>,\n options.reverseData,\n valueDimension,\n true\n );\n const series = normalized.series as NormalizedSeries[];\n const found =\n options.stackBars && options.stackMode !== true && series.length\n ? getHighLow([serialSums(series)], options, valueDimension)\n : getHighLow(series, options, valueDimension);\n // The chart-level bounds win, but can empty the range again (#1057).\n const highLow = nonEmptyRange({\n high: typeof options.high === 'number' ? options.high : found.high,\n low: typeof options.low === 'number' ? options.low : found.low\n });\n const valueOptions = horizontal ? options.axisX : options.axisY;\n const labelOptions = horizontal ? options.axisY : options.axisX;\n const ValueAxis = isLegacyAxisClass(valueOptions.type)\n ? valueOptions.type\n : AutoScaleAxis;\n const valueAxis = new ValueAxis(\n axisUnits[valueDimension],\n series,\n chartRect,\n {\n ...valueOptions,\n highLow,\n referenceValue: 0\n }\n );\n const labelAxis = isLegacyAxisClass(labelOptions.type)\n ? new labelOptions.type(\n axisUnits[labelDimension],\n series,\n chartRect,\n labelOptions\n )\n : new StepAxis(axisUnits[labelDimension], series, chartRect, {\n ticks:\n options.distributeSeries && options.stackBars\n ? normalized.labels.slice(0, 1)\n : normalized.labels\n });\n return horizontal\n ? { axisX: valueAxis, axisY: labelAxis }\n : { axisX: labelAxis, axisY: valueAxis };\n}\n\nconst AXES: Record<\n string,\n (\n options: AnyOptions,\n data: Data,\n chartRect: ChartRect\n ) => { axisX: unknown; axisY: unknown }\n> = {\n line: lineAxes,\n bar: barAxes,\n // Pie charts have no axes.\n pie: () => ({ axisX: undefined, axisY: undefined })\n};\n\n/** 1.x `draw` payloads in 1.x order, then `created`. */\nfunction emitDrawEvents(\n handle: ChartHandle,\n state: CompatState,\n scene: SceneNode,\n svgElement: Element,\n elementOf: (node: SceneNode) => Element | undefined\n) {\n const options = state.preset?.options as AnyOptions;\n const data = (state.copy ?? state.preset?.data) as Data;\n const chartRect = chartRectOf(state.layout!);\n const { axisX, axisY } = AXES[state.preset!.kind](options, data, chartRect);\n const axisOf = (dimension?: string) => (dimension === 'x' ? axisX : axisY);\n const wrap = (element: Element) => new Svg(element);\n const draw = (payload: Record<string, unknown>) =>\n untyped(handle).emit('draw', payload);\n const parts = (node: SceneNode) => {\n const element = elementOf(node)!;\n return { element: wrap(element), group: wrap(element.parentElement!) };\n };\n\n // Axes: per tick its grid line, then its label, in the order the axes\n // appear in the chart (X first for lines, the label axis first for bars).\n const grids = findAll(scene, { role: 'grid' });\n // Only axis labels; pie labels belong to their slice.\n const allLabels = findAll(scene, { role: 'label' });\n const labels = allLabels.filter(\n (n): n is RoleNode<'label'> & { ctx: AxisLabelContext } =>\n n.ctx.kind === 'axis'\n );\n const sliceLabels = allLabels.filter(\n (n): n is RoleNode<'label'> & { ctx: PieLabelContext } =>\n n.ctx.kind === 'pie'\n );\n const order = [\n ...new Set([...grids, ...labels].map(n => n.ctx.axis.dimension))\n ];\n for (const dimension of order) {\n const onAxis = (node: { ctx: { axis: { dimension: string } } }) =>\n node.ctx.axis.dimension === dimension;\n const indexes = [\n ...new Set([...grids, ...labels].filter(onAxis).map(n => n.ctx.index))\n ].sort((a, b) => a - b);\n for (const index of indexes) {\n const grid = grids.find(n => onAxis(n) && n.ctx.index === index);\n if (grid) {\n const { x1, y1, x2, y2 } = grid.attrs;\n draw({\n type: 'grid',\n axis: axisOf(dimension),\n index,\n ...parts(grid),\n x1,\n y1,\n x2,\n y2\n });\n }\n const label = labels.find(n => onAxis(n) && n.ctx.index === index);\n if (label) {\n const { x, y, width, height } = label.attrs;\n draw({\n type: 'label',\n axis: axisOf(dimension),\n index,\n ...parts(label),\n text: label.ctx.text,\n x,\n y,\n width,\n height\n });\n }\n }\n }\n for (const background of findAll(scene, { role: 'gridBackground' })) {\n draw({ type: 'gridBackground', ...parts(background) });\n }\n\n // Series: points, then the line, then the areas in creation order.\n const rawSeries = (data.series ?? []) as unknown[];\n for (const series of findAll(scene, { role: 'series' })) {\n const seriesIndex = series.ctx.seriesIndex;\n const original =\n rawSeries[\n options.reverseData ? rawSeries.length - 1 - seriesIndex : seriesIndex\n ];\n const common = { series: original, seriesIndex, axisX, axisY };\n const children = series.children;\n const slice = children.find(n => n.role === 'slice');\n if (slice) {\n const ctx = slice.ctx;\n draw({\n type: 'slice',\n value: ctx.value,\n totalDataSum: ctx.totalDataSum,\n index: ctx.index,\n meta: ctx.meta,\n series: ctx.series,\n ...parts(slice),\n path: ctx.path.clone(),\n center: ctx.center,\n radius: ctx.radius,\n startAngle: ctx.startAngle,\n endAngle: ctx.endAngle,\n chartRect\n });\n const label = sliceLabels.find(n => n.ctx.index === ctx.index);\n if (label) {\n const labelCtx = label.ctx;\n draw({\n type: 'label',\n index: labelCtx.index,\n ...parts(label),\n text: labelCtx.text,\n chartRect,\n series: labelCtx.series,\n meta: labelCtx.meta,\n x: labelCtx.x,\n y: labelCtx.y\n });\n }\n continue;\n }\n for (const barNode of children.filter(n => n.role === 'bar')) {\n const ctx = barNode.ctx!;\n draw({\n type: 'bar',\n value: ctx.value,\n index: ctx.valueIndex,\n meta: ctx.meta,\n series: ctx.series,\n seriesIndex,\n axisX,\n axisY,\n chartRect,\n ...parts(barNode),\n x1: ctx.x1,\n y1: ctx.y1,\n x2: ctx.x2,\n y2: ctx.y2\n });\n }\n for (const point of children.filter(n => n.role === 'point')) {\n const ctx = point.ctx!;\n draw({\n type: 'point',\n value: ctx.value,\n index: ctx.valueIndex,\n meta: ctx.meta,\n ...common,\n ...parts(point),\n x: ctx.x,\n y: ctx.y,\n chartRect\n });\n }\n const shapes = [\n ...children.filter(n => n.role === 'line'),\n // Areas are inserted first, so the DOM order is the reverse.\n ...children.filter(n => n.role === 'area').reverse()\n ];\n for (const shape of shapes) {\n const ctx = shape.ctx!;\n draw({\n type: shape.role,\n values: ctx.values,\n path: ctx.path.clone(),\n chartRect,\n index: seriesIndex,\n ...common,\n meta: ctx.meta,\n ...parts(shape)\n });\n }\n }\n\n // 0.x plugins also read `bounds`, the value axis's scale, which 0.x\n // passed next to the axes (auto scale axes only, as in 0.x).\n const valueAxis = options.horizontalBars ? axisX : axisY;\n untyped(handle).emit(\n 'created',\n state.preset!.kind === 'pie'\n ? { chartRect, svg: wrap(svgElement), options }\n : {\n chartRect,\n axisX,\n axisY,\n bounds: (valueAxis as { bounds?: unknown }).bounds,\n svg: wrap(svgElement),\n options\n }\n );\n}\n\n/** Turns the 1.x events on for a chart, once. */\nfunction enable(handle: ChartHandle): CompatState {\n const existing = states.get(handle);\n if (existing) {\n return existing;\n }\n const state: CompatState = { instances: [] };\n states.set(handle, state);\n (handle as { [REPLACES_OUTPUT]?: boolean })[REPLACES_OUTPUT] = true;\n\n handle.on('resolve', ({ config }) => {\n state.preset = config.preset as CompatState['preset'];\n if (config.data !== state.source) {\n // 1.x data handlers mutate the data; they get a copy, and the copy\n // is used from now on (as 1.x keeps its mutated data).\n state.copy = mutableCopy(config.data) as Data;\n untyped(handle).emit('data', {\n type: state.source === undefined ? 'initial' : 'update',\n data: state.copy\n });\n state.source = config.data;\n }\n return { config: { ...config, data: state.copy as typeof config.data } };\n });\n handle.on('layout', layout => {\n state.layout = layout;\n });\n handle.on('responsive', change =>\n 'previousOptions' in change\n ? untyped(handle).emit('optionsChanged', {\n previousOptions: change.previousOptions,\n currentOptions: change.currentOptions\n })\n : undefined\n );\n handle.on('mount', ({ scene, output, elementOf }) => {\n const svg = (output as { svg?: Element }).svg;\n if (!svg) {\n throw new Error('Chartist: the compat plugin requires the DOM renderer');\n }\n state.svg = new Svg(svg);\n // Set before the draw events, so listeners can query the chart.\n for (const instance of state.instances) {\n instance.svg = state.svg;\n }\n // Animations of the chart's elements emit animationBegin and\n // animationEnd on the chart, as 1.x did with the chart's emitter.\n (svg as { [ANIMATION_EMITTER]?: unknown })[ANIMATION_EMITTER] = {\n emit: (event: string, payload: unknown) =>\n untyped(handle).emit(event, payload)\n };\n if (state.preset) {\n emitDrawEvents(handle, state, scene, svg, elementOf);\n }\n });\n return state;\n}\n\n/** 1.x `optionsProvider`: the options in effect, after responsive options. */\nfunction optionsProviderOf(getOptions: () => unknown) {\n return {\n getCurrentOptions: getOptions,\n // The preset watches the media queries and stops on `detach()`.\n removeMediaQueryListeners: () => undefined\n };\n}\n\n/**\n * A 1.x-style chart object for 1.x plugins on the functional API. For a\n * preset it is an instance of the preset's 1.x class (without running its\n * constructor), so type checks such as `chart instanceof LineChart` hold;\n * for `chart()` compositions a plain object.\n */\nfunction legacyChart(handle: ChartHandle, state: CompatState) {\n const preset = presetOf(handle);\n const chart = {\n get container() {\n return handle.container;\n },\n get data() {\n return state.copy ?? preset?.data;\n },\n get options() {\n return preset?.options;\n },\n get svg() {\n return state.svg;\n },\n eventEmitter: {\n on: (event: string, listener: (payload: unknown) => void) =>\n untyped(handle).on(event, listener),\n off: (event: string, listener?: (payload: unknown) => void) =>\n untyped(handle).off(event, listener),\n emit: (event: string, payload: unknown) =>\n untyped(handle).emit(event, payload)\n },\n optionsProvider: optionsProviderOf(() => preset?.options),\n on(event: string, listener: (payload: unknown) => void) {\n untyped(handle).on(event, listener);\n return chart;\n },\n off(event: string, listener?: (payload: unknown) => void) {\n untyped(handle).off(event, listener);\n return chart;\n },\n update(data?: unknown, options?: unknown, override?: boolean) {\n if (preset) {\n preset.update(data as never, options as never, override);\n } else {\n handle.update(data ? { data: data as never } : {});\n }\n return chart;\n },\n detach() {\n if (preset) {\n preset.detach();\n } else {\n handle.detach();\n }\n return chart;\n }\n };\n // The fields above are own properties, so they shadow the class's.\n const type = preset && CLASSES[preset.kind];\n return type ? Object.setPrototypeOf(chart, type.prototype) : chart;\n}\n\n/**\n * Runs a 1.x plugin function as a v2 plugin, with the given chart object.\n * Used by the 1.x chart classes, which pass themselves.\n */\nfunction legacyPlugin(\n plugin: LegacyPlugin,\n options?: unknown,\n chart?: unknown\n): ChartPlugin {\n return {\n name: plugin.name || 'legacy-plugin',\n provides: LEGACY_EVENTS,\n install(handle) {\n const state = enable(handle);\n if (chart) {\n // A 1.x chart instance: keep its `svg` field current, as 1.x did.\n state.instances.push(chart as { svg?: Svg });\n // The 1.x classes run on a preset and have no options provider;\n // plugins call it for the options in effect.\n const instance = chart as { optionsProvider?: unknown };\n if (!instance.optionsProvider) {\n instance.optionsProvider = optionsProviderOf(\n () => presetOf(handle)?.options\n );\n }\n }\n const chartObject = chart ?? legacyChart(handle, state);\n // As 1.x: plugins without options are called with the chart only.\n if (options === undefined) {\n plugin(chartObject);\n } else {\n plugin(chartObject, options);\n }\n }\n };\n}\n\n/**\n * The compat plugin. Restores the 1.x events (`data`, `optionsChanged`,\n * `draw`, `created`, `animationBegin`, `animationEnd`) with 1.x payloads.\n * With it, the 1.x chart classes also run 1.x plugin functions.\n *\n * Add it to `plugins`, of a 1.x class, a preset or `chart()`. The `draw`\n * events come in the 1.x order, right after the chart is in the DOM, so\n * `element` is a live element; then `created`. Animations started with\n * `animate()` on the chart's elements emit `animationBegin` and\n * `animationEnd`. Importing\n * `chartist/compat` also types the 1.x events on every chart handle. It\n * needs the DOM renderer, and the `draw` and `created` events need a\n * chart made by a preset or a 1.x class.\n *\n * @example\n * ```ts\n * import { lineChart } from 'chartist';\n * import { compat } from 'chartist/compat';\n *\n * const chart = lineChart(\n * '#chart',\n * {\n * labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],\n * series: [[12, 9, 7, 8, 5]]\n * },\n * { plugins: [compat] }\n * );\n *\n * // Registered after the first render, so it runs from the next one on.\n * chart.on('draw', data => {\n * if (data.type === 'point' && data.index === 4) {\n * data.element.addClass('is-friday');\n * }\n * });\n * ```\n */\nexport const compat: ChartPlugin & { legacyPlugin: typeof legacyPlugin } = {\n name: 'compat',\n provides: LEGACY_EVENTS,\n install: handle => void enable(handle),\n legacyPlugin\n};\n\n/**\n * Converts a 1.x plugin function into a v2 plugin for `chart()` and the\n * preset functions. It turns the 1.x events on for the chart and calls the\n * plugin with a 1.x-style chart object (`container`, `data`, `options`,\n * `svg`, `eventEmitter`, `on`, `off`, `update`, `detach`). You don't need\n * {@link compat} in the list as well.\n *\n * @param plugin The 1.x plugin: a function that gets the chart (and its\n * options)\n * @param options The plugin's options; without them, the plugin is called\n * with the chart only, as in 1.x\n * @example\n * ```ts\n * import { lineChart, type Plugin } from 'chartist';\n * import { fromLegacyPlugin } from 'chartist/compat';\n *\n * // A 1.x plugin: a function that gets the chart and its options.\n * const caption: Plugin = (chart, options) => {\n * chart.on('created', () => {\n * chart.container.setAttribute('aria-label', options.text);\n * });\n * };\n *\n * lineChart(\n * '#chart',\n * { series: [[1, 3, 2, 4]] },\n * { plugins: [fromLegacyPlugin(caption, { text: 'Visitors per week' })] }\n * );\n * ```\n */\nexport function fromLegacyPlugin(\n plugin: LegacyPlugin,\n options?: unknown\n): ChartPlugin {\n return legacyPlugin(plugin, options);\n}\n\n// The types of the 1.x events and plugins this plugin turns on.\nexport type * from './types';\n","/**\n * The global `Chartist` that plugin scripts of the 0.x and 1.x era read.\n * They register on `Chartist.plugins`, check the chart type with\n * `instanceof Chartist.Line`, and call helpers such as `Chartist.extend`.\n * Importing `chartist/compat` (any build: module, CommonJS or the UMD\n * script) sets this up, so such a script works when it loads after it.\n *\n * The names are added to the global only, never exported: the module\n * builds keep the 1.x and v2 names.\n */\nimport * as core from '../index';\nimport {\n BarChart,\n LineChart,\n PieChart,\n normalizeData,\n type Data\n} from '../index';\n\n/**\n * 0.x: the values of each series as plain numbers (`undefined` for holes),\n * normalized as the 1.x charts do; reversed when `reverse` is true. Line\n * and bar data give an array per series, pie data one array.\n */\nexport function getDataArray(\n data: Data,\n reverse?: boolean\n): (number | undefined)[] | (number | undefined)[][] {\n return normalizeData(data as Data<never>, reverse).series as\n | (number | undefined)[]\n | (number | undefined)[][];\n}\n\n/** The 0.x names plugin scripts use, next to the library's own. */\nconst LEGACY_NAMES = {\n // 0.x names of the chart classes, for `chart instanceof Chartist.Line`.\n Line: LineChart,\n Bar: BarChart,\n Pie: PieChart,\n getDataArray\n};\n\ntype Root = { Chartist?: Record<string, unknown>; document?: unknown };\n\n/**\n * Adds the core, compat and the 0.x names to the global `Chartist`, only\n * what it lacks: a global set by the UMD build or by plugin scripts keeps\n * its values, and `plugins` keeps what scripts registered. If the global\n * belongs to another copy of Chartist (say the UMD build next to these\n * modules), it is left alone with a warning: mixing two copies breaks the\n * plugins' type checks. Outside a browser it does nothing.\n */\nexport function installGlobal(\n compat: Record<string, unknown>,\n root: Root = globalThis as Root\n): void {\n if (root.document === undefined) {\n return;\n }\n const existing = root.Chartist;\n if (existing && 'LineChart' in existing && existing.LineChart !== LineChart) {\n // A hint for developers, as the warnings for 1.x events without compat.\n // eslint-disable-next-line no-console\n console.warn(\n 'Chartist: the global `Chartist` belongs to another copy of Chartist, so chartist/compat leaves it alone. Load Chartist once: as modules, or as the UMD build with compat.umd.js.'\n );\n return;\n }\n const target = existing ?? (root.Chartist = {});\n const add = (name: string, value: unknown) => {\n if (!(name in target)) {\n target[name] = value;\n }\n };\n for (const [name, value] of Object.entries(core)) {\n add(name, value);\n }\n for (const [name, value] of Object.entries(compat)) {\n add(name, value);\n }\n add('plugins', {});\n for (const [name, value] of Object.entries(LEGACY_NAMES)) {\n add(name, value);\n }\n}\n","/**\n * The published entry of `chartist/compat`, in every build. Next to the\n * compat API, importing it sets up the global `Chartist` for plugin\n * scripts of the 0.x and 1.x era (see ./global.ts). That's why\n * package.json lists the compat files under `sideEffects`.\n */\nimport * as compat from './index';\nimport { installGlobal } from './global';\n\nexport * from './index';\n\ninstallGlobal(compat);\n"],"mappings":"u8BA8TA,IAAa8C,EAAW,GACtBC,ECtTF,SAAgBC,EAAc,EAGI,CAChC,GAAM,CAAE,OAAM,OAAQC,EAiBtB,OAhBIC,EA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