manim-web 0.25.0 → 0.26.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/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/integrations/react.js +17 -17
- package/dist/integrations/vue.js +16 -16
- package/dist/manim-web.browser.js +2996 -1495
- 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/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/index.d.ts +11 -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-B2lipHn1.js} +2978 -1477
- package/package.json +1 -1
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Group } from '../../core/Group';
|
|
2
|
+
import { VGroup } from '../../core/VGroup';
|
|
3
|
+
import { Polygon } from '../geometry/Polygon';
|
|
4
|
+
import { Axes } from './Axes';
|
|
5
|
+
/** Options for creating an AreaChart. */
|
|
6
|
+
export interface AreaChartOptions {
|
|
7
|
+
/** Y-values as [series][point]. A flat array is treated as a single series. */
|
|
8
|
+
values: number[][] | number[];
|
|
9
|
+
/** Shared x-values, one per point. Default: indices 0, 1, 2, ... */
|
|
10
|
+
xValues?: number[];
|
|
11
|
+
/** Stack the series so each area rests on the sum below it. Default: false */
|
|
12
|
+
stacked?: boolean;
|
|
13
|
+
/** Baseline each (unstacked) area fills down to. Default: 0 */
|
|
14
|
+
baseline?: number;
|
|
15
|
+
/** Series colors for fills and lines. Single color or array. Default: Manim palette */
|
|
16
|
+
seriesColors?: string | string[];
|
|
17
|
+
/** Series names for the legend. Default: [] */
|
|
18
|
+
seriesNames?: string[];
|
|
19
|
+
/** Fill opacity for the areas. Default: 0.4 */
|
|
20
|
+
fillOpacity?: number;
|
|
21
|
+
/** Stroke width for the top line. Default: 3 */
|
|
22
|
+
lineWidth?: number;
|
|
23
|
+
/** An existing Axes to plot onto. When omitted, one is built from the data. */
|
|
24
|
+
axes?: Axes;
|
|
25
|
+
/** X-axis range override as [min, max] or [min, max, step]. */
|
|
26
|
+
xRange?: [number, number] | [number, number, number];
|
|
27
|
+
/** Y-axis range override as [min, max] or [min, max, step]. */
|
|
28
|
+
yRange?: [number, number] | [number, number, number];
|
|
29
|
+
/** Visual length of the x-axis when auto-building axes. Default: 8 */
|
|
30
|
+
xLength?: number;
|
|
31
|
+
/** Visual length of the y-axis when auto-building axes. Default: 6 */
|
|
32
|
+
yLength?: number;
|
|
33
|
+
/** Color for the axes when auto-building. Default: white */
|
|
34
|
+
axisColor?: string;
|
|
35
|
+
}
|
|
36
|
+
/** The two mobjects that draw one series of an AreaChart. */
|
|
37
|
+
interface SeriesParts {
|
|
38
|
+
/** The filled area from the top line down to the band below. */
|
|
39
|
+
area: Polygon;
|
|
40
|
+
/** The top boundary line. */
|
|
41
|
+
line: Polygon;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* AreaChart - one or more series drawn as filled areas under a line.
|
|
45
|
+
*
|
|
46
|
+
* Each series becomes a semi-transparent fill from its line down to the
|
|
47
|
+
* baseline, plus the line itself. When `stacked` is set, each area rests on
|
|
48
|
+
* the cumulative sum of the series below it.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* const chart = new AreaChart({
|
|
53
|
+
* values: [[1, 3, 2, 5], [2, 1, 4, 3]],
|
|
54
|
+
* stacked: true,
|
|
55
|
+
* seriesNames: ['A', 'B'],
|
|
56
|
+
* });
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare class AreaChart extends Group {
|
|
60
|
+
/** The coordinate system the areas are plotted on. */
|
|
61
|
+
axes: Axes;
|
|
62
|
+
/** The filled areas, one per series. */
|
|
63
|
+
areas: VGroup;
|
|
64
|
+
/** The top boundary lines, one per series. */
|
|
65
|
+
lines: VGroup;
|
|
66
|
+
protected _values: number[][];
|
|
67
|
+
protected _x: number[];
|
|
68
|
+
protected _stacked: boolean;
|
|
69
|
+
protected _baseline: number;
|
|
70
|
+
protected _colors: string[];
|
|
71
|
+
protected _fillOpacity: number;
|
|
72
|
+
protected _lineWidth: number;
|
|
73
|
+
protected _parts: SeriesParts[];
|
|
74
|
+
constructor(options: AreaChartOptions);
|
|
75
|
+
private _normalize;
|
|
76
|
+
/** The cumulative baseline below series `s` at point index `i`. */
|
|
77
|
+
private _bandBelow;
|
|
78
|
+
/** The top value of series `s` at point index `i`. */
|
|
79
|
+
private _bandTop;
|
|
80
|
+
private _buildAxes;
|
|
81
|
+
private _createSeries;
|
|
82
|
+
/** The coordinate system. */
|
|
83
|
+
getAxes(): Axes;
|
|
84
|
+
/** The number of series. */
|
|
85
|
+
getNumSeries(): number;
|
|
86
|
+
/** The filled area polygon of series `s`. */
|
|
87
|
+
getArea(s: number): Polygon | undefined;
|
|
88
|
+
/** The top boundary line of series `s`. */
|
|
89
|
+
getLine(s: number): Polygon | undefined;
|
|
90
|
+
/** The area and line of series `s` grouped together. */
|
|
91
|
+
getSeries(s: number): VGroup;
|
|
92
|
+
/** The data-space baseline value an unstacked area fills down to. */
|
|
93
|
+
getBaseline(): number;
|
|
94
|
+
/** The top data value of series `s` at each x (cumulative when stacked). */
|
|
95
|
+
getTopValues(s: number): number[];
|
|
96
|
+
/** The baseline data value below series `s` at each x (cumulative when stacked). */
|
|
97
|
+
getBottomValues(s: number): number[];
|
|
98
|
+
copy(): AreaChart;
|
|
99
|
+
}
|
|
100
|
+
export {};
|
|
101
|
+
//# sourceMappingURL=AreaChart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AreaChart.d.ts","sourceRoot":"","sources":["../../../src/mobjects/graphing/AreaChart.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;AAE9C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAI9B,yCAAyC;AACzC,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,8EAA8E;IAC9E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uFAAuF;IACvF,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACjC,+CAA+C;IAC/C,WAA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AAC;IAC7B,SAAS,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC;gBAEpB,OAAO,EAAE,gBAAgB;IA0CrC,OAAO,CAAC,UAAU;IAKlB,mEAAmE;IACnE,OAAO,CAAC,UAAU;IAOlB,sDAAsD;IACtD,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,UAAU;IA4BlB,OAAO,CAAC,aAAa;IAuCrB,6BAA6B;IAC7B,OAAO,IAAI,IAAI;IAIf,4BAA4B;IAC5B,YAAY,IAAI,MAAM;IAItB,6CAA6C;IAC7C,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAIvC,2CAA2C;IAC3C,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAIvC,wDAAwD;IACxD,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;IAU5B,qEAAqE;IACrE,WAAW,IAAI,MAAM;IAIrB,4EAA4E;IAC5E,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE;IAIjC,oFAAoF;IACpF,eAAe,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE;IAI3B,IAAI,IAAI,SAAS;CAa3B"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { Group } from '../../core/Group';
|
|
2
|
+
import { VGroup } from '../../core/VGroup';
|
|
3
|
+
import { Rectangle } from '../geometry/Rectangle';
|
|
4
|
+
/** GitHub-style green contribution palette (light to dark). */
|
|
5
|
+
export declare const GITHUB_GREENS: readonly string[];
|
|
6
|
+
/** One dated value for a CalendarHeatmap. */
|
|
7
|
+
export interface CalendarDatum {
|
|
8
|
+
/** The day, as a 'YYYY-MM-DD' string or a Date. */
|
|
9
|
+
date: string | Date;
|
|
10
|
+
/** The value that colors the day. */
|
|
11
|
+
value: number;
|
|
12
|
+
}
|
|
13
|
+
/** The grid position of a day cell. */
|
|
14
|
+
export interface CellPosition {
|
|
15
|
+
/** Column index (week offset from the start). */
|
|
16
|
+
week: number;
|
|
17
|
+
/** Row index (0..6), the weekday within the chart's week layout. */
|
|
18
|
+
weekday: number;
|
|
19
|
+
}
|
|
20
|
+
/** Options for creating a CalendarHeatmap. */
|
|
21
|
+
export interface CalendarHeatmapOptions {
|
|
22
|
+
/** The dated values. */
|
|
23
|
+
data: CalendarDatum[];
|
|
24
|
+
/** First day shown. Default: the earliest date in the data. */
|
|
25
|
+
startDate?: string | Date;
|
|
26
|
+
/** Last day shown. Default: the latest date in the data. */
|
|
27
|
+
endDate?: string | Date;
|
|
28
|
+
/** Side length of a day cell. Default: 0.3 */
|
|
29
|
+
cellSize?: number;
|
|
30
|
+
/** Gap between cells. Default: 0.06 */
|
|
31
|
+
cellGap?: number;
|
|
32
|
+
/** Color palette mapped across the value domain. Default: GitHub greens */
|
|
33
|
+
palette?: readonly string[];
|
|
34
|
+
/** Value domain [min, max] mapped across the palette. Auto-computed if omitted. */
|
|
35
|
+
domain?: [number, number];
|
|
36
|
+
/** Blend the palette in perceptually-uniform Oklab space. Default: false */
|
|
37
|
+
useOklab?: boolean;
|
|
38
|
+
/** First weekday of a column: 0 = Sunday (GitHub), 1 = Monday. Default: 0 */
|
|
39
|
+
weekStartsOn?: 0 | 1;
|
|
40
|
+
/** Color for days with no datum. Default: '#ebedf0' */
|
|
41
|
+
emptyColor?: string;
|
|
42
|
+
/** Draw month labels above the grid. Default: true */
|
|
43
|
+
showMonthLabels?: boolean;
|
|
44
|
+
/** Font size for month labels. Default: 16 */
|
|
45
|
+
monthLabelFontSize?: number;
|
|
46
|
+
/** Color for labels. Default: white */
|
|
47
|
+
labelColor?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* CalendarHeatmap - a GitHub-style grid of day cells colored by value.
|
|
51
|
+
*
|
|
52
|
+
* Weeks run as columns and weekdays as rows. Each day is a colored square;
|
|
53
|
+
* days with a value are colored through the palette, and days with no datum
|
|
54
|
+
* take the empty color. Month labels sit above the columns where a month
|
|
55
|
+
* begins.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const cal = new CalendarHeatmap({
|
|
60
|
+
* data: [
|
|
61
|
+
* { date: '2024-01-01', value: 3 },
|
|
62
|
+
* { date: '2024-01-02', value: 7 },
|
|
63
|
+
* ],
|
|
64
|
+
* });
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare class CalendarHeatmap extends Group {
|
|
68
|
+
/** The day cells. */
|
|
69
|
+
cells: VGroup;
|
|
70
|
+
/** The month labels. */
|
|
71
|
+
monthLabels: VGroup;
|
|
72
|
+
protected _cellSize: number;
|
|
73
|
+
protected _cellGap: number;
|
|
74
|
+
protected _palette: readonly string[];
|
|
75
|
+
protected _domain: [number, number];
|
|
76
|
+
protected _useOklab: boolean;
|
|
77
|
+
protected _weekStartsOn: 0 | 1;
|
|
78
|
+
protected _emptyColor: string;
|
|
79
|
+
protected _labelColor: string;
|
|
80
|
+
protected _values: Map<string, number>;
|
|
81
|
+
protected _startTs: number;
|
|
82
|
+
protected _endTs: number;
|
|
83
|
+
/** Cell rectangle by day key. */
|
|
84
|
+
protected _cellByKey: Map<string, Rectangle>;
|
|
85
|
+
/** Grid position by day key. */
|
|
86
|
+
protected _posByKey: Map<string, CellPosition>;
|
|
87
|
+
constructor(options: CalendarHeatmapOptions);
|
|
88
|
+
private _autoDomain;
|
|
89
|
+
/** The first column's start day, snapped back to the week's first weekday. */
|
|
90
|
+
private _resolveBounds;
|
|
91
|
+
/** The weekday row (0..6) of a day, honoring weekStartsOn. */
|
|
92
|
+
private _weekdayOf;
|
|
93
|
+
/** The grid position of a day timestamp. */
|
|
94
|
+
private _positionOf;
|
|
95
|
+
/** The cell center in local space for a grid position. */
|
|
96
|
+
private _centerOf;
|
|
97
|
+
private _createCells;
|
|
98
|
+
private _createMonthLabels;
|
|
99
|
+
/** The value domain [min, max] mapped across the palette. */
|
|
100
|
+
getDomain(): [number, number];
|
|
101
|
+
/** The number of day cells drawn. */
|
|
102
|
+
getNumCells(): number;
|
|
103
|
+
/** The cell rectangle for a date, or undefined when outside the range. */
|
|
104
|
+
getCell(date: string | Date): Rectangle | undefined;
|
|
105
|
+
/** The grid position (week, weekday) of a date. */
|
|
106
|
+
cellPosition(date: string | Date): CellPosition;
|
|
107
|
+
/** The color the map assigns to a value. */
|
|
108
|
+
colorForValue(value: number): string;
|
|
109
|
+
copy(): CalendarHeatmap;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=CalendarHeatmap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CalendarHeatmap.d.ts","sourceRoot":"","sources":["../../../src/mobjects/graphing/CalendarHeatmap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAKlD,+DAA+D;AAC/D,eAAO,MAAM,aAAa,EAAE,SAAS,MAAM,EAAiD,CAAC;AAE7F,6CAA6C;AAC7C,MAAM,WAAW,aAAa;IAC5B,mDAAmD;IACnD,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,qCAAqC;IACrC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,uCAAuC;AACvC,MAAM,WAAW,YAAY;IAC3B,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,oEAAoE;IACpE,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,8CAA8C;AAC9C,MAAM,WAAW,sBAAsB;IACrC,wBAAwB;IACxB,IAAI,EAAE,aAAa,EAAE,CAAC;IACtB,+DAA+D;IAC/D,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,4DAA4D;IAC5D,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,MA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M,CAAC;IACzB,iCAAiC;IACjC,SAAS,CAAC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC7C,gCAAgC;IAChC,SAAS,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;gBAEnC,OAAO,EAAE,sBAAsB;IA+C3C,OAAO,CAAC,WAAW;IAYnB,8EAA8E;IAC9E,OAAO,CAAC,cAAc;IAiBtB,8DAA8D;IAC9D,OAAO,CAAC,UAAU;IAKlB,4CAA4C;IAC5C,OAAO,CAAC,WAAW;IAKnB,0DAA0D;IAC1D,OAAO,CAAC,SAAS;IAKjB,OAAO,CAAC,YAAY;IAyBpB,OAAO,CAAC,kBAAkB;IAsB1B,6DAA6D;IAC7D,SAAS,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;IAI7B,qCAAqC;IACrC,WAAW,IAAI,MAAM;IAIrB,0EAA0E;IAC1E,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,SAAS;IAInD,mDAAmD;IACnD,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,YAAY;IAI/C,4CAA4C;IAC5C,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAI3B,IAAI,IAAI,eAAe;CAmBjC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { VGroup } from '../../core/VGroup';
|
|
2
|
+
import { VMobject } from '../../core/VMobject';
|
|
3
|
+
import { AnnularSector } from '../geometry/AnnularSector';
|
|
4
|
+
import { ChordFlow, ChordGroupArc, ChordLayout, ChordRibbonSpan } from './chordLayout';
|
|
5
|
+
/**
|
|
6
|
+
* A single group arc of a {@link ChordDiagram}.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ChordArc extends AnnularSector {
|
|
9
|
+
/** Group index. */
|
|
10
|
+
readonly groupIndex: number;
|
|
11
|
+
/** Total flow of the group. */
|
|
12
|
+
readonly total: number;
|
|
13
|
+
constructor(options: ConstructorParameters<typeof AnnularSector>[0] & {
|
|
14
|
+
groupIndex: number;
|
|
15
|
+
total: number;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A single flow ribbon of a {@link ChordDiagram}.
|
|
20
|
+
*
|
|
21
|
+
* The ribbon is a closed filled VMobject: an arc along the source span, a
|
|
22
|
+
* bezier through the center to the target span, an arc along it, and a bezier
|
|
23
|
+
* back. The source and target span angles are proportional to the flow values.
|
|
24
|
+
*/
|
|
25
|
+
export declare class ChordRibbon extends VMobject {
|
|
26
|
+
/** Source group index. */
|
|
27
|
+
readonly source: number;
|
|
28
|
+
/** Target group index. */
|
|
29
|
+
readonly target: number;
|
|
30
|
+
/** Flow on the source side. */
|
|
31
|
+
readonly sourceValue: number;
|
|
32
|
+
/** Flow on the target side. */
|
|
33
|
+
readonly targetValue: number;
|
|
34
|
+
private readonly _sourceSpanAngle;
|
|
35
|
+
private readonly _targetSpanAngle;
|
|
36
|
+
constructor(span: ChordRibbonSpan, radius: number, color: string, fillOpacity: number);
|
|
37
|
+
/** Angular width of the source span, proportional to {@link sourceValue}. */
|
|
38
|
+
getSourceSpanAngle(): number;
|
|
39
|
+
/** Angular width of the target span, proportional to {@link targetValue}. */
|
|
40
|
+
getTargetSpanAngle(): number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Options for {@link ChordDiagram}.
|
|
44
|
+
*/
|
|
45
|
+
export interface ChordDiagramOptions {
|
|
46
|
+
/** Square flow matrix. `matrix[i][j]` is the flow from group i to group j. */
|
|
47
|
+
matrix?: number[][];
|
|
48
|
+
/** Link-list input, used with `groupCount` when `matrix` is omitted. */
|
|
49
|
+
flows?: ChordFlow[];
|
|
50
|
+
/** Number of groups, required with `flows`. */
|
|
51
|
+
groupCount?: number;
|
|
52
|
+
/** Group labels, by index. Default: []. */
|
|
53
|
+
labels?: string[];
|
|
54
|
+
/** Inner radius of the ring (ribbons are drawn inside it). Default: 2.5. */
|
|
55
|
+
radius?: number;
|
|
56
|
+
/** Thickness of the group ring. Default: 0.25. */
|
|
57
|
+
ringWidth?: number;
|
|
58
|
+
/** Angular gap between groups, in radians. Default: 0.05. */
|
|
59
|
+
gap?: number;
|
|
60
|
+
/** Angle of the first group's start edge, in radians. Default: Math.PI / 2. */
|
|
61
|
+
startAngle?: number;
|
|
62
|
+
/** Group colors. Single color applies to all, array cycles. Default: Manim palette. */
|
|
63
|
+
colors?: string | string[];
|
|
64
|
+
/** Fill opacity of the group arcs. Default: 1. */
|
|
65
|
+
arcOpacity?: number;
|
|
66
|
+
/** Fill opacity of the ribbons. Default: 0.6. */
|
|
67
|
+
ribbonOpacity?: number;
|
|
68
|
+
/** Whether to draw group labels. Default: true when labels are given. */
|
|
69
|
+
showLabels?: boolean;
|
|
70
|
+
/** Font size for group labels. Default: 20. */
|
|
71
|
+
labelFontSize?: number;
|
|
72
|
+
/** Gap between the ring and a label. Default: 0.3. */
|
|
73
|
+
labelBuff?: number;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* ChordDiagram - arcs around a circle linked by proportional ribbons.
|
|
77
|
+
*
|
|
78
|
+
* Each group becomes an {@link ChordArc} whose angle is proportional to the
|
|
79
|
+
* group's total flow. Each non-zero flow pair becomes a {@link ChordRibbon}
|
|
80
|
+
* whose span angles are proportional to the flow values. Empty, single-group,
|
|
81
|
+
* and zero-value inputs produce no error.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* const chord = new ChordDiagram({
|
|
86
|
+
* matrix: [
|
|
87
|
+
* [0, 3, 1],
|
|
88
|
+
* [3, 0, 2],
|
|
89
|
+
* [1, 2, 0],
|
|
90
|
+
* ],
|
|
91
|
+
* labels: ['A', 'B', 'C'],
|
|
92
|
+
* });
|
|
93
|
+
* chord.getArc(0); // the first group arc
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export declare class ChordDiagram extends VGroup {
|
|
97
|
+
/** The group arcs. */
|
|
98
|
+
arcs: VGroup;
|
|
99
|
+
/** The flow ribbons. */
|
|
100
|
+
chords: VGroup;
|
|
101
|
+
/** The group labels. */
|
|
102
|
+
labelGroup: VGroup;
|
|
103
|
+
protected _options: ChordDiagramOptions;
|
|
104
|
+
protected _layout: ChordLayout;
|
|
105
|
+
protected _arcs: ChordArc[];
|
|
106
|
+
protected _chords: ChordRibbon[];
|
|
107
|
+
constructor(options: ChordDiagramOptions);
|
|
108
|
+
/** Build a label for each group at its mid-angle, outside the ring. */
|
|
109
|
+
protected _buildLabels(groups: ChordGroupArc[], labels: string[], labelRadius: number, fontSize: number): void;
|
|
110
|
+
/** All group arcs, in group order. */
|
|
111
|
+
getArcs(): ChordArc[];
|
|
112
|
+
/** The arc for a group index, or undefined when out of range. */
|
|
113
|
+
getArc(index: number): ChordArc | undefined;
|
|
114
|
+
/** All flow ribbons, in layout order. */
|
|
115
|
+
getChords(): ChordRibbon[];
|
|
116
|
+
/** The ribbon at the given index, or undefined when out of range. */
|
|
117
|
+
getChord(index: number): ChordRibbon | undefined;
|
|
118
|
+
/** The computed layout (arcs and ribbon spans). */
|
|
119
|
+
getLayout(): ChordLayout;
|
|
120
|
+
copy(): ChordDiagram;
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=ChordDiagram.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChordDiagram.d.ts","sourceRoot":"","sources":["../../../src/mobjects/graphing/ChordDiagram.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAa1D,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC;AA8DvB;;GAE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,MAAM,GAAG,WAAW,GAAG,SAAS;IAIhD,mDAAmD;IACnD,SAAS,IAAI,WAAW;IAQf,IAAI,IAAI,YAAY;CAK9B"}
|
|
@@ -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,MAAM,CAAC;IAChB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2FAA2F;IAC3F,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACjC,wDAAwD;IACxD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sDAAsD;IACtD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,yDAAyD;IACzD,UAAU,CAAC,EAAE,OAAO,CAAC;I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M,GAAG,MAAM;IAM3C,iFAAiF;IACjF,OAAO,CAAC,cAAc;IAKtB;;;OAGG;IACH,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,YAAY;IAO1E,4CAA4C;IAC5C,OAAO,CAAC,WAAW;IAKnB,8DAA8D;IAC9D,OAAO,CAAC,WAAW;IAsBnB,wEAAwE;IACxE,OAAO,CAAC,aAAa;IAYrB,2CAA2C;IAC3C,OAAO,CAAC,aAAa;IAwBrB,oEAAoE;IACpE,OAAO,CAAC,aAAa;IAkBrB,oEAAoE;IACpE,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAI1D,yCAAyC;IACzC,OAAO,IAAI,MAAM;IAIjB,mCAAmC;IACnC,OAAO,IAAI,MAAM;IAIjB,wCAAwC;IACxC,SAAS,IAAI,MAAM;IAInB,wCAAwC;IACxC,SAAS,IAAI,MAAM;IAInB,mCAAmC;IACnC,UAAU,IAAI,MAAM;IAIpB,wBAAwB;IACxB,YAAY,IAAI,MAAM;IAItB,6CAA6C;IAC7C,WAAW,IAAI,MAAM;IAIrB,6BAA6B;IAC7B,cAAc,IAAI,MAAM;IAIxB,wDAAwD;IACxD,OAAO,IAAI,MAAM,EAAE,EAAE;IAIZ,IAAI,IAAI,UAAU;CAmB5B"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { Group } from '../../core/Group';
|
|
2
|
+
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,mBAA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