manim-web 0.25.0 → 0.27.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/dist/animation/text/index.d.ts +2 -0
- package/dist/animation/text/index.d.ts.map +1 -0
- package/dist/animation/text/kineticTypography.d.ts +144 -0
- package/dist/animation/text/kineticTypography.d.ts.map +1 -0
- package/dist/audio/MidiInput.d.ts +159 -0
- package/dist/audio/MidiInput.d.ts.map +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/integrations/notebook.d.ts +117 -0
- package/dist/integrations/notebook.d.ts.map +1 -0
- package/dist/integrations/notebook.js +60 -0
- package/dist/integrations/react.js +16 -16
- package/dist/integrations/vue.js +13 -13
- package/dist/manim-web.browser.js +9638 -7586
- package/dist/mobjects/graphing/AreaChart.d.ts +101 -0
- package/dist/mobjects/graphing/AreaChart.d.ts.map +1 -0
- package/dist/mobjects/graphing/CalendarHeatmap.d.ts +111 -0
- package/dist/mobjects/graphing/CalendarHeatmap.d.ts.map +1 -0
- package/dist/mobjects/graphing/ChordDiagram.d.ts +122 -0
- package/dist/mobjects/graphing/ChordDiagram.d.ts.map +1 -0
- package/dist/mobjects/graphing/GanttChart.d.ts +179 -0
- package/dist/mobjects/graphing/GanttChart.d.ts.map +1 -0
- package/dist/mobjects/graphing/RadarChart.d.ts +135 -0
- package/dist/mobjects/graphing/RadarChart.d.ts.map +1 -0
- package/dist/mobjects/graphing/StackedBarChart.d.ts +131 -0
- package/dist/mobjects/graphing/StackedBarChart.d.ts.map +1 -0
- package/dist/mobjects/graphing/StepChart.d.ts +90 -0
- package/dist/mobjects/graphing/StepChart.d.ts.map +1 -0
- package/dist/mobjects/graphing/Treemap.d.ts +100 -0
- package/dist/mobjects/graphing/Treemap.d.ts.map +1 -0
- package/dist/mobjects/graphing/WaterfallChart.d.ts +164 -0
- package/dist/mobjects/graphing/WaterfallChart.d.ts.map +1 -0
- package/dist/mobjects/graphing/chartColors.d.ts +18 -0
- package/dist/mobjects/graphing/chartColors.d.ts.map +1 -0
- package/dist/mobjects/graphing/chordLayout.d.ts +89 -0
- package/dist/mobjects/graphing/chordLayout.d.ts.map +1 -0
- package/dist/mobjects/graphing/ganttLayout.d.ts +36 -0
- package/dist/mobjects/graphing/ganttLayout.d.ts.map +1 -0
- package/dist/mobjects/graphing/index.d.ts +12 -0
- package/dist/mobjects/graphing/index.d.ts.map +1 -1
- package/dist/mobjects/graphing/treemapLayout.d.ts +83 -0
- package/dist/mobjects/graphing/treemapLayout.d.ts.map +1 -0
- package/dist/{src-Dq6hmMfV.js → src-C3q2JQb_.js} +4054 -2002
- package/package.json +6 -1
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { VGroup } from '../../core/VGroup';
|
|
2
|
+
import { Vector3Tuple } from '../../core/Mobject';
|
|
3
|
+
import { Polygon } from '../geometry/Polygon';
|
|
4
|
+
/**
|
|
5
|
+
* Options for creating a RadarChart.
|
|
6
|
+
*/
|
|
7
|
+
export interface RadarChartOptions {
|
|
8
|
+
/** Values per category. One series is number[], several series are number[][]. */
|
|
9
|
+
data: number[] | number[][];
|
|
10
|
+
/** Axis (category) labels, one per axis. Default: [] */
|
|
11
|
+
categories?: string[];
|
|
12
|
+
/** Value that reaches the outer ring. Default: the largest value in the data. */
|
|
13
|
+
maxValue?: number;
|
|
14
|
+
/** Radius of the outer ring. Default: 3 */
|
|
15
|
+
radius?: number;
|
|
16
|
+
/** Number of concentric grid rings. Default: 5 */
|
|
17
|
+
numRings?: number;
|
|
18
|
+
/** Color per series. Single color applies to all, array cycles. Default: Manim palette. */
|
|
19
|
+
seriesColors?: string | string[];
|
|
20
|
+
/** Fill opacity of each series polygon. Default: 0.3 */
|
|
21
|
+
fillOpacity?: number;
|
|
22
|
+
/** Stroke width of each series polygon. Default: 3 */
|
|
23
|
+
strokeWidth?: number;
|
|
24
|
+
/** Whether to draw the rings and spokes. Default: true */
|
|
25
|
+
showGrid?: boolean;
|
|
26
|
+
/** Whether to draw the category labels. Default: true */
|
|
27
|
+
showLabels?: boolean;
|
|
28
|
+
/** Font size for the category labels. Default: 20 */
|
|
29
|
+
labelFontSize?: number;
|
|
30
|
+
/** Color for the grid rings, spokes and labels. Default: gray. */
|
|
31
|
+
gridColor?: string;
|
|
32
|
+
/** Angle of the first axis in radians. Default: Math.PI / 2 (straight up). */
|
|
33
|
+
startAngle?: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* RadarChart - A radar (spider) chart mobject.
|
|
37
|
+
*
|
|
38
|
+
* Draws N axes that radiate from a shared center, one per category, spaced at
|
|
39
|
+
* 2*pi/N. Each value is plotted at a radius proportional to the value along its
|
|
40
|
+
* axis, and the points of a series connect into a closed polygon. Several series
|
|
41
|
+
* overlay on the same axes, each with its own color and a semi-transparent fill.
|
|
42
|
+
*
|
|
43
|
+
* Negative values clamp to the center (radius 0). A value equal to maxValue sits
|
|
44
|
+
* on the outer ring.
|
|
45
|
+
*
|
|
46
|
+
* The chart is a VGroup, so Create and FadeIn animate it directly.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const chart = new RadarChart({
|
|
51
|
+
* data: [
|
|
52
|
+
* [4, 2, 5, 1, 3],
|
|
53
|
+
* [1, 5, 2, 4, 2],
|
|
54
|
+
* ],
|
|
55
|
+
* categories: ['Speed', 'Power', 'Range', 'Cost', 'Weight'],
|
|
56
|
+
* });
|
|
57
|
+
* scene.play(new Create(chart));
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare class RadarChart extends VGroup {
|
|
61
|
+
/** The concentric grid rings. */
|
|
62
|
+
grid: VGroup;
|
|
63
|
+
/** The axis spoke lines, one per category. */
|
|
64
|
+
axes: VGroup;
|
|
65
|
+
/** The series polygons. */
|
|
66
|
+
series: VGroup;
|
|
67
|
+
/** The category labels. */
|
|
68
|
+
labels: VGroup;
|
|
69
|
+
protected _series: number[][];
|
|
70
|
+
protected _categories: string[];
|
|
71
|
+
protected _maxValue: number;
|
|
72
|
+
protected _radius: number;
|
|
73
|
+
protected _numRings: number;
|
|
74
|
+
protected _seriesColors: string[];
|
|
75
|
+
protected _fillOpacity: number;
|
|
76
|
+
protected _strokeWidth: number;
|
|
77
|
+
protected _showGrid: boolean;
|
|
78
|
+
protected _showLabels: boolean;
|
|
79
|
+
protected _labelFontSize: number;
|
|
80
|
+
protected _gridColor: string;
|
|
81
|
+
protected _startAngle: number;
|
|
82
|
+
constructor(options: RadarChartOptions);
|
|
83
|
+
/** Normalize data to a 2D array (series x categories). */
|
|
84
|
+
private _normalizeData;
|
|
85
|
+
/** Largest value across all series, or 1 when nothing is positive. */
|
|
86
|
+
private _autoMaxValue;
|
|
87
|
+
/** Number of axes (categories). */
|
|
88
|
+
private get _numAxes();
|
|
89
|
+
/** Color for series s, cycling through the palette. */
|
|
90
|
+
private _seriesColor;
|
|
91
|
+
/**
|
|
92
|
+
* Angle in radians of axis k, measured from the positive x-axis.
|
|
93
|
+
* Axes are spaced 2*pi/N counter-clockwise from startAngle.
|
|
94
|
+
*/
|
|
95
|
+
getAxisAngle(categoryIndex: number): number;
|
|
96
|
+
/** Radius for a value, clamped to [0, infinity): negatives sit at the center. */
|
|
97
|
+
private _valueToRadius;
|
|
98
|
+
/**
|
|
99
|
+
* Plotted point for the value of series s at category k, in chart coordinates
|
|
100
|
+
* (the chart is centered on the origin).
|
|
101
|
+
*/
|
|
102
|
+
getPointForValue(seriesIndex: number, categoryIndex: number): Vector3Tuple;
|
|
103
|
+
/** Point on the outer ring along axis k. */
|
|
104
|
+
private _outerPoint;
|
|
105
|
+
/** Build the concentric grid rings (one polygon per ring). */
|
|
106
|
+
private _createGrid;
|
|
107
|
+
/** Build one spoke line per axis, from the center to the outer ring. */
|
|
108
|
+
private _createSpokes;
|
|
109
|
+
/** Build one closed polygon per series. */
|
|
110
|
+
private _createSeries;
|
|
111
|
+
/** Build the category labels, placed just beyond the outer ring. */
|
|
112
|
+
private _createLabels;
|
|
113
|
+
/** Get the polygon for series i, or undefined when out of range. */
|
|
114
|
+
getSeriesPolygon(seriesIndex: number): Polygon | undefined;
|
|
115
|
+
/** Get the group of axis spoke lines. */
|
|
116
|
+
getAxes(): VGroup;
|
|
117
|
+
/** Get the group of grid rings. */
|
|
118
|
+
getGrid(): VGroup;
|
|
119
|
+
/** Get the group of series polygons. */
|
|
120
|
+
getSeries(): VGroup;
|
|
121
|
+
/** Get the group of category labels. */
|
|
122
|
+
getLabels(): VGroup;
|
|
123
|
+
/** Number of axes (categories). */
|
|
124
|
+
getNumAxes(): number;
|
|
125
|
+
/** Number of series. */
|
|
126
|
+
getNumSeries(): number;
|
|
127
|
+
/** The value that reaches the outer ring. */
|
|
128
|
+
getMaxValue(): number;
|
|
129
|
+
/** The outer ring radius. */
|
|
130
|
+
getOuterRadius(): number;
|
|
131
|
+
/** Get the data as a 2D array (series x categories). */
|
|
132
|
+
getData(): number[][];
|
|
133
|
+
copy(): RadarChart;
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=RadarChart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadarChart.d.ts","sourceRoot":"","sources":["../../../src/mobjects/graphing/RadarChart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAQ9C;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,kFAAkF;IAClF,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,CAAC;IAC5B,wDAAwD;IACxD,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,iFAAiF;IACjF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2CAA2C;IAC3C,MAAM,CAAC,EAAE,MAA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
+
import { VGroup } from '../../core/VGroup';
|
|
3
|
+
import { VMobject } from '../../core/VMobject';
|
|
4
|
+
import { Rectangle } from '../geometry/Rectangle';
|
|
5
|
+
/** How a StackedBarChart arranges the bars of each category. */
|
|
6
|
+
export type BarChartMode = 'stacked' | 'grouped';
|
|
7
|
+
/** Options for creating a StackedBarChart. */
|
|
8
|
+
export interface StackedBarChartOptions {
|
|
9
|
+
/** Values as a 2D array [series][category]. A flat array is treated as one series. */
|
|
10
|
+
values: number[][] | number[];
|
|
11
|
+
/** 'stacked' cumulates series; 'grouped' places them side by side. Default: 'stacked' */
|
|
12
|
+
mode?: BarChartMode;
|
|
13
|
+
/** Width of a category slot (stacked) or the full group (grouped). Default: 0.8 */
|
|
14
|
+
slotWidth?: number;
|
|
15
|
+
/** Gap kept empty on each side of a category slot. Default: 0.2 */
|
|
16
|
+
categoryGap?: number;
|
|
17
|
+
/** Gap between bars of a group (grouped mode). Default: 0.05 */
|
|
18
|
+
seriesGap?: number;
|
|
19
|
+
/** Series colors. Single color applies to all, array cycles. Default: Manim palette */
|
|
20
|
+
seriesColors?: string | string[];
|
|
21
|
+
/** Series names for the legend. Default: [] */
|
|
22
|
+
seriesNames?: string[];
|
|
23
|
+
/** Whether to draw a legend. Default: false */
|
|
24
|
+
showLegend?: boolean;
|
|
25
|
+
/** Fill opacity for the bars. Default: 0.85 */
|
|
26
|
+
fillOpacity?: number;
|
|
27
|
+
/** Stroke width for the bar outlines. Default: 1.5 */
|
|
28
|
+
strokeWidth?: number;
|
|
29
|
+
/** X-axis labels, one per category. Default: [] */
|
|
30
|
+
xLabels?: string[];
|
|
31
|
+
/** Font size for x-axis labels. Default: 22 */
|
|
32
|
+
xLabelFontSize?: number;
|
|
33
|
+
/** Y-axis range as [min, max, step]. Default: auto-computed */
|
|
34
|
+
yRange?: [number, number, number];
|
|
35
|
+
/** Visual height of the chart area. Default: 5 */
|
|
36
|
+
height?: number;
|
|
37
|
+
/** Visual width of the chart area. Default: 8 */
|
|
38
|
+
width?: number;
|
|
39
|
+
/** Color for the axes and labels. Default: white */
|
|
40
|
+
axisColor?: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* StackedBarChart - a multi-series bar chart with stacked or grouped bars.
|
|
44
|
+
*
|
|
45
|
+
* In `stacked` mode each category shows its series piled on top of one another,
|
|
46
|
+
* so bar `i` sits on the cumulative sum of the series below it. In `grouped`
|
|
47
|
+
* mode the series sit side by side within each category with no overlap.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* const chart = new StackedBarChart({
|
|
52
|
+
* values: [[3, 7, 2], [5, 4, 6]],
|
|
53
|
+
* mode: 'stacked',
|
|
54
|
+
* xLabels: ['Q1', 'Q2', 'Q3'],
|
|
55
|
+
* seriesNames: ['2023', '2024'],
|
|
56
|
+
* showLegend: true,
|
|
57
|
+
* });
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare class StackedBarChart extends Group {
|
|
61
|
+
/** All bars, in series-major order. */
|
|
62
|
+
bars: VGroup;
|
|
63
|
+
/** X-axis labels. */
|
|
64
|
+
xLabels: VGroup;
|
|
65
|
+
/** Y-axis labels. */
|
|
66
|
+
yLabels: VGroup;
|
|
67
|
+
/** The x-axis baseline. */
|
|
68
|
+
xAxisLine: VMobject;
|
|
69
|
+
/** The y-axis line. */
|
|
70
|
+
yAxisLine: VMobject;
|
|
71
|
+
/** Legend, when enabled. */
|
|
72
|
+
legend: VGroup | null;
|
|
73
|
+
protected _values: number[][];
|
|
74
|
+
protected _mode: BarChartMode;
|
|
75
|
+
protected _slotWidth: number;
|
|
76
|
+
protected _categoryGap: number;
|
|
77
|
+
protected _seriesGap: number;
|
|
78
|
+
protected _colors: string[];
|
|
79
|
+
protected _seriesNames: string[];
|
|
80
|
+
protected _showLegend: boolean;
|
|
81
|
+
protected _fillOpacity: number;
|
|
82
|
+
protected _strokeWidth: number;
|
|
83
|
+
protected _xLabelTexts: string[];
|
|
84
|
+
protected _xLabelFontSize: number;
|
|
85
|
+
protected _yRange: [number, number, number];
|
|
86
|
+
protected _height: number;
|
|
87
|
+
protected _width: number;
|
|
88
|
+
protected _axisColor: string;
|
|
89
|
+
/** Bars indexed [series][category]. */
|
|
90
|
+
protected _barGrid: Rectangle[][];
|
|
91
|
+
constructor(options: StackedBarChartOptions);
|
|
92
|
+
/** Coerce the input into a [series][category] grid with equal category counts. */
|
|
93
|
+
private _normalize;
|
|
94
|
+
private get _numSeries();
|
|
95
|
+
private get _numCategories();
|
|
96
|
+
/** Auto value range from the data, accounting for the stacking mode. */
|
|
97
|
+
private _computeYRange;
|
|
98
|
+
/** Map a data value to a y-coordinate in the chart frame. */
|
|
99
|
+
valueToY(value: number): number;
|
|
100
|
+
/** The y-coordinate of the zero baseline. */
|
|
101
|
+
baselineY(): number;
|
|
102
|
+
/** The center x-coordinate of category `c`. */
|
|
103
|
+
categoryCenterX(c: number): number;
|
|
104
|
+
/** Effective drawable width inside a category slot. */
|
|
105
|
+
private _innerWidth;
|
|
106
|
+
private _createBars;
|
|
107
|
+
/** The horizontal placement (center + width) of a bar. */
|
|
108
|
+
private _barPlacement;
|
|
109
|
+
/** The vertical placement (center + signed height) of a bar. */
|
|
110
|
+
private _barExtent;
|
|
111
|
+
private _createAxisLine;
|
|
112
|
+
private _createXLabels;
|
|
113
|
+
private _createYLabels;
|
|
114
|
+
private _createLegend;
|
|
115
|
+
/** The values as a defensive copy. */
|
|
116
|
+
getValues(): number[][];
|
|
117
|
+
/** The number of series. */
|
|
118
|
+
getNumSeries(): number;
|
|
119
|
+
/** The number of categories. */
|
|
120
|
+
getNumCategories(): number;
|
|
121
|
+
/** The chart mode. */
|
|
122
|
+
getMode(): BarChartMode;
|
|
123
|
+
/** The value range [min, max, step]. */
|
|
124
|
+
getYRange(): [number, number, number];
|
|
125
|
+
/** A single bar by series and category index. */
|
|
126
|
+
getBar(series: number, category: number): Rectangle | undefined;
|
|
127
|
+
/** All bars of one series as a VGroup. */
|
|
128
|
+
getSeries(series: number): VGroup;
|
|
129
|
+
copy(): StackedBarChart;
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=StackedBarChart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StackedBarChart.d.ts","sourceRoot":"","sources":["../../../src/mobjects/graphing/StackedBarChart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAKlD,gEAAgE;AAChE,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,SAAS,CAAC;AAEjD,8CAA8C;AAC9C,MAAM,WAAW,sBAAsB;IACrC,sFAAsF;IACtF,MAAM,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,CAAC;IAC9B,yFAAyF;IACzF,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,mFAAmF;IACnF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mEAAmE;IACnE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gEAAgE;IAChE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uFAAuF;IACvF,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACjC,+CAA+C;IAC/C,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,+CAA+C;IAC/C,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,+CAA+C;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sDAAsD;IACtD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mDAAmD;IACnD,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,+CAA+C;IAC/C,cAAc,CAAC,EAAE,MAAM,CAAC;IAC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@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Group } from '../../core/Group';
|
|
2
|
+
import { VGroup } from '../../core/VGroup';
|
|
3
|
+
import { Polygon } from '../geometry/Polygon';
|
|
4
|
+
import { Axes } from './Axes';
|
|
5
|
+
/**
|
|
6
|
+
* Where the step between two points falls.
|
|
7
|
+
* - 'after': hold the current value, then jump at the next x (matplotlib 'post').
|
|
8
|
+
* - 'before': jump at the current x, then hold to the next x (matplotlib 'pre').
|
|
9
|
+
* - 'center': jump halfway between the two x-values (matplotlib 'mid').
|
|
10
|
+
*/
|
|
11
|
+
export type StepMode = 'before' | 'after' | 'center';
|
|
12
|
+
/** Options for creating a StepChart. */
|
|
13
|
+
export interface StepChartOptions {
|
|
14
|
+
/** Y-values as [series][point]. A flat array is treated as a single series. */
|
|
15
|
+
values: number[][] | number[];
|
|
16
|
+
/** Shared x-values, one per point. Default: indices 0, 1, 2, ... */
|
|
17
|
+
xValues?: number[];
|
|
18
|
+
/** Where the step falls between points. Default: 'after' */
|
|
19
|
+
stepMode?: StepMode;
|
|
20
|
+
/** Series colors. Single color or array. Default: Manim palette */
|
|
21
|
+
seriesColors?: string | string[];
|
|
22
|
+
/** Stroke width for the step lines. Default: 3 */
|
|
23
|
+
lineWidth?: number;
|
|
24
|
+
/** Draw a dot at each data point. Default: false */
|
|
25
|
+
showDots?: boolean;
|
|
26
|
+
/** Dot radius when showDots is set. Default: 0.06 */
|
|
27
|
+
dotRadius?: number;
|
|
28
|
+
/** An existing Axes to plot onto. When omitted, one is built from the data. */
|
|
29
|
+
axes?: Axes;
|
|
30
|
+
/** X-axis range override as [min, max] or [min, max, step]. */
|
|
31
|
+
xRange?: [number, number] | [number, number, number];
|
|
32
|
+
/** Y-axis range override as [min, max] or [min, max, step]. */
|
|
33
|
+
yRange?: [number, number] | [number, number, number];
|
|
34
|
+
/** Visual length of the x-axis when auto-building axes. Default: 8 */
|
|
35
|
+
xLength?: number;
|
|
36
|
+
/** Visual length of the y-axis when auto-building axes. Default: 6 */
|
|
37
|
+
yLength?: number;
|
|
38
|
+
/** Color for the axes when auto-building. Default: white */
|
|
39
|
+
axisColor?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* StepChart - a line graph drawn as horizontal/vertical steps.
|
|
43
|
+
*
|
|
44
|
+
* Each series holds its value across an interval, then jumps to the next
|
|
45
|
+
* value. The jump falls before, after, or at the center of each interval,
|
|
46
|
+
* which suits discrete or state-over-time data.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const chart = new StepChart({
|
|
51
|
+
* values: [0, 2, 2, 5, 3],
|
|
52
|
+
* stepMode: 'after',
|
|
53
|
+
* });
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export declare class StepChart extends Group {
|
|
57
|
+
/** The coordinate system the steps are plotted on. */
|
|
58
|
+
axes: Axes;
|
|
59
|
+
/** The step lines, one per series. */
|
|
60
|
+
lines: VGroup;
|
|
61
|
+
/** The data-point dots, when enabled. */
|
|
62
|
+
dots: VGroup;
|
|
63
|
+
protected _values: number[][];
|
|
64
|
+
protected _x: number[];
|
|
65
|
+
protected _stepMode: StepMode;
|
|
66
|
+
protected _colors: string[];
|
|
67
|
+
protected _lineWidth: number;
|
|
68
|
+
protected _showDots: boolean;
|
|
69
|
+
protected _dotRadius: number;
|
|
70
|
+
/** Step vertices in data space, one array per series. */
|
|
71
|
+
protected _stepPoints: Array<Array<[number, number]>>;
|
|
72
|
+
constructor(options: StepChartOptions);
|
|
73
|
+
private _normalize;
|
|
74
|
+
/** Build the step vertices (data space) for one series. */
|
|
75
|
+
private _buildStepPoints;
|
|
76
|
+
private _buildAxes;
|
|
77
|
+
private _createLines;
|
|
78
|
+
/** The coordinate system. */
|
|
79
|
+
getAxes(): Axes;
|
|
80
|
+
/** The number of series. */
|
|
81
|
+
getNumSeries(): number;
|
|
82
|
+
/** The step line of series `s`. */
|
|
83
|
+
getLine(s: number): Polygon | undefined;
|
|
84
|
+
/** The step vertices in data space for series `s`. */
|
|
85
|
+
getStepPoints(s: number): Array<[number, number]>;
|
|
86
|
+
/** The step mode. */
|
|
87
|
+
getStepMode(): StepMode;
|
|
88
|
+
copy(): StepChart;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=StepChart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StepChart.d.ts","sourceRoot":"","sources":["../../../src/mobjects/graphing/StepChart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAG9C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAI9B;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;AAErD,wCAAwC;AACxC,MAAM,WAAW,gBAAgB;IAC/B,+EAA+E;IAC/E,MAAM,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,CAAC;IAC9B,oEAAoE;IACpE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,mEAAmE;IACnE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACjC,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oDAAoD;IACpD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+EAA+E;IAC/E,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,+DAA+D;IAC/D,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;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DAAsD;IACtD,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAIjD,qBAAqB;IACrB,WAAW,IAAI,QAAQ;IAId,IAAI,IAAI,SAAS;CAa3B"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { VGroup } from '../../core/VGroup';
|
|
2
|
+
import { Rectangle } from '../geometry/Rectangle';
|
|
3
|
+
import { TreemapNode, TreemapTile } from './treemapLayout';
|
|
4
|
+
/** How a tile picks its color. */
|
|
5
|
+
export type TreemapColorBy = 'category' | 'depth';
|
|
6
|
+
/**
|
|
7
|
+
* Options for {@link Treemap}.
|
|
8
|
+
*/
|
|
9
|
+
export interface TreemapOptions {
|
|
10
|
+
/** The root of the value hierarchy. */
|
|
11
|
+
data: TreemapNode;
|
|
12
|
+
/** Width of the chart region. Default: 8. */
|
|
13
|
+
width?: number;
|
|
14
|
+
/** Height of the chart region. Default: 4.5. */
|
|
15
|
+
height?: number;
|
|
16
|
+
/** Inset between a parent tile and its children. Default: 0.06. */
|
|
17
|
+
padding?: number;
|
|
18
|
+
/** Tile colors. Single color applies to all, array cycles. Default: Manim palette. */
|
|
19
|
+
colors?: string | string[];
|
|
20
|
+
/** Whether a color is chosen by top-level category or by depth. Default: 'category'. */
|
|
21
|
+
colorBy?: TreemapColorBy;
|
|
22
|
+
/** Fill opacity of the tiles. Default: 0.85. */
|
|
23
|
+
fillOpacity?: number;
|
|
24
|
+
/** Stroke color between tiles. Default: WHITE. */
|
|
25
|
+
strokeColor?: string;
|
|
26
|
+
/** Stroke width between tiles. Default: 1. */
|
|
27
|
+
strokeWidth?: number;
|
|
28
|
+
/** Whether to draw the root rectangle. Default: false. */
|
|
29
|
+
showRoot?: boolean;
|
|
30
|
+
/** Whether to draw a rectangle for internal (non-leaf) nodes. Default: true. */
|
|
31
|
+
showInternalNodes?: boolean;
|
|
32
|
+
/** Whether to label leaf tiles that are large enough. Default: true. */
|
|
33
|
+
showLabels?: boolean;
|
|
34
|
+
/** Font size for tile labels. Default: 18. */
|
|
35
|
+
labelFontSize?: number;
|
|
36
|
+
/** Smallest tile side, in scene units, that still gets a label. Default: 0.6. */
|
|
37
|
+
minLabelSize?: number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Treemap - a squarified treemap of nested rectangles.
|
|
41
|
+
*
|
|
42
|
+
* Each node of a value hierarchy becomes a {@link Rectangle} sized in
|
|
43
|
+
* proportion to its value. Children tile their parent's rectangle, so a child
|
|
44
|
+
* always sits inside its parent. Tiles are colored by top-level category or by
|
|
45
|
+
* depth. Empty, single-node, and zero-value inputs produce no error.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* const tree = new Treemap({
|
|
50
|
+
* data: {
|
|
51
|
+
* name: 'root',
|
|
52
|
+
* children: [
|
|
53
|
+
* { name: 'A', value: 6 },
|
|
54
|
+
* { name: 'B', children: [{ name: 'B1', value: 2 }, { name: 'B2', value: 2 }] },
|
|
55
|
+
* ],
|
|
56
|
+
* },
|
|
57
|
+
* });
|
|
58
|
+
* tree.getTile([1, 0]); // the B1 rectangle
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare class Treemap extends VGroup {
|
|
62
|
+
/** The tile rectangles, root first. */
|
|
63
|
+
tiles: VGroup;
|
|
64
|
+
/** The tile labels. */
|
|
65
|
+
labelGroup: VGroup;
|
|
66
|
+
protected _layout: TreemapTile[];
|
|
67
|
+
protected _options: TreemapOptions;
|
|
68
|
+
protected _colors: string[];
|
|
69
|
+
protected _colorBy: TreemapColorBy;
|
|
70
|
+
protected _fillOpacity: number;
|
|
71
|
+
protected _strokeColor: string;
|
|
72
|
+
protected _strokeWidth: number;
|
|
73
|
+
protected _showRoot: boolean;
|
|
74
|
+
protected _showInternalNodes: boolean;
|
|
75
|
+
protected _showLabels: boolean;
|
|
76
|
+
protected _labelFontSize: number;
|
|
77
|
+
protected _minLabelSize: number;
|
|
78
|
+
protected _tileByPath: Map<string, Rectangle>;
|
|
79
|
+
constructor(options: TreemapOptions);
|
|
80
|
+
/** Whether a tile has a non-leaf (it has a deeper descendant). */
|
|
81
|
+
protected _isLeaf(tile: TreemapTile): boolean;
|
|
82
|
+
/** The color for a tile, by category (top ancestor) or by depth. */
|
|
83
|
+
protected _colorForTile(tile: TreemapTile): string;
|
|
84
|
+
/** Build one rectangle per visible tile. */
|
|
85
|
+
protected _buildTiles(): void;
|
|
86
|
+
/** Build labels for leaf tiles that are large enough to hold text. */
|
|
87
|
+
protected _buildLabels(): void;
|
|
88
|
+
/** All tile rectangles, root first when drawn. */
|
|
89
|
+
getTiles(): Rectangle[];
|
|
90
|
+
/**
|
|
91
|
+
* The rectangle for a node, addressed by its index path from the root.
|
|
92
|
+
* @param path - Child indices from the root (empty path = root).
|
|
93
|
+
* @returns The rectangle, or undefined when the node is not drawn.
|
|
94
|
+
*/
|
|
95
|
+
getTile(path: number[]): Rectangle | undefined;
|
|
96
|
+
/** The computed layout (rectangles, values, depths) for every node. */
|
|
97
|
+
getLayout(): TreemapTile[];
|
|
98
|
+
copy(): Treemap;
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=Treemap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Treemap.d.ts","sourceRoot":"","sources":["../../../src/mobjects/graphing/Treemap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAalD,OAAO,EAAwB,KAAK,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAK3F,kCAAkC;AAClC,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,OAAO,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,uCAAuC;IACvC,IAAI,EAAE,WAAW,CAAC;IAClB,6CAA6C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AAC;IACtC,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC;IAC/B,SAAS,CAAC,cAAc,EAAE,MAAM,CAAC;IACjC,SAAS,CAAC,aAAa,EAAE,MAAM,CAAC;IAChC,SAAS,CAAC,WAAW,yBAAgC;gBAEzC,OAAO,EAAE,cAAc;IA+CnC,kEAAkE;IAClE,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO;IAQ7C,oEAAoE;IACpE,SAAS,CAAC,aAAa,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM;IAKlD,4CAA4C;IAC5C,SAAS,CAAC,WAAW,IAAI,IAAI;IAyB7B,sEAAsE;IACtE,SAAS,CAAC,YAAY,IAAI,IAAI;IAkB9B,kDAAkD;IAClD,QAAQ,IAAI,SAAS,EAAE;IAIvB;;;;OAIG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,SAAS;IAI9C,uEAAuE;IACvE,SAAS,IAAI,WAAW,EAAE;IAIjB,IAAI,IAAI,OAAO;CAKzB"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { VGroup } from '../../core/VGroup';
|
|
2
|
+
import { VMobject } from '../../core/VMobject';
|
|
3
|
+
import { Rectangle } from '../geometry/Rectangle';
|
|
4
|
+
import { NumberLine } from './NumberLine';
|
|
5
|
+
/** One rendered bar, resolved from the deltas. */
|
|
6
|
+
interface BarSpec {
|
|
7
|
+
/** Running total at the bottom start of the bar. */
|
|
8
|
+
startValue: number;
|
|
9
|
+
/** Running total at the top end of the bar. */
|
|
10
|
+
endValue: number;
|
|
11
|
+
/** Running total carried to the next bar (for the connector level). */
|
|
12
|
+
connectLevel: number;
|
|
13
|
+
/** Fill/stroke color for the bar. */
|
|
14
|
+
color: string;
|
|
15
|
+
/** Label text for the bar, if any. */
|
|
16
|
+
label?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Options for creating a WaterfallChart.
|
|
20
|
+
*/
|
|
21
|
+
export interface WaterfallChartOptions {
|
|
22
|
+
/** Sequential contributions (deltas), left to right. */
|
|
23
|
+
values: number[];
|
|
24
|
+
/** Labels for each bar. Default: [] */
|
|
25
|
+
labels?: string[];
|
|
26
|
+
/** Color for positive contributions. Default: GREEN. */
|
|
27
|
+
increaseColor?: string;
|
|
28
|
+
/** Color for negative contributions. Default: RED. */
|
|
29
|
+
decreaseColor?: string;
|
|
30
|
+
/** Color for the total bar. Default: BLUE. */
|
|
31
|
+
totalColor?: string;
|
|
32
|
+
/** Whether to draw connector lines between bars. Default: true */
|
|
33
|
+
showConnectors?: boolean;
|
|
34
|
+
/** Whether to append a total bar spanning 0 to the sum. Default: false */
|
|
35
|
+
showTotal?: boolean;
|
|
36
|
+
/** Label for the appended total bar. Default: 'Total' */
|
|
37
|
+
totalLabel?: string;
|
|
38
|
+
/** Width of each bar. Default: 0.6 */
|
|
39
|
+
barWidth?: number;
|
|
40
|
+
/** Gap between adjacent bars. Default: 0.4 */
|
|
41
|
+
barGap?: number;
|
|
42
|
+
/** Stroke width of the connector lines. Default: 1.5 */
|
|
43
|
+
connectorWidth?: number;
|
|
44
|
+
/** Stroke width of the bar outline. Default: 1.5 */
|
|
45
|
+
barStrokeWidth?: number;
|
|
46
|
+
/** Fill opacity of the bars. Default: 0.9 */
|
|
47
|
+
fillOpacity?: number;
|
|
48
|
+
/** Y-axis range as [min, max, step]. Default: auto-scaled from the running totals. */
|
|
49
|
+
yRange?: [number, number, number];
|
|
50
|
+
/** Visual height of the chart area. Default: 5 */
|
|
51
|
+
height?: number;
|
|
52
|
+
/** Visual width of the chart area. Default: 8 */
|
|
53
|
+
width?: number;
|
|
54
|
+
/** Color for the axes and labels. Default: WHITE */
|
|
55
|
+
axisColor?: string;
|
|
56
|
+
/** Whether to include y-axis tick marks. Default: true */
|
|
57
|
+
includeYTicks?: boolean;
|
|
58
|
+
/** Whether to include y-axis number labels. Default: true */
|
|
59
|
+
includeYLabels?: boolean;
|
|
60
|
+
/** Whether to draw the per-bar labels. Default: true */
|
|
61
|
+
showLabels?: boolean;
|
|
62
|
+
/** Font size for the bar labels. Default: 18 */
|
|
63
|
+
labelFontSize?: number;
|
|
64
|
+
/** Font size for the y-axis labels. Default: 20 */
|
|
65
|
+
yLabelFontSize?: number;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* WaterfallChart - A waterfall (bridge) chart mobject.
|
|
69
|
+
*
|
|
70
|
+
* Shows sequential positive and negative contributions as floating bars. Bar i
|
|
71
|
+
* starts at the running total of the previous bars and spans its own delta.
|
|
72
|
+
* Positive and negative deltas use separate colors. Connector lines join each
|
|
73
|
+
* bar to the next at the running-total level. An optional total bar spans from
|
|
74
|
+
* zero to the final sum.
|
|
75
|
+
*
|
|
76
|
+
* The chart is a VGroup, so Create and FadeIn animate it directly.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* const chart = new WaterfallChart({
|
|
81
|
+
* values: [100, -40, 30, -20, 50],
|
|
82
|
+
* labels: ['Start', 'Q1', 'Q2', 'Q3', 'Q4'],
|
|
83
|
+
* showTotal: true,
|
|
84
|
+
* });
|
|
85
|
+
* scene.play(new Create(chart));
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
export declare class WaterfallChart extends VGroup {
|
|
89
|
+
/** The floating bars (deltas, plus the total bar when enabled). */
|
|
90
|
+
bars: VGroup;
|
|
91
|
+
/** The connector lines between bars. */
|
|
92
|
+
connectors: VGroup;
|
|
93
|
+
/** The y-axis. */
|
|
94
|
+
yAxis: NumberLine;
|
|
95
|
+
/** The baseline at value zero. */
|
|
96
|
+
baseline: VMobject;
|
|
97
|
+
/** Per-bar labels. */
|
|
98
|
+
barLabels: VGroup;
|
|
99
|
+
/** Y-axis labels. */
|
|
100
|
+
yLabels: VGroup;
|
|
101
|
+
protected _values: number[];
|
|
102
|
+
protected _labelTexts: string[];
|
|
103
|
+
protected _increaseColor: string;
|
|
104
|
+
protected _decreaseColor: string;
|
|
105
|
+
protected _totalColor: string;
|
|
106
|
+
protected _showConnectors: boolean;
|
|
107
|
+
protected _showTotal: boolean;
|
|
108
|
+
protected _totalLabel: string;
|
|
109
|
+
protected _barWidth: number;
|
|
110
|
+
protected _barGap: number;
|
|
111
|
+
protected _connectorWidth: number;
|
|
112
|
+
protected _barStrokeWidth: number;
|
|
113
|
+
protected _fillOpacity: number;
|
|
114
|
+
protected _yRange: [number, number, number];
|
|
115
|
+
protected _height: number;
|
|
116
|
+
protected _width: number;
|
|
117
|
+
protected _axisColor: string;
|
|
118
|
+
protected _includeYTicks: boolean;
|
|
119
|
+
protected _includeYLabels: boolean;
|
|
120
|
+
protected _showLabels: boolean;
|
|
121
|
+
protected _labelFontSize: number;
|
|
122
|
+
protected _yLabelFontSize: number;
|
|
123
|
+
protected _specs: BarSpec[];
|
|
124
|
+
constructor(options: WaterfallChartOptions);
|
|
125
|
+
/** Resolve the deltas into ordered bar specs. */
|
|
126
|
+
private _buildSpecs;
|
|
127
|
+
/** Auto-scale the y range from every running-total level the bars reach. */
|
|
128
|
+
private _calculateYRange;
|
|
129
|
+
/** Convert a value to its y-coordinate within the chart area. */
|
|
130
|
+
valueToY(value: number): number;
|
|
131
|
+
/** X-coordinate of the center of bar i. */
|
|
132
|
+
private _barCenterX;
|
|
133
|
+
/** Create the y-axis. */
|
|
134
|
+
private _createYAxis;
|
|
135
|
+
/** Create the baseline at value zero. */
|
|
136
|
+
private _createBaseline;
|
|
137
|
+
/** Build one rectangle per bar spec. */
|
|
138
|
+
private _createBars;
|
|
139
|
+
/** Build the connector lines between adjacent bars. */
|
|
140
|
+
private _createConnectors;
|
|
141
|
+
/** Build the y-axis labels. */
|
|
142
|
+
private _createYLabels;
|
|
143
|
+
/** Build the per-bar labels below the baseline. */
|
|
144
|
+
private _createBarLabels;
|
|
145
|
+
/** Get the group of bars. */
|
|
146
|
+
getBars(): VGroup;
|
|
147
|
+
/** Get bar i, or undefined when out of range. */
|
|
148
|
+
getBar(index: number): Rectangle | undefined;
|
|
149
|
+
/** Get the group of connector lines. */
|
|
150
|
+
getConnectors(): VGroup;
|
|
151
|
+
/** Get the y-axis range as [min, max, step]. */
|
|
152
|
+
getYRange(): [number, number, number];
|
|
153
|
+
/** Get the deltas. */
|
|
154
|
+
getValues(): number[];
|
|
155
|
+
/** Get the final running total (sum of all deltas). */
|
|
156
|
+
getTotal(): number;
|
|
157
|
+
/** Get the visual height of the chart area. */
|
|
158
|
+
getChartHeight(): number;
|
|
159
|
+
/** Get the visual width of the chart area. */
|
|
160
|
+
getChartWidth(): number;
|
|
161
|
+
copy(): WaterfallChart;
|
|
162
|
+
}
|
|
163
|
+
export {};
|
|
164
|
+
//# sourceMappingURL=WaterfallChart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WaterfallChart.d.ts","sourceRoot":"","sources":["../../../src/mobjects/graphing/WaterfallChart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGlD,OAAO,EAAE,UAAU,EAAqB,MAAM,cAAc,CAAC;AAM7D,kDAAkD;AAClD,UAAU,OAAO;IACf,oDAAoD;IACpD,UAAU,EAAE,MAAM,CAAC;IACnB,+CAA+C;IAC/C,QAAQ,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,YAAY,EAAE,MAAM,CAAC;IACrB,qCAAqC;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,wDAAwD;IACxD,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,uCAAuC;IACvC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,wDAAwD;IACxD,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