chartist 1.5.0 → 2.0.0-rc.1

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.
Files changed (138) hide show
  1. package/README.md +45 -101
  2. package/dist/_settings.scss +1 -89
  3. package/dist/chartist.min.css +2 -0
  4. package/dist/chartist.min.js +2 -0
  5. package/dist/compat.cjs +588 -0
  6. package/dist/compat.cjs.map +1 -0
  7. package/dist/compat.d.cts +119 -0
  8. package/dist/compat.d.ts +118 -0
  9. package/dist/compat.js +567 -0
  10. package/dist/compat.js.map +1 -0
  11. package/dist/compat.min.js +2 -0
  12. package/dist/compat.min.js.map +1 -0
  13. package/dist/compat.umd.js +2 -0
  14. package/dist/compat.umd.js.map +1 -0
  15. package/dist/index.cjs +5592 -3489
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.css +749 -2
  18. package/dist/index.css.map +1 -1
  19. package/dist/index.d.cts +4897 -0
  20. package/dist/index.d.ts +4896 -8
  21. package/dist/index.js +5562 -3484
  22. package/dist/index.js.map +1 -1
  23. package/dist/index.min.css +2 -0
  24. package/dist/index.min.css.map +1 -0
  25. package/dist/index.min.js +2 -0
  26. package/dist/index.min.js.map +1 -0
  27. package/dist/index.scss +1 -204
  28. package/dist/index.umd.js +2 -2
  29. package/dist/index.umd.js.map +1 -1
  30. package/dist/scss/_settings.scss +125 -0
  31. package/dist/scss/index.scss +254 -0
  32. package/dist/scss/themes/accessible.scss +53 -0
  33. package/dist/themes/accessible.css +34 -0
  34. package/dist/themes/accessible.min.css +1 -0
  35. package/package.json +238 -12
  36. package/dist/axes/AutoScaleAxis.d.ts +0 -12
  37. package/dist/axes/AutoScaleAxis.d.ts.map +0 -1
  38. package/dist/axes/Axis.d.ts +0 -40
  39. package/dist/axes/Axis.d.ts.map +0 -1
  40. package/dist/axes/FixedScaleAxis.d.ts +0 -11
  41. package/dist/axes/FixedScaleAxis.d.ts.map +0 -1
  42. package/dist/axes/StepAxis.d.ts +0 -9
  43. package/dist/axes/StepAxis.d.ts.map +0 -1
  44. package/dist/axes/index.d.ts +0 -6
  45. package/dist/axes/index.d.ts.map +0 -1
  46. package/dist/axes/types.d.ts +0 -5
  47. package/dist/axes/types.d.ts.map +0 -1
  48. package/dist/charts/BarChart/BarChart.d.ts +0 -50
  49. package/dist/charts/BarChart/BarChart.d.ts.map +0 -1
  50. package/dist/charts/BarChart/BarChart.types.d.ts +0 -66
  51. package/dist/charts/BarChart/BarChart.types.d.ts.map +0 -1
  52. package/dist/charts/BarChart/index.d.ts +0 -3
  53. package/dist/charts/BarChart/index.d.ts.map +0 -1
  54. package/dist/charts/BaseChart.d.ts +0 -47
  55. package/dist/charts/BaseChart.d.ts.map +0 -1
  56. package/dist/charts/LineChart/LineChart.d.ts +0 -97
  57. package/dist/charts/LineChart/LineChart.d.ts.map +0 -1
  58. package/dist/charts/LineChart/LineChart.types.d.ts +0 -83
  59. package/dist/charts/LineChart/LineChart.types.d.ts.map +0 -1
  60. package/dist/charts/LineChart/index.d.ts +0 -3
  61. package/dist/charts/LineChart/index.d.ts.map +0 -1
  62. package/dist/charts/PieChart/PieChart.d.ts +0 -101
  63. package/dist/charts/PieChart/PieChart.d.ts.map +0 -1
  64. package/dist/charts/PieChart/PieChart.types.d.ts +0 -95
  65. package/dist/charts/PieChart/PieChart.types.d.ts.map +0 -1
  66. package/dist/charts/PieChart/index.d.ts +0 -3
  67. package/dist/charts/PieChart/index.d.ts.map +0 -1
  68. package/dist/charts/index.d.ts +0 -6
  69. package/dist/charts/index.d.ts.map +0 -1
  70. package/dist/charts/types.d.ts +0 -11
  71. package/dist/charts/types.d.ts.map +0 -1
  72. package/dist/core/constants.d.ts +0 -13
  73. package/dist/core/constants.d.ts.map +0 -1
  74. package/dist/core/creation.d.ts +0 -61
  75. package/dist/core/creation.d.ts.map +0 -1
  76. package/dist/core/data/bounds.d.ts +0 -14
  77. package/dist/core/data/bounds.d.ts.map +0 -1
  78. package/dist/core/data/data.d.ts +0 -23
  79. package/dist/core/data/data.d.ts.map +0 -1
  80. package/dist/core/data/highLow.d.ts +0 -13
  81. package/dist/core/data/highLow.d.ts.map +0 -1
  82. package/dist/core/data/index.d.ts +0 -7
  83. package/dist/core/data/index.d.ts.map +0 -1
  84. package/dist/core/data/normalize.d.ts +0 -11
  85. package/dist/core/data/normalize.d.ts.map +0 -1
  86. package/dist/core/data/segments.d.ts +0 -29
  87. package/dist/core/data/segments.d.ts.map +0 -1
  88. package/dist/core/data/serialize.d.ts +0 -12
  89. package/dist/core/data/serialize.d.ts.map +0 -1
  90. package/dist/core/index.d.ts +0 -8
  91. package/dist/core/index.d.ts.map +0 -1
  92. package/dist/core/lang.d.ts +0 -23
  93. package/dist/core/lang.d.ts.map +0 -1
  94. package/dist/core/math.d.ts +0 -42
  95. package/dist/core/math.d.ts.map +0 -1
  96. package/dist/core/optionsProvider.d.ts +0 -15
  97. package/dist/core/optionsProvider.d.ts.map +0 -1
  98. package/dist/core/types.d.ts +0 -274
  99. package/dist/core/types.d.ts.map +0 -1
  100. package/dist/event/EventEmitter.d.ts +0 -27
  101. package/dist/event/EventEmitter.d.ts.map +0 -1
  102. package/dist/event/index.d.ts +0 -2
  103. package/dist/event/index.d.ts.map +0 -1
  104. package/dist/index.d.ts.map +0 -1
  105. package/dist/interpolation/cardinal.d.ts +0 -30
  106. package/dist/interpolation/cardinal.d.ts.map +0 -1
  107. package/dist/interpolation/index.d.ts +0 -6
  108. package/dist/interpolation/index.d.ts.map +0 -1
  109. package/dist/interpolation/monotoneCubic.d.ts +0 -30
  110. package/dist/interpolation/monotoneCubic.d.ts.map +0 -1
  111. package/dist/interpolation/none.d.ts +0 -22
  112. package/dist/interpolation/none.d.ts.map +0 -1
  113. package/dist/interpolation/simple.d.ts +0 -30
  114. package/dist/interpolation/simple.d.ts.map +0 -1
  115. package/dist/interpolation/step.d.ts +0 -26
  116. package/dist/interpolation/step.d.ts.map +0 -1
  117. package/dist/svg/Svg.d.ts +0 -201
  118. package/dist/svg/Svg.d.ts.map +0 -1
  119. package/dist/svg/SvgList.d.ts +0 -31
  120. package/dist/svg/SvgList.d.ts.map +0 -1
  121. package/dist/svg/SvgPath.d.ts +0 -125
  122. package/dist/svg/SvgPath.d.ts.map +0 -1
  123. package/dist/svg/animation.d.ts +0 -37
  124. package/dist/svg/animation.d.ts.map +0 -1
  125. package/dist/svg/index.d.ts +0 -6
  126. package/dist/svg/index.d.ts.map +0 -1
  127. package/dist/svg/types.d.ts +0 -55
  128. package/dist/svg/types.d.ts.map +0 -1
  129. package/dist/utils/extend.d.ts +0 -10
  130. package/dist/utils/extend.d.ts.map +0 -1
  131. package/dist/utils/functional.d.ts +0 -31
  132. package/dist/utils/functional.d.ts.map +0 -1
  133. package/dist/utils/index.d.ts +0 -5
  134. package/dist/utils/index.d.ts.map +0 -1
  135. package/dist/utils/types.d.ts +0 -7
  136. package/dist/utils/types.d.ts.map +0 -1
  137. package/dist/utils/utils.d.ts +0 -31
  138. package/dist/utils/utils.d.ts.map +0 -1
package/dist/compat.js ADDED
@@ -0,0 +1,567 @@
1
+ import * as core from "./index.js";
2
+ import { AutoScaleAxis, BarChart, LineChart, PieChart, StepAxis, Svg, axisUnits, findAll, getHighLow, isNumeric, normalizeData, safeHasProperty, serialMap } from "./index.js";
3
+ //#region \0rolldown/runtime.js
4
+ var __defProp = Object.defineProperty;
5
+ var __exportAll = (all, no_symbols) => {
6
+ let target = {};
7
+ for (var name in all) __defProp(target, name, {
8
+ get: all[name],
9
+ enumerable: true
10
+ });
11
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
12
+ return target;
13
+ };
14
+ //#endregion
15
+ //#region src/chart/types.ts
16
+ /** The same handle, seen without event typing. Internal. */
17
+ const untyped = (handle) => handle;
18
+ //#endregion
19
+ //#region src/compat/index.ts
20
+ /**
21
+ * The compat plugin: 1.x events, `Svg` wrappers and 1.x plugins on v2
22
+ * charts. Opt-in: `plugins: [compat]`, or convert a 1.x plugin with
23
+ * `fromLegacyPlugin()`.
24
+ *
25
+ * Imports only from the package root, so the built `chartist/compat` entry
26
+ * shares the core with `chartist` instead of bundling a copy.
27
+ */
28
+ var compat_exports = /* @__PURE__ */ __exportAll({
29
+ compat: () => compat,
30
+ fromLegacyPlugin: () => fromLegacyPlugin
31
+ });
32
+ /** The 1.x events the compat plugin emits. */
33
+ const LEGACY_EVENTS = [
34
+ "data",
35
+ "optionsChanged",
36
+ "draw",
37
+ "created",
38
+ "animationBegin",
39
+ "animationEnd"
40
+ ];
41
+ const states = /* @__PURE__ */ new WeakMap();
42
+ /**
43
+ * Where `Svg#animate()` looks for the emitter of an element's animations
44
+ * when it gets none (on the element or an ancestor). The core reads the
45
+ * same global symbol.
46
+ */
47
+ const ANIMATION_EMITTER = Symbol.for("chartist.animationEmitter");
48
+ /**
49
+ * Where a preset's chart handle holds its preset state from the moment
50
+ * plugins install. The core sets the same global symbol.
51
+ */
52
+ const PRESET_STATE = Symbol.for("chartist.presetState");
53
+ const presetOf = (handle) => handle[PRESET_STATE];
54
+ /** The 1.x class of each preset, for 0.x and 1.x type checks in plugins. */
55
+ const CLASSES = {
56
+ line: LineChart,
57
+ bar: BarChart,
58
+ pie: PieChart
59
+ };
60
+ /** Copies plain arrays and objects; other values are kept by reference. */
61
+ function mutableCopy(value) {
62
+ if (Array.isArray(value)) return value.map(mutableCopy);
63
+ if (value && typeof value === "object") {
64
+ const proto = Object.getPrototypeOf(value);
65
+ if (proto === Object.prototype || proto === null) return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, mutableCopy(entry)]));
66
+ }
67
+ return value;
68
+ }
69
+ const isLegacyAxisClass = (type) => typeof type === "function" && typeof type.prototype?.projectValue === "function";
70
+ function chartRectOf(layout) {
71
+ const { area, padding } = layout;
72
+ return {
73
+ x1: area.x1,
74
+ x2: area.x2,
75
+ y1: area.y1,
76
+ y2: area.y2,
77
+ padding,
78
+ width() {
79
+ return this.x2 - this.x1;
80
+ },
81
+ height() {
82
+ return this.y1 - this.y2;
83
+ }
84
+ };
85
+ }
86
+ /** The 1.x axes, constructed as 1.x `LineChart.createChart` does. */
87
+ function lineAxes(options, data, chartRect) {
88
+ const normalized = normalizeData(data, options.reverseData, true);
89
+ const series = normalized.series;
90
+ return {
91
+ axisX: isLegacyAxisClass(options.axisX.type) ? new options.axisX.type(axisUnits.x, series, chartRect, options.axisX) : new StepAxis(axisUnits.x, series, chartRect, {
92
+ ...options.axisX,
93
+ ticks: normalized.labels,
94
+ stretch: options.fullWidth
95
+ }),
96
+ axisY: isLegacyAxisClass(options.axisY.type) ? new options.axisY.type(axisUnits.y, series, chartRect, options.axisY) : new AutoScaleAxis(axisUnits.y, series, chartRect, {
97
+ ...options.axisY,
98
+ high: isNumeric(options.high) ? options.high : options.axisY.high,
99
+ low: isNumeric(options.low) ? options.low : options.axisY.low
100
+ })
101
+ };
102
+ }
103
+ /** Sums per index across series, as 1.x `BarChart` stacks them. */
104
+ function serialSums(series) {
105
+ return serialMap(series, (...values) => values.reduce((sum, value) => ({
106
+ x: sum.x + (safeHasProperty(value, "x") ? value.x : 0),
107
+ y: sum.y + (safeHasProperty(value, "y") ? value.y : 0)
108
+ }), {
109
+ x: 0,
110
+ y: 0
111
+ }));
112
+ }
113
+ /** The 1.x axes, constructed as 1.x `BarChart.createChart` does. */
114
+ function barAxes(options, data, chartRect) {
115
+ const horizontal = Boolean(options.horizontalBars);
116
+ const valueDimension = horizontal ? "x" : "y";
117
+ const labelDimension = horizontal ? "y" : "x";
118
+ const normalized = normalizeData(data, options.reverseData, valueDimension, true);
119
+ const series = normalized.series;
120
+ const highLow = options.stackBars && options.stackMode !== true && series.length ? getHighLow([serialSums(series)], options, valueDimension) : getHighLow(series, options, valueDimension);
121
+ if (typeof options.high === "number") highLow.high = options.high;
122
+ if (typeof options.low === "number") highLow.low = options.low;
123
+ const valueOptions = horizontal ? options.axisX : options.axisY;
124
+ const labelOptions = horizontal ? options.axisY : options.axisX;
125
+ const valueAxis = new (isLegacyAxisClass(valueOptions.type) ? valueOptions.type : AutoScaleAxis)(axisUnits[valueDimension], series, chartRect, {
126
+ ...valueOptions,
127
+ highLow,
128
+ referenceValue: 0
129
+ });
130
+ const labelAxis = isLegacyAxisClass(labelOptions.type) ? new labelOptions.type(axisUnits[labelDimension], series, chartRect, labelOptions) : new StepAxis(axisUnits[labelDimension], series, chartRect, { ticks: options.distributeSeries && options.stackBars ? normalized.labels.slice(0, 1) : normalized.labels });
131
+ return horizontal ? {
132
+ axisX: valueAxis,
133
+ axisY: labelAxis
134
+ } : {
135
+ axisX: labelAxis,
136
+ axisY: valueAxis
137
+ };
138
+ }
139
+ const AXES = {
140
+ line: lineAxes,
141
+ bar: barAxes,
142
+ pie: () => ({
143
+ axisX: void 0,
144
+ axisY: void 0
145
+ })
146
+ };
147
+ /** 1.x `draw` payloads in 1.x order, then `created`. */
148
+ function emitDrawEvents(handle, state, scene, svgElement, elementOf) {
149
+ const options = state.preset?.options;
150
+ const data = state.copy ?? state.preset?.data;
151
+ const chartRect = chartRectOf(state.layout);
152
+ const { axisX, axisY } = AXES[state.preset.kind](options, data, chartRect);
153
+ const axisOf = (dimension) => dimension === "x" ? axisX : axisY;
154
+ const wrap = (element) => new Svg(element);
155
+ const draw = (payload) => untyped(handle).emit("draw", payload);
156
+ const parts = (node) => {
157
+ const element = elementOf(node);
158
+ return {
159
+ element: wrap(element),
160
+ group: wrap(element.parentElement)
161
+ };
162
+ };
163
+ const grids = findAll(scene, { role: "grid" });
164
+ const allLabels = findAll(scene, { role: "label" });
165
+ const labels = allLabels.filter((n) => n.ctx.kind === "axis");
166
+ const sliceLabels = allLabels.filter((n) => n.ctx.kind === "pie");
167
+ const order = [...new Set([...grids, ...labels].map((n) => n.ctx.axis.dimension))];
168
+ for (const dimension of order) {
169
+ const onAxis = (node) => node.ctx.axis.dimension === dimension;
170
+ const indexes = [...new Set([...grids, ...labels].filter(onAxis).map((n) => n.ctx.index))].sort((a, b) => a - b);
171
+ for (const index of indexes) {
172
+ const grid = grids.find((n) => onAxis(n) && n.ctx.index === index);
173
+ if (grid) {
174
+ const { x1, y1, x2, y2 } = grid.attrs;
175
+ draw({
176
+ type: "grid",
177
+ axis: axisOf(dimension),
178
+ index,
179
+ ...parts(grid),
180
+ x1,
181
+ y1,
182
+ x2,
183
+ y2
184
+ });
185
+ }
186
+ const label = labels.find((n) => onAxis(n) && n.ctx.index === index);
187
+ if (label) {
188
+ const { x, y, width, height } = label.attrs;
189
+ draw({
190
+ type: "label",
191
+ axis: axisOf(dimension),
192
+ index,
193
+ ...parts(label),
194
+ text: label.ctx.text,
195
+ x,
196
+ y,
197
+ width,
198
+ height
199
+ });
200
+ }
201
+ }
202
+ }
203
+ for (const background of findAll(scene, { role: "gridBackground" })) draw({
204
+ type: "gridBackground",
205
+ ...parts(background)
206
+ });
207
+ const rawSeries = data.series ?? [];
208
+ for (const series of findAll(scene, { role: "series" })) {
209
+ const seriesIndex = series.ctx.seriesIndex;
210
+ const common = {
211
+ series: rawSeries[options.reverseData ? rawSeries.length - 1 - seriesIndex : seriesIndex],
212
+ seriesIndex,
213
+ axisX,
214
+ axisY
215
+ };
216
+ const children = series.children;
217
+ const slice = children.find((n) => n.role === "slice");
218
+ if (slice) {
219
+ const ctx = slice.ctx;
220
+ draw({
221
+ type: "slice",
222
+ value: ctx.value,
223
+ totalDataSum: ctx.totalDataSum,
224
+ index: ctx.index,
225
+ meta: ctx.meta,
226
+ series: ctx.series,
227
+ ...parts(slice),
228
+ path: ctx.path.clone(),
229
+ center: ctx.center,
230
+ radius: ctx.radius,
231
+ startAngle: ctx.startAngle,
232
+ endAngle: ctx.endAngle,
233
+ chartRect
234
+ });
235
+ const label = sliceLabels.find((n) => n.ctx.index === ctx.index);
236
+ if (label) {
237
+ const labelCtx = label.ctx;
238
+ draw({
239
+ type: "label",
240
+ index: labelCtx.index,
241
+ ...parts(label),
242
+ text: labelCtx.text,
243
+ chartRect,
244
+ series: labelCtx.series,
245
+ meta: labelCtx.meta,
246
+ x: labelCtx.x,
247
+ y: labelCtx.y
248
+ });
249
+ }
250
+ continue;
251
+ }
252
+ for (const barNode of children.filter((n) => n.role === "bar")) {
253
+ const ctx = barNode.ctx;
254
+ draw({
255
+ type: "bar",
256
+ value: ctx.value,
257
+ index: ctx.valueIndex,
258
+ meta: ctx.meta,
259
+ series: ctx.series,
260
+ seriesIndex,
261
+ axisX,
262
+ axisY,
263
+ chartRect,
264
+ ...parts(barNode),
265
+ x1: ctx.x1,
266
+ y1: ctx.y1,
267
+ x2: ctx.x2,
268
+ y2: ctx.y2
269
+ });
270
+ }
271
+ for (const point of children.filter((n) => n.role === "point")) {
272
+ const ctx = point.ctx;
273
+ draw({
274
+ type: "point",
275
+ value: ctx.value,
276
+ index: ctx.valueIndex,
277
+ meta: ctx.meta,
278
+ ...common,
279
+ ...parts(point),
280
+ x: ctx.x,
281
+ y: ctx.y,
282
+ chartRect
283
+ });
284
+ }
285
+ const shapes = [...children.filter((n) => n.role === "line"), ...children.filter((n) => n.role === "area").reverse()];
286
+ for (const shape of shapes) {
287
+ const ctx = shape.ctx;
288
+ draw({
289
+ type: shape.role,
290
+ values: ctx.values,
291
+ path: ctx.path.clone(),
292
+ chartRect,
293
+ index: seriesIndex,
294
+ ...common,
295
+ meta: ctx.meta,
296
+ ...parts(shape)
297
+ });
298
+ }
299
+ }
300
+ const valueAxis = options.horizontalBars ? axisX : axisY;
301
+ untyped(handle).emit("created", state.preset.kind === "pie" ? {
302
+ chartRect,
303
+ svg: wrap(svgElement),
304
+ options
305
+ } : {
306
+ chartRect,
307
+ axisX,
308
+ axisY,
309
+ bounds: valueAxis.bounds,
310
+ svg: wrap(svgElement),
311
+ options
312
+ });
313
+ }
314
+ /** Turns the 1.x events on for a chart, once. */
315
+ function enable(handle) {
316
+ const existing = states.get(handle);
317
+ if (existing) return existing;
318
+ const state = { instances: [] };
319
+ states.set(handle, state);
320
+ handle.on("resolve", ({ config }) => {
321
+ state.preset = config.preset;
322
+ if (config.data !== state.source) {
323
+ state.copy = mutableCopy(config.data);
324
+ untyped(handle).emit("data", {
325
+ type: state.source === void 0 ? "initial" : "update",
326
+ data: state.copy
327
+ });
328
+ state.source = config.data;
329
+ }
330
+ return { config: {
331
+ ...config,
332
+ data: state.copy
333
+ } };
334
+ });
335
+ handle.on("layout", (layout) => {
336
+ state.layout = layout;
337
+ });
338
+ handle.on("responsive", (change) => "previousOptions" in change ? untyped(handle).emit("optionsChanged", {
339
+ previousOptions: change.previousOptions,
340
+ currentOptions: change.currentOptions
341
+ }) : void 0);
342
+ handle.on("mount", ({ scene, output, elementOf }) => {
343
+ const svg = output.svg;
344
+ if (!svg) throw new Error("Chartist: the compat plugin requires the DOM renderer");
345
+ state.svg = new Svg(svg);
346
+ for (const instance of state.instances) instance.svg = state.svg;
347
+ svg[ANIMATION_EMITTER] = { emit: (event, payload) => untyped(handle).emit(event, payload) };
348
+ if (state.preset) emitDrawEvents(handle, state, scene, svg, elementOf);
349
+ });
350
+ return state;
351
+ }
352
+ /** 1.x `optionsProvider`: the options in effect, after responsive options. */
353
+ function optionsProviderOf(getOptions) {
354
+ return {
355
+ getCurrentOptions: getOptions,
356
+ removeMediaQueryListeners: () => void 0
357
+ };
358
+ }
359
+ /**
360
+ * A 1.x-style chart object for 1.x plugins on the functional API. For a
361
+ * preset it is an instance of the preset's 1.x class (without running its
362
+ * constructor), so type checks such as `chart instanceof LineChart` hold;
363
+ * for `chart()` compositions a plain object.
364
+ */
365
+ function legacyChart(handle, state) {
366
+ const preset = presetOf(handle);
367
+ const chart = {
368
+ get container() {
369
+ return handle.container;
370
+ },
371
+ get data() {
372
+ return state.copy ?? preset?.data;
373
+ },
374
+ get options() {
375
+ return preset?.options;
376
+ },
377
+ get svg() {
378
+ return state.svg;
379
+ },
380
+ eventEmitter: {
381
+ on: (event, listener) => untyped(handle).on(event, listener),
382
+ off: (event, listener) => untyped(handle).off(event, listener),
383
+ emit: (event, payload) => untyped(handle).emit(event, payload)
384
+ },
385
+ optionsProvider: optionsProviderOf(() => preset?.options),
386
+ on(event, listener) {
387
+ untyped(handle).on(event, listener);
388
+ return chart;
389
+ },
390
+ off(event, listener) {
391
+ untyped(handle).off(event, listener);
392
+ return chart;
393
+ },
394
+ update(data, options, override) {
395
+ if (preset) preset.update(data, options, override);
396
+ else handle.update(data ? { data } : {});
397
+ return chart;
398
+ },
399
+ detach() {
400
+ if (preset) preset.detach();
401
+ else handle.detach();
402
+ return chart;
403
+ }
404
+ };
405
+ const type = preset && CLASSES[preset.kind];
406
+ return type ? Object.setPrototypeOf(chart, type.prototype) : chart;
407
+ }
408
+ /**
409
+ * Runs a 1.x plugin function as a v2 plugin, with the given chart object.
410
+ * Used by the 1.x chart classes, which pass themselves.
411
+ */
412
+ function legacyPlugin(plugin, options, chart) {
413
+ return {
414
+ name: plugin.name || "legacy-plugin",
415
+ provides: LEGACY_EVENTS,
416
+ install(handle) {
417
+ const state = enable(handle);
418
+ if (chart) {
419
+ state.instances.push(chart);
420
+ const instance = chart;
421
+ if (!instance.optionsProvider) instance.optionsProvider = optionsProviderOf(() => presetOf(handle)?.options);
422
+ }
423
+ const chartObject = chart ?? legacyChart(handle, state);
424
+ if (options === void 0) plugin(chartObject);
425
+ else plugin(chartObject, options);
426
+ }
427
+ };
428
+ }
429
+ /**
430
+ * The compat plugin. Restores the 1.x events (`data`, `optionsChanged`,
431
+ * `draw`, `created`, `animationBegin`, `animationEnd`) with 1.x payloads.
432
+ * With it, the 1.x chart classes also run 1.x plugin functions.
433
+ *
434
+ * Add it to `plugins`, of a 1.x class, a preset or `chart()`. The `draw`
435
+ * events come in the 1.x order, right after the chart is in the DOM, so
436
+ * `element` is a live element; then `created`. Animations started with
437
+ * `animate()` on the chart's elements emit `animationBegin` and
438
+ * `animationEnd`. Importing
439
+ * `chartist/compat` also types the 1.x events on every chart handle. It
440
+ * needs the DOM renderer, and the `draw` and `created` events need a
441
+ * chart made by a preset or a 1.x class.
442
+ *
443
+ * @example
444
+ * ```ts
445
+ * import { lineChart } from 'chartist';
446
+ * import { compat } from 'chartist/compat';
447
+ *
448
+ * const chart = lineChart(
449
+ * '#chart',
450
+ * {
451
+ * labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
452
+ * series: [[12, 9, 7, 8, 5]]
453
+ * },
454
+ * { plugins: [compat] }
455
+ * );
456
+ *
457
+ * // Registered after the first render, so it runs from the next one on.
458
+ * chart.on('draw', data => {
459
+ * if (data.type === 'point' && data.index === 4) {
460
+ * data.element.addClass('is-friday');
461
+ * }
462
+ * });
463
+ * ```
464
+ */
465
+ const compat = {
466
+ name: "compat",
467
+ provides: LEGACY_EVENTS,
468
+ install: (handle) => void enable(handle),
469
+ legacyPlugin
470
+ };
471
+ /**
472
+ * Converts a 1.x plugin function into a v2 plugin for `chart()` and the
473
+ * preset functions. It turns the 1.x events on for the chart and calls the
474
+ * plugin with a 1.x-style chart object (`container`, `data`, `options`,
475
+ * `svg`, `eventEmitter`, `on`, `off`, `update`, `detach`). You don't need
476
+ * {@link compat} in the list as well.
477
+ *
478
+ * @param plugin The 1.x plugin: a function that gets the chart (and its
479
+ * options)
480
+ * @param options The plugin's options; without them, the plugin is called
481
+ * with the chart only, as in 1.x
482
+ * @example
483
+ * ```ts
484
+ * import { lineChart, type Plugin } from 'chartist';
485
+ * import { fromLegacyPlugin } from 'chartist/compat';
486
+ *
487
+ * // A 1.x plugin: a function that gets the chart and its options.
488
+ * const caption: Plugin = (chart, options) => {
489
+ * chart.on('created', () => {
490
+ * chart.container.setAttribute('aria-label', options.text);
491
+ * });
492
+ * };
493
+ *
494
+ * lineChart(
495
+ * '#chart',
496
+ * { series: [[1, 3, 2, 4]] },
497
+ * { plugins: [fromLegacyPlugin(caption, { text: 'Visitors per week' })] }
498
+ * );
499
+ * ```
500
+ */
501
+ function fromLegacyPlugin(plugin, options) {
502
+ return legacyPlugin(plugin, options);
503
+ }
504
+ //#endregion
505
+ //#region src/compat/global.ts
506
+ /**
507
+ * The global `Chartist` that plugin scripts of the 0.x and 1.x era read.
508
+ * They register on `Chartist.plugins`, check the chart type with
509
+ * `instanceof Chartist.Line`, and call helpers such as `Chartist.extend`.
510
+ * Importing `chartist/compat` (any build: module, CommonJS or the UMD
511
+ * script) sets this up, so such a script works when it loads after it.
512
+ *
513
+ * The names are added to the global only, never exported: the module
514
+ * builds keep the 1.x and v2 names.
515
+ */
516
+ /**
517
+ * 0.x: the values of each series as plain numbers (`undefined` for holes),
518
+ * normalized as the 1.x charts do; reversed when `reverse` is true. Line
519
+ * and bar data give an array per series, pie data one array.
520
+ */
521
+ function getDataArray(data, reverse) {
522
+ return normalizeData(data, reverse).series;
523
+ }
524
+ /** The 0.x names plugin scripts use, next to the library's own. */
525
+ const LEGACY_NAMES = {
526
+ Line: LineChart,
527
+ Bar: BarChart,
528
+ Pie: PieChart,
529
+ getDataArray
530
+ };
531
+ /**
532
+ * Adds the core, compat and the 0.x names to the global `Chartist`, only
533
+ * what it lacks: a global set by the UMD build or by plugin scripts keeps
534
+ * its values, and `plugins` keeps what scripts registered. If the global
535
+ * belongs to another copy of Chartist (say the UMD build next to these
536
+ * modules), it is left alone with a warning: mixing two copies breaks the
537
+ * plugins' type checks. Outside a browser it does nothing.
538
+ */
539
+ function installGlobal(compat, root = globalThis) {
540
+ if (root.document === void 0) return;
541
+ const existing = root.Chartist;
542
+ if (existing && "LineChart" in existing && existing.LineChart !== LineChart) {
543
+ 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.");
544
+ return;
545
+ }
546
+ const target = existing ?? (root.Chartist = {});
547
+ const add = (name, value) => {
548
+ if (!(name in target)) target[name] = value;
549
+ };
550
+ for (const [name, value] of Object.entries(core)) add(name, value);
551
+ for (const [name, value] of Object.entries(compat)) add(name, value);
552
+ add("plugins", {});
553
+ for (const [name, value] of Object.entries(LEGACY_NAMES)) add(name, value);
554
+ }
555
+ //#endregion
556
+ //#region src/compat/entry.ts
557
+ /**
558
+ * The published entry of `chartist/compat`, in every build. Next to the
559
+ * compat API, importing it sets up the global `Chartist` for plugin
560
+ * scripts of the 0.x and 1.x era (see ./global.ts). That's why
561
+ * package.json lists the compat files under `sideEffects`.
562
+ */
563
+ installGlobal(compat_exports);
564
+ //#endregion
565
+ export { compat, fromLegacyPlugin };
566
+
567
+ //# sourceMappingURL=compat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compat.js","names":["compat"],"sources":["../src/chart/types.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 * 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 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 highLow =\n options.stackBars && options.stackMode !== true && series.length\n ? getHighLow([serialSums(series)], options, valueDimension)\n : getHighLow(series, options, valueDimension);\n if (typeof options.high === 'number') {\n highLow.high = options.high;\n }\n if (typeof options.low === 'number') {\n highLow.low = options.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 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":";;;;;;;;;;;;;;;;AAoRA,MAAa,WAAW,WACtB;;;;;;;;;;;;;;;;AC/KF,MAAM,gBAAgB;CACpB;CACA;CACA;CACA;CACA;CACA;AACF;AAkBA,MAAM,yBAAS,IAAI,QAAkC;;;;;;AAOrD,MAAM,oBAAoB,OAAO,IAAI,2BAA2B;;;;;AAMhE,MAAM,eAAe,OAAO,IAAI,sBAAsB;AAEtD,MAAM,YAAY,WACf,OAA8D;;AAGjE,MAAM,UAAiD;CACrD,MAAM;CACN,KAAK;CACL,KAAK;AACP;;AAGA,SAAS,YAAe,OAAa;CACnC,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,IAAI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