manim-web 0.22.0 → 0.24.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 +4 -2
- 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/lottie-fy5zaR1g.js +7057 -0
- package/dist/manim-web.browser.js +5032 -3696
- package/dist/mobjects/graphing/BoxPlot.d.ts +99 -0
- package/dist/mobjects/graphing/BoxPlot.d.ts.map +1 -0
- package/dist/mobjects/graphing/CandlestickChart.d.ts +191 -0
- package/dist/mobjects/graphing/CandlestickChart.d.ts.map +1 -0
- package/dist/mobjects/graphing/FourierEpicycles.d.ts +149 -0
- package/dist/mobjects/graphing/FourierEpicycles.d.ts.map +1 -0
- package/dist/mobjects/graphing/FourierSeries.d.ts +60 -0
- package/dist/mobjects/graphing/FourierSeries.d.ts.map +1 -0
- package/dist/mobjects/graphing/Histogram.d.ts +71 -0
- package/dist/mobjects/graphing/Histogram.d.ts.map +1 -0
- package/dist/mobjects/graphing/ScatterPlot.d.ts +66 -0
- package/dist/mobjects/graphing/ScatterPlot.d.ts.map +1 -0
- package/dist/mobjects/graphing/ViolinPlot.d.ts +83 -0
- package/dist/mobjects/graphing/ViolinPlot.d.ts.map +1 -0
- package/dist/mobjects/graphing/fourier.d.ts +104 -0
- package/dist/mobjects/graphing/fourier.d.ts.map +1 -0
- package/dist/mobjects/graphing/index.d.ts +9 -0
- package/dist/mobjects/graphing/index.d.ts.map +1 -1
- package/dist/mobjects/graphing/stats.d.ts +128 -0
- package/dist/mobjects/graphing/stats.d.ts.map +1 -0
- package/dist/mobjects/lottie/LottieMobject.d.ts +211 -0
- package/dist/mobjects/lottie/LottieMobject.d.ts.map +1 -0
- package/dist/mobjects/lottie/index.d.ts +2 -0
- package/dist/mobjects/lottie/index.d.ts.map +1 -0
- package/dist/serialization/index.d.ts +2 -0
- package/dist/serialization/index.d.ts.map +1 -1
- package/dist/serialization/urlState.d.ts +127 -0
- package/dist/serialization/urlState.d.ts.map +1 -0
- package/dist/{src-C18aslV3.js → src-DRH8XOAP.js} +2843 -1507
- package/package.json +2 -1
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Group } from '../../core/Group';
|
|
2
|
+
import { VGroup } from '../../core/VGroup';
|
|
3
|
+
import { Rectangle } from '../geometry/Rectangle';
|
|
4
|
+
import { Line } from '../geometry/Line';
|
|
5
|
+
import { Axes } from './Axes';
|
|
6
|
+
import { BoxSummary } from './stats';
|
|
7
|
+
/** Orientation of a box or violin plot. */
|
|
8
|
+
export type PlotOrientation = 'vertical' | 'horizontal';
|
|
9
|
+
/** Options for creating a BoxPlot. */
|
|
10
|
+
export interface BoxPlotOptions {
|
|
11
|
+
/** One data group (number[]) or several groups (number[][]). */
|
|
12
|
+
data: number[] | number[][];
|
|
13
|
+
/** Lay boxes along the x-axis ('vertical') or y-axis ('horizontal'). Default: 'vertical' */
|
|
14
|
+
orientation?: PlotOrientation;
|
|
15
|
+
/** Box color, or a per-group color array. Default: Manim color palette */
|
|
16
|
+
colors?: string | string[];
|
|
17
|
+
/** Fill opacity for the boxes. Default: 0.6 */
|
|
18
|
+
fillOpacity?: number;
|
|
19
|
+
/** Stroke width for box, median and whiskers. Default: 2 */
|
|
20
|
+
strokeWidth?: number;
|
|
21
|
+
/** Whisker length as a multiple of the IQR. Default: 1.5 */
|
|
22
|
+
whiskerFactor?: number;
|
|
23
|
+
/** Box thickness in category units. Default: 0.5 */
|
|
24
|
+
boxWidth?: number;
|
|
25
|
+
/** Radius of the outlier dots. Default: 0.05 */
|
|
26
|
+
outlierRadius?: number;
|
|
27
|
+
/** An existing Axes to draw onto. When omitted, one is built from the data. */
|
|
28
|
+
axes?: Axes;
|
|
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: '#ffffff' */
|
|
34
|
+
axisColor?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* BoxPlot - a box-and-whisker plot for one or more data groups.
|
|
38
|
+
*
|
|
39
|
+
* Each group draws a box from Q1 to Q3 with a median line, whiskers that reach
|
|
40
|
+
* the most extreme values inside 1.5*IQR, and dots for the outliers beyond the
|
|
41
|
+
* whiskers. Groups sit side by side along the category axis.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* const box = new BoxPlot({
|
|
46
|
+
* data: [[1, 2, 3, 4, 5, 100], [2, 3, 4, 5, 6]],
|
|
47
|
+
* orientation: 'vertical',
|
|
48
|
+
* });
|
|
49
|
+
* const summary = box.getSummary(0); // { q1, median, q3, whiskerLow, ... }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare class BoxPlot extends Group {
|
|
53
|
+
/** The coordinate system the boxes are drawn on. */
|
|
54
|
+
axes: Axes;
|
|
55
|
+
protected _groupsData: number[][];
|
|
56
|
+
protected _orientation: PlotOrientation;
|
|
57
|
+
protected _boxWidth: number;
|
|
58
|
+
protected _summaries: BoxSummary[];
|
|
59
|
+
protected _groupMobjects: VGroup[];
|
|
60
|
+
protected _boxes: (Rectangle | null)[];
|
|
61
|
+
protected _medianLines: (Line | null)[];
|
|
62
|
+
protected _whiskerGroups: VGroup[];
|
|
63
|
+
protected _outlierGroups: VGroup[];
|
|
64
|
+
constructor(options: BoxPlotOptions);
|
|
65
|
+
/** Padded value range covering every data value across all groups. */
|
|
66
|
+
private _valueRange;
|
|
67
|
+
/** Map a (category, value) pair to a world point, respecting orientation. */
|
|
68
|
+
private _toPoint;
|
|
69
|
+
/** Build the box, median, whiskers and outliers for one group. */
|
|
70
|
+
private _buildGroup;
|
|
71
|
+
/** Build the Q1..Q3 box rectangle for one group. */
|
|
72
|
+
private _buildBox;
|
|
73
|
+
/** A whisker stem from a box edge value to a whisker end value. */
|
|
74
|
+
private _stem;
|
|
75
|
+
/** A whisker cap: a short line perpendicular to the stem at a value. */
|
|
76
|
+
private _cap;
|
|
77
|
+
/** Get the coordinate system. */
|
|
78
|
+
getAxes(): Axes;
|
|
79
|
+
/** Get the computed summary for one group. */
|
|
80
|
+
getSummary(index: number): BoxSummary;
|
|
81
|
+
/** Get all group summaries. */
|
|
82
|
+
getSummaries(): BoxSummary[];
|
|
83
|
+
/** Get the mobject group for one data group. */
|
|
84
|
+
getGroup(index: number): VGroup | undefined;
|
|
85
|
+
/** Get the box rectangle for one group, or null for an empty group. */
|
|
86
|
+
getBox(index: number): Rectangle | null;
|
|
87
|
+
/** Get the median line for one group, or null for an empty group. */
|
|
88
|
+
getMedianLine(index: number): Line | null;
|
|
89
|
+
/** Get the whisker lines for one group. */
|
|
90
|
+
getWhiskers(index: number): VGroup | undefined;
|
|
91
|
+
/** Get the outlier dots for one group. */
|
|
92
|
+
getOutlierDots(index: number): VGroup | undefined;
|
|
93
|
+
/** The number of data groups. */
|
|
94
|
+
get numGroups(): number;
|
|
95
|
+
copy(): BoxPlot;
|
|
96
|
+
}
|
|
97
|
+
/** Normalize a one-group or many-group data argument to number[][]. */
|
|
98
|
+
export declare function normalizeGroups(data: number[] | number[][]): number[][];
|
|
99
|
+
//# sourceMappingURL=BoxPlot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BoxPlot.d.ts","sourceRoot":"","sources":["../../../src/mobjects/graphing/BoxPlot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,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|
+
import { VGroup } from '../../core/VGroup';
|
|
2
|
+
import { VMobject } from '../../core/VMobject';
|
|
3
|
+
import { Rectangle } from '../geometry/Rectangle';
|
|
4
|
+
import { Line } from '../geometry/Line';
|
|
5
|
+
import { NumberLine } from './NumberLine';
|
|
6
|
+
/**
|
|
7
|
+
* One open/high/low/close data point for a CandlestickChart.
|
|
8
|
+
*/
|
|
9
|
+
export interface OHLC {
|
|
10
|
+
/** Opening price. */
|
|
11
|
+
open: number;
|
|
12
|
+
/** Highest price in the period. */
|
|
13
|
+
high: number;
|
|
14
|
+
/** Lowest price in the period. */
|
|
15
|
+
low: number;
|
|
16
|
+
/** Closing price. */
|
|
17
|
+
close: number;
|
|
18
|
+
/** Optional date or category label for the x-axis. */
|
|
19
|
+
date?: string;
|
|
20
|
+
/** Optional free-form label for the x-axis (overrides date). */
|
|
21
|
+
label?: string;
|
|
22
|
+
/** Optional traded volume, shown when showVolume is true. */
|
|
23
|
+
volume?: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Options for creating a CandlestickChart.
|
|
27
|
+
*/
|
|
28
|
+
export interface CandlestickChartOptions {
|
|
29
|
+
/** Array of OHLC data points, left to right. */
|
|
30
|
+
data: OHLC[];
|
|
31
|
+
/** Fill/stroke color for bullish candles (close >= open). Default: GREEN. */
|
|
32
|
+
bullishColor?: string;
|
|
33
|
+
/** Fill/stroke color for bearish candles (close < open). Default: RED. */
|
|
34
|
+
bearishColor?: string;
|
|
35
|
+
/** Width of each candle body. Default: 0.5 */
|
|
36
|
+
candleWidth?: number;
|
|
37
|
+
/** Gap between adjacent candles. Default: 0.2 */
|
|
38
|
+
candleSpacing?: number;
|
|
39
|
+
/** Stroke width of the high/low wick line. Default: 2 */
|
|
40
|
+
wickWidth?: number;
|
|
41
|
+
/** Stroke width of the candle body outline. Default: 1.5 */
|
|
42
|
+
bodyStrokeWidth?: number;
|
|
43
|
+
/** Fill opacity of the candle body. Default: 0.9 */
|
|
44
|
+
bodyFillOpacity?: number;
|
|
45
|
+
/** Y-axis (price) range as [min, max, step]. Default: auto-scaled from data. */
|
|
46
|
+
yRange?: [number, number, number];
|
|
47
|
+
/** Visual height of the price area. Default: 5 */
|
|
48
|
+
height?: number;
|
|
49
|
+
/** Visual width of the chart area. Default: 8 */
|
|
50
|
+
width?: number;
|
|
51
|
+
/** Color for the axes and labels. Default: WHITE */
|
|
52
|
+
axisColor?: string;
|
|
53
|
+
/** Whether to include y-axis tick marks. Default: true */
|
|
54
|
+
includeYTicks?: boolean;
|
|
55
|
+
/** Whether to include y-axis price labels. Default: true */
|
|
56
|
+
includeYLabels?: boolean;
|
|
57
|
+
/** Font size for y-axis labels. Default: 20 */
|
|
58
|
+
yLabelFontSize?: number;
|
|
59
|
+
/** Explicit x-axis labels (overrides date/label on the data). Default: [] */
|
|
60
|
+
xLabels?: string[];
|
|
61
|
+
/** Font size for x-axis labels. Default: 20 */
|
|
62
|
+
xLabelFontSize?: number;
|
|
63
|
+
/** Whether to draw volume bars below the price area. Default: false */
|
|
64
|
+
showVolume?: boolean;
|
|
65
|
+
/** Visual height of the volume area. Default: 1 */
|
|
66
|
+
volumeHeight?: number;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* CandlestickChart - A financial candlestick / OHLC chart mobject.
|
|
70
|
+
*
|
|
71
|
+
* Renders each period as a body rectangle that spans open to close, plus a
|
|
72
|
+
* high/low wick line. Bullish periods (close >= open) and bearish periods
|
|
73
|
+
* (close < open) use separate colors. The price y-axis auto-scales to the data
|
|
74
|
+
* unless an explicit range is given. Optional volume bars render below.
|
|
75
|
+
*
|
|
76
|
+
* The chart is a VGroup, so Create and FadeIn animate it directly.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* const chart = new CandlestickChart({
|
|
81
|
+
* data: [
|
|
82
|
+
* { open: 10, high: 15, low: 8, close: 14, date: 'Mon' },
|
|
83
|
+
* { open: 14, high: 16, low: 11, close: 12, date: 'Tue' },
|
|
84
|
+
* ],
|
|
85
|
+
* showVolume: true,
|
|
86
|
+
* });
|
|
87
|
+
* scene.play(new Create(chart));
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export declare class CandlestickChart extends VGroup {
|
|
91
|
+
/** The candle VGroups (each holds a body Rectangle and a wick Line). */
|
|
92
|
+
candles: VGroup;
|
|
93
|
+
/** The volume bars, when showVolume is enabled. */
|
|
94
|
+
volumeBars: VGroup;
|
|
95
|
+
/** The price y-axis. */
|
|
96
|
+
yAxis: NumberLine;
|
|
97
|
+
/** The x-axis baseline. */
|
|
98
|
+
xAxisLine: VMobject;
|
|
99
|
+
/** X-axis labels. */
|
|
100
|
+
xLabels: VGroup;
|
|
101
|
+
/** Y-axis labels. */
|
|
102
|
+
yLabels: VGroup;
|
|
103
|
+
protected _data: OHLC[];
|
|
104
|
+
protected _bullishColor: string;
|
|
105
|
+
protected _bearishColor: string;
|
|
106
|
+
protected _candleWidth: number;
|
|
107
|
+
protected _candleSpacing: number;
|
|
108
|
+
protected _wickWidth: number;
|
|
109
|
+
protected _bodyStrokeWidth: number;
|
|
110
|
+
protected _bodyFillOpacity: number;
|
|
111
|
+
protected _yRange: [number, number, number];
|
|
112
|
+
protected _height: number;
|
|
113
|
+
protected _width: number;
|
|
114
|
+
protected _axisColor: string;
|
|
115
|
+
protected _includeYTicks: boolean;
|
|
116
|
+
protected _includeYLabels: boolean;
|
|
117
|
+
protected _yLabelFontSize: number;
|
|
118
|
+
protected _xLabelTexts: string[];
|
|
119
|
+
protected _xLabelFontSize: number;
|
|
120
|
+
protected _showVolume: boolean;
|
|
121
|
+
protected _volumeHeight: number;
|
|
122
|
+
constructor(options: CandlestickChartOptions);
|
|
123
|
+
/** Whether a period is bullish (close at or above open). */
|
|
124
|
+
private _isBullish;
|
|
125
|
+
/** Color for a period, by direction. */
|
|
126
|
+
private _candleColor;
|
|
127
|
+
/**
|
|
128
|
+
* Auto-scale the price range from the data lows and highs.
|
|
129
|
+
*/
|
|
130
|
+
private _calculateYRange;
|
|
131
|
+
/**
|
|
132
|
+
* Convert a price to its y-coordinate within the price area.
|
|
133
|
+
*/
|
|
134
|
+
priceToY(price: number): number;
|
|
135
|
+
/**
|
|
136
|
+
* X-coordinate of the center column for candle i.
|
|
137
|
+
*/
|
|
138
|
+
private _candleCenterX;
|
|
139
|
+
/**
|
|
140
|
+
* Create the price y-axis.
|
|
141
|
+
*/
|
|
142
|
+
private _createYAxis;
|
|
143
|
+
/**
|
|
144
|
+
* Create the x-axis baseline at the bottom of the price area.
|
|
145
|
+
*/
|
|
146
|
+
private _createXAxisLine;
|
|
147
|
+
/**
|
|
148
|
+
* Build one candle (body rectangle + wick line) per data point.
|
|
149
|
+
*/
|
|
150
|
+
private _createCandles;
|
|
151
|
+
/**
|
|
152
|
+
* Build volume bars below the price area.
|
|
153
|
+
*/
|
|
154
|
+
private _createVolumeBars;
|
|
155
|
+
/**
|
|
156
|
+
* Create x-axis labels from the explicit option or the data date/label.
|
|
157
|
+
*/
|
|
158
|
+
private _createXLabels;
|
|
159
|
+
/**
|
|
160
|
+
* Create y-axis price labels.
|
|
161
|
+
*/
|
|
162
|
+
private _createYLabels;
|
|
163
|
+
/** Get all candle VGroups. */
|
|
164
|
+
getCandles(): VGroup[];
|
|
165
|
+
/**
|
|
166
|
+
* Get a single candle VGroup by index.
|
|
167
|
+
* @returns The candle, or undefined when out of range.
|
|
168
|
+
*/
|
|
169
|
+
getCandle(index: number): VGroup | undefined;
|
|
170
|
+
/**
|
|
171
|
+
* Get the body rectangle of candle i.
|
|
172
|
+
* @returns The body, or undefined when out of range.
|
|
173
|
+
*/
|
|
174
|
+
getBody(index: number): Rectangle | undefined;
|
|
175
|
+
/**
|
|
176
|
+
* Get the wick line of candle i.
|
|
177
|
+
* @returns The wick, or undefined when out of range.
|
|
178
|
+
*/
|
|
179
|
+
getWick(index: number): Line | undefined;
|
|
180
|
+
/** Get all volume bars (empty when showVolume is off). */
|
|
181
|
+
getVolumeBars(): Rectangle[];
|
|
182
|
+
/** Get the price (y-axis) range as [min, max, step]. */
|
|
183
|
+
getYRange(): [number, number, number];
|
|
184
|
+
/** Get the data points. */
|
|
185
|
+
getData(): OHLC[];
|
|
186
|
+
/** Get the visual height of the price area. */
|
|
187
|
+
getChartHeight(): number;
|
|
188
|
+
/** Get the visual width of the chart area. */
|
|
189
|
+
getChartWidth(): number;
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=CandlestickChart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CandlestickChart.d.ts","sourceRoot":"","sources":["../../../src/mobjects/graphing/CandlestickChart.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;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,OAAO,EAAE,UAAU,EAAqB,MAAM,cAAc,CAAC;AAG7D;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,qBAAqB;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,sDAAsD;IACtD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gEAAgE;IAChE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,gDAAgD;IAChD,IAAI,EAAE,IAAI,EAAE,CAAC;IACb,6EAA6E;IAC7E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,0EAA0E;IAC1E,YAAY,CAAC,EAAE,MAAM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,CAAC,iBAAiB;IA2BzB;;OAEG;IACH,OAAO,CAAC,cAAc;IAkBtB;;OAEG;IACH,OAAO,CAAC,cAAc;IA2BtB,8BAA8B;IAC9B,UAAU,IAAI,MAAM,EAAE;IAItB;;;OAGG;IACH,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAK5C;;;OAGG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;IAK7C;;;OAGG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAKxC,0DAA0D;IAC1D,aAAa,IAAI,SAAS,EAAE;IAI5B,wDAAwD;IACxD,SAAS,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;IAIrC,2BAA2B;IAC3B,OAAO,IAAI,IAAI,EAAE;IAIjB,+CAA+C;IAC/C,cAAc,IAAI,MAAM;IAIxB,8CAA8C;IAC9C,aAAa,IAAI,MAAM;CAGxB"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { Group } from '../../core/Group';
|
|
2
|
+
import { VMobject } from '../../core/VMobject';
|
|
3
|
+
import { Vector3Tuple } from '../../core/Mobject';
|
|
4
|
+
import { ValueTracker } from '../value-tracker/ValueTracker';
|
|
5
|
+
import { Complex } from './ComplexPlane';
|
|
6
|
+
import { FourierCoefficient, FourierOrder } from './fourier';
|
|
7
|
+
/** A parametric complex path: `func(t)` for `t` over `tRange` (default `[0, 1]`). */
|
|
8
|
+
export interface ComplexPathFunction {
|
|
9
|
+
/** Maps a parameter to a complex plane point. */
|
|
10
|
+
func: (t: number) => Complex;
|
|
11
|
+
/** Parameter range as `[min, max]`. Default `[0, 1]`. */
|
|
12
|
+
tRange?: [number, number];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The path an epicycle chain approximates. One of:
|
|
16
|
+
* - `number[][]`: equally spaced samples, each `[x, y]` read as the complex point `x + i·y`.
|
|
17
|
+
* - {@link VMobject}: sampled along its arc length into complex points.
|
|
18
|
+
* - {@link ComplexPathFunction}: a parametric complex function sampled over its range.
|
|
19
|
+
*/
|
|
20
|
+
export type FourierPathInput = number[][] | VMobject | ComplexPathFunction;
|
|
21
|
+
/**
|
|
22
|
+
* Options for {@link FourierEpicycles}.
|
|
23
|
+
*/
|
|
24
|
+
export interface FourierEpicyclesOptions {
|
|
25
|
+
/** The path to approximate. */
|
|
26
|
+
path: FourierPathInput;
|
|
27
|
+
/** Number of rotating vectors to show. Default: all coefficients. */
|
|
28
|
+
numTerms?: number;
|
|
29
|
+
/** Samples taken from a {@link VMobject} or {@link ComplexPathFunction}. Default `256`. */
|
|
30
|
+
numSamples?: number;
|
|
31
|
+
/** Origin of the vector chain (the fixed tail of the first vector). Default `[0, 0, 0]`. */
|
|
32
|
+
center?: Vector3Tuple;
|
|
33
|
+
/** Vector chain ordering. Default `'frequency'` (the iconic `0, +1, -1, +2, -2, …`). */
|
|
34
|
+
order?: FourierOrder;
|
|
35
|
+
/** Color of the rotating vectors (arrows). Default `'#58c4dd'`. */
|
|
36
|
+
color?: string;
|
|
37
|
+
/** Whether to draw the circles behind the vectors. Default `true`. */
|
|
38
|
+
showCircles?: boolean;
|
|
39
|
+
/** Color of the circles. Default `'#888888'`. */
|
|
40
|
+
circleColor?: string;
|
|
41
|
+
/** Opacity of the circles' stroke. Default `0.5`. */
|
|
42
|
+
circleOpacity?: number;
|
|
43
|
+
/** Color of the traced output curve. Default `'#ffff00'`. */
|
|
44
|
+
traceColor?: string;
|
|
45
|
+
/** Stroke width of the traced curve. Default `3`. */
|
|
46
|
+
traceWidth?: number;
|
|
47
|
+
/** Stroke width of the vectors. Default `2`. */
|
|
48
|
+
strokeWidth?: number;
|
|
49
|
+
/** Arrow tip length for the vectors. Default `0.15`. */
|
|
50
|
+
tipLength?: number;
|
|
51
|
+
/** Whether to show a pen dot at the chain tip. Default `true`. */
|
|
52
|
+
showPen?: boolean;
|
|
53
|
+
/** Cycles per second advanced by the internal updater. Default `0.2`. */
|
|
54
|
+
speed?: number;
|
|
55
|
+
/** Install an updater that advances time each frame. Default `true`. */
|
|
56
|
+
animate?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Optional tracker that drives time instead of the internal clock. When set,
|
|
59
|
+
* `time` is read from the tracker each frame (one period spans value `0 → 1`).
|
|
60
|
+
*/
|
|
61
|
+
tracker?: ValueTracker;
|
|
62
|
+
/** Maximum number of accumulated trace points before the oldest are dropped. Default `2000`. */
|
|
63
|
+
maxTracePoints?: number;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* FourierEpicycles - the rotating-vector ("epicycle") approximation of a path.
|
|
67
|
+
*
|
|
68
|
+
* Given a path and a number of terms `N`, this builds the chain of `N` rotating
|
|
69
|
+
* vectors (and their circles) whose tip-to-tail sum tracks the path, plus the
|
|
70
|
+
* curve traced by the final tip. An updater rotates each vector at its own
|
|
71
|
+
* frequency and extends the traced curve over time, reproducing the iconic
|
|
72
|
+
* 3Blue1Brown Fourier-series animation.
|
|
73
|
+
*
|
|
74
|
+
* The geometry is deterministic: {@link setTime} fully determines every vector,
|
|
75
|
+
* circle, and the tip for a given normalized time `t`.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* // Approximate a square wave path with 50 rotating vectors.
|
|
80
|
+
* const path: number[][] = [];
|
|
81
|
+
* for (let i = 0; i < 256; i++) {
|
|
82
|
+
* const a = (2 * Math.PI * i) / 256;
|
|
83
|
+
* path.push([Math.cos(a), Math.sin(3 * a) / 3]);
|
|
84
|
+
* }
|
|
85
|
+
* const epicycles = new FourierEpicycles({ path, numTerms: 50 });
|
|
86
|
+
* scene.add(epicycles);
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export declare class FourierEpicycles extends Group {
|
|
90
|
+
private _coefficients;
|
|
91
|
+
private _center;
|
|
92
|
+
private _speed;
|
|
93
|
+
private _tracker;
|
|
94
|
+
private _maxTracePoints;
|
|
95
|
+
private _showPen;
|
|
96
|
+
private _circlesGroup;
|
|
97
|
+
private _vectorsGroup;
|
|
98
|
+
private _tracedPath;
|
|
99
|
+
private _circles;
|
|
100
|
+
private _vectors;
|
|
101
|
+
private _pen;
|
|
102
|
+
private _time;
|
|
103
|
+
private _tracePoints;
|
|
104
|
+
private _lastTip;
|
|
105
|
+
private _sourceSamples;
|
|
106
|
+
private _options;
|
|
107
|
+
constructor(options: FourierEpicyclesOptions);
|
|
108
|
+
/**
|
|
109
|
+
* Resolve a {@link FourierPathInput} into equally spaced complex samples.
|
|
110
|
+
*/
|
|
111
|
+
private static _resolveSamples;
|
|
112
|
+
/**
|
|
113
|
+
* Advance the internal clock by `dt` seconds (scaled by `speed`), reposition
|
|
114
|
+
* the chain, and extend the traced curve. When a tracker drives time, its
|
|
115
|
+
* value is used directly instead of the internal clock.
|
|
116
|
+
*/
|
|
117
|
+
private _advance;
|
|
118
|
+
private _appendTracePoint;
|
|
119
|
+
private _rebuildTrace;
|
|
120
|
+
/**
|
|
121
|
+
* Position every vector and circle for normalized time `t` and move the pen
|
|
122
|
+
* to the chain tip. One full period spans `t ∈ [0, 1)`. Pure positioning:
|
|
123
|
+
* this does not extend the traced curve.
|
|
124
|
+
*
|
|
125
|
+
* @param t - Normalized time.
|
|
126
|
+
* @returns The chain tip as `[x, y, z]`, equal to the `numTerms` partial sum.
|
|
127
|
+
*/
|
|
128
|
+
setTime(t: number): Vector3Tuple;
|
|
129
|
+
/** Current normalized time of the internal clock. */
|
|
130
|
+
getTime(): number;
|
|
131
|
+
/** The chain tip computed at the most recent {@link setTime}. */
|
|
132
|
+
getTipPoint(): Vector3Tuple;
|
|
133
|
+
/** The ordered coefficients actually shown (length equals the vector count). */
|
|
134
|
+
getCoefficients(): FourierCoefficient[];
|
|
135
|
+
/** The number of rotating vectors (equals the requested, clamped, term count). */
|
|
136
|
+
getNumTerms(): number;
|
|
137
|
+
/** The group of rotating-vector arrows. */
|
|
138
|
+
getVectors(): Group;
|
|
139
|
+
/** The group of circles (empty when `showCircles` is `false`). */
|
|
140
|
+
getCircles(): Group;
|
|
141
|
+
/** The VMobject holding the traced output curve. */
|
|
142
|
+
getTracedPath(): VMobject;
|
|
143
|
+
/** The accumulated trace points, oldest first. */
|
|
144
|
+
getTracePoints(): number[][];
|
|
145
|
+
/** Clear the accumulated traced curve. */
|
|
146
|
+
clearTrace(): this;
|
|
147
|
+
copy(): FourierEpicycles;
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=FourierEpicycles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FourierEpicycles.d.ts","sourceRoot":"","sources":["../../../src/mobjects/graphing/FourierEpicycles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,YAAY,EAClB,MAAM,WAAW,CAAC;AAEnB,qFAAqF;AACrF,MAAM,WAAW,mBAAmB;IAClC,iDAAiD;IACjD,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;IAC7B,yDAAyD;IACzD,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC3B;AAED;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,EAAE,EAAE,GAAG,QAAQ,GAAG,mBAAmB,CAAC;AAE3E;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,+BAA+B;IAC/B,IAAI,EAAE,gBAAgB,CAAC;IACvB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,M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C,QAAQ,CAAe;IAC/B,OAAO,CAAC,IAAI,CAAoB;IAEhC,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,YAAY,CAAkB;IACtC,OAAO,CAAC,QAAQ,CAAe;IAG/B,OAAO,CAAC,cAAc,CAAY;IAClC,OAAO,CAAC,QAAQ,CAA0B;gBAE9B,OAAO,EAAE,uBAAuB;IAsF5C;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,eAAe;IA2B9B;;;;OAIG;IACH,OAAO,CAAC,QAAQ;IAMhB,OAAO,CAAC,iBAAiB;IAQzB,OAAO,CAAC,aAAa;IAsBrB;;;;;;;OAOG;IACH,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,YAAY;IA2BhC,qDAAqD;IACrD,OAAO,IAAI,MAAM;IAIjB,iEAAiE;IACjE,WAAW,IAAI,YAAY;IAI3B,gFAAgF;IAChF,eAAe,IAAI,kBAAkB,EAAE;IAIvC,kFAAkF;IAClF,WAAW,IAAI,MAAM;IAIrB,2CAA2C;IAC3C,UAAU,IAAI,KAAK;IAInB,kEAAkE;IAClE,UAAU,IAAI,KAAK;IAInB,oDAAoD;IACpD,aAAa,IAAI,QAAQ;IAIzB,kDAAkD;IAClD,cAAc,IAAI,MAAM,EAAE,EAAE;IAI5B,0CAA0C;IAC1C,UAAU,IAAI,IAAI;IAMT,IAAI,IAAI,gBAAgB;CAQlC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { FunctionGraph, FunctionGraphOptions } from './FunctionGraph';
|
|
2
|
+
/**
|
|
3
|
+
* Options for {@link FourierSeries}.
|
|
4
|
+
*/
|
|
5
|
+
export interface FourierSeriesOptions {
|
|
6
|
+
/** The target real periodic function to approximate, `y = f(x)`. */
|
|
7
|
+
func: (x: number) => number;
|
|
8
|
+
/** Number of harmonics kept, chosen by amplitude. Default: all sampled terms. */
|
|
9
|
+
numTerms?: number;
|
|
10
|
+
/** Length of one period of {@link func}. Default `2π`. */
|
|
11
|
+
period?: number;
|
|
12
|
+
/** Start of the sampled period. Default: the graph's `xRange[0]`, else `0`. */
|
|
13
|
+
periodStart?: number;
|
|
14
|
+
/** Samples used to compute the Fourier coefficients. Default `256`. */
|
|
15
|
+
coefficientSamples?: number;
|
|
16
|
+
/** X range for the plotted curve as `[min, max]`. */
|
|
17
|
+
xRange?: [number, number];
|
|
18
|
+
/** Stroke color. Default `'#58c4dd'`. */
|
|
19
|
+
color?: string;
|
|
20
|
+
/** Stroke width in pixels. Default `2`. */
|
|
21
|
+
strokeWidth?: number;
|
|
22
|
+
/** Samples used to draw the curve. Default `200`. */
|
|
23
|
+
numSamples?: number;
|
|
24
|
+
/** Reference axes for coordinate transformation. */
|
|
25
|
+
axes?: FunctionGraphOptions['axes'];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* FourierSeries - the truncated Fourier partial sum of a function, as a graph.
|
|
29
|
+
*
|
|
30
|
+
* Computes the discrete Fourier coefficients of a real periodic function,
|
|
31
|
+
* keeps the `numTerms` largest harmonics, and plots the resulting partial-sum
|
|
32
|
+
* approximation `y = f_N(x)` like a {@link FunctionGraph}. As `numTerms` grows,
|
|
33
|
+
* the curve converges to the target function.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* // Approximate a square wave with 7 harmonics over [-π, π].
|
|
38
|
+
* const square = (x: number) => (Math.sin(x) >= 0 ? 1 : -1);
|
|
39
|
+
* const series = new FourierSeries({
|
|
40
|
+
* func: square,
|
|
41
|
+
* numTerms: 7,
|
|
42
|
+
* period: 2 * Math.PI,
|
|
43
|
+
* xRange: [-Math.PI, Math.PI],
|
|
44
|
+
* axes,
|
|
45
|
+
* });
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare class FourierSeries extends FunctionGraph {
|
|
49
|
+
private _targetFunc;
|
|
50
|
+
private _numTerms;
|
|
51
|
+
private _period;
|
|
52
|
+
constructor(options: FourierSeriesOptions);
|
|
53
|
+
/** The target function this series approximates. */
|
|
54
|
+
getTargetFunction(): (x: number) => number;
|
|
55
|
+
/** The number of harmonics requested (`undefined` means all sampled terms). */
|
|
56
|
+
getNumTerms(): number | undefined;
|
|
57
|
+
/** The period used to compute the coefficients. */
|
|
58
|
+
getPeriod(): number;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=FourierSeries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FourierSeries.d.ts","sourceRoot":"","sources":["../../../src/mobjects/graphing/FourierSeries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAG3E;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,oEAAoE;IACpE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC5B,iFAAiF;IACjF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+EAA+E;IAC/E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uEAAuE;IACvE,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,qDAAqD;IACrD,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1B,yCAAyC;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2CAA2C;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qDAAqD;IACrD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oDAAoD;IACpD,IAAI,CAAC,EAAE,oBAAoB,CAAC,MAAM,CAAC,CAAC;CACrC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,aAAc,SAAQ,aAAa;IAC9C,OAAO,CAAC,WAAW,CAAwB;IAC3C,OAAO,CAAC,SAAS,CAAqB;IACtC,OAAO,CAAC,OAAO,CAAS;gBAEZ,OAAO,EAAE,oBAAoB;IAyBzC,oDAAoD;IACpD,iBAAiB,IAAI,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM;IAI1C,+EAA+E;IAC/E,WAAW,IAAI,MAAM,GAAG,SAAS;IAIjC,mDAAmD;IACnD,SAAS,IAAI,MAAM;CAGpB"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Group } from '../../core/Group';
|
|
2
|
+
import { VGroup } from '../../core/VGroup';
|
|
3
|
+
import { Rectangle } from '../geometry/Rectangle';
|
|
4
|
+
import { Axes } from './Axes';
|
|
5
|
+
import { HistogramBin } from './stats';
|
|
6
|
+
/** Options for creating a Histogram. */
|
|
7
|
+
export interface HistogramOptions {
|
|
8
|
+
/** The raw data values to bin. */
|
|
9
|
+
data: number[];
|
|
10
|
+
/** Number of equal-width bins. Ignored when binEdges is given. Default: 10 */
|
|
11
|
+
bins?: number;
|
|
12
|
+
/** Explicit bin edges (length n+1 for n bins). Overrides bins. */
|
|
13
|
+
binEdges?: number[];
|
|
14
|
+
/** Plot bar height as probability density instead of count. Default: false */
|
|
15
|
+
density?: boolean;
|
|
16
|
+
/** Plot bar height as relative frequency (count / N). Ignored if density. Default: false */
|
|
17
|
+
normalize?: boolean;
|
|
18
|
+
/** Fill color for the bars. Default: Manim's blue */
|
|
19
|
+
color?: string;
|
|
20
|
+
/** Fill opacity for the bars. Default: 0.75 */
|
|
21
|
+
fillOpacity?: number;
|
|
22
|
+
/** Stroke width for the bar outlines. Default: 1 */
|
|
23
|
+
strokeWidth?: number;
|
|
24
|
+
/** An existing Axes to draw onto. When omitted, one is built from the bins. */
|
|
25
|
+
axes?: Axes;
|
|
26
|
+
/** Visual length of the x-axis when auto-building axes. Default: 8 */
|
|
27
|
+
xLength?: number;
|
|
28
|
+
/** Visual length of the y-axis when auto-building axes. Default: 6 */
|
|
29
|
+
yLength?: number;
|
|
30
|
+
/** Color for the axes when auto-building. Default: '#ffffff' */
|
|
31
|
+
axisColor?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Histogram - bars over an x-axis from binned raw data.
|
|
35
|
+
*
|
|
36
|
+
* The raw data is binned into equal-width bins (or the given explicit edges).
|
|
37
|
+
* Bar height is the bin count, the relative frequency, or the probability
|
|
38
|
+
* density. When no Axes is supplied, one is built to fit the bins.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const hist = new Histogram({
|
|
43
|
+
* data: [1, 2, 2, 3, 3, 3, 4, 4, 5],
|
|
44
|
+
* bins: 5,
|
|
45
|
+
* density: true,
|
|
46
|
+
* });
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare class Histogram extends Group {
|
|
50
|
+
/** The coordinate system the bars are drawn on. */
|
|
51
|
+
axes: Axes;
|
|
52
|
+
/** The rectangular bars, one per bin, left to right. */
|
|
53
|
+
bars: VGroup;
|
|
54
|
+
protected _data: number[];
|
|
55
|
+
protected _bins: HistogramBin[];
|
|
56
|
+
constructor(options: HistogramOptions);
|
|
57
|
+
/** Map a bin to its bar height given the count/frequency/density mode. */
|
|
58
|
+
private _barHeight;
|
|
59
|
+
/** Get the coordinate system. */
|
|
60
|
+
getAxes(): Axes;
|
|
61
|
+
/** Get the group of bars. */
|
|
62
|
+
getBars(): VGroup;
|
|
63
|
+
/** Get a single bar by bin index, or undefined when out of range. */
|
|
64
|
+
getBar(index: number): Rectangle | undefined;
|
|
65
|
+
/** Get the computed bins (edges, counts, density). */
|
|
66
|
+
getBins(): HistogramBin[];
|
|
67
|
+
/** The number of bins. */
|
|
68
|
+
get numBins(): number;
|
|
69
|
+
copy(): Histogram;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=Histogram.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Histogram.d.ts","sourceRoot":"","sources":["../../../src/mobjects/graphing/Histogram.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAk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AAI;IAIf,6BAA6B;IAC7B,OAAO,IAAI,MAAM;IAIjB,qEAAqE;IACrE,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;IAI5C,sDAAsD;IACtD,OAAO,IAAI,YAAY,EAAE;IAIzB,0BAA0B;IAC1B,IAAI,OAAO,IAAI,MAAM,CAEpB;IAEQ,IAAI,IAAI,SAAS;CAK3B"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Group } from '../../core/Group';
|
|
2
|
+
import { VGroup } from '../../core/VGroup';
|
|
3
|
+
import { Dot } from '../geometry/Dot';
|
|
4
|
+
import { Axes } from './Axes';
|
|
5
|
+
/** Options for creating a ScatterPlot. */
|
|
6
|
+
export interface ScatterPlotOptions {
|
|
7
|
+
/** X coordinates of the points. */
|
|
8
|
+
x: number[];
|
|
9
|
+
/** Y coordinates of the points. Paired with x by index. */
|
|
10
|
+
y: number[];
|
|
11
|
+
/** Dot radius, or a per-point radius array for a bubble chart. Default: 0.06 */
|
|
12
|
+
sizes?: number | number[];
|
|
13
|
+
/** Dot color, or a per-point color array. Default: Manim color palette */
|
|
14
|
+
colors?: string | string[];
|
|
15
|
+
/** Fill opacity for the dots. Default: 1 */
|
|
16
|
+
fillOpacity?: number;
|
|
17
|
+
/** Stroke width for the dots. Default: 0 */
|
|
18
|
+
strokeWidth?: number;
|
|
19
|
+
/** An existing Axes to plot onto. When omitted, one is built from the data. */
|
|
20
|
+
axes?: Axes;
|
|
21
|
+
/** X-axis range override as [min, max] or [min, max, step]. */
|
|
22
|
+
xRange?: [number, number] | [number, number, number];
|
|
23
|
+
/** Y-axis range override as [min, max] or [min, max, step]. */
|
|
24
|
+
yRange?: [number, number] | [number, number, number];
|
|
25
|
+
/** Visual length of the x-axis when auto-building axes. Default: 8 */
|
|
26
|
+
xLength?: number;
|
|
27
|
+
/** Visual length of the y-axis when auto-building axes. Default: 6 */
|
|
28
|
+
yLength?: number;
|
|
29
|
+
/** Color for the axes when auto-building. Default: '#ffffff' */
|
|
30
|
+
axisColor?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* ScatterPlot - points plotted as dots on a coordinate system.
|
|
34
|
+
*
|
|
35
|
+
* Each (x, y) pair becomes a Dot. Per-point sizes and colors turn the plot
|
|
36
|
+
* into a bubble chart. When no Axes is supplied, one is built to fit the data.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const plot = new ScatterPlot({
|
|
41
|
+
* x: [1, 2, 3, 4],
|
|
42
|
+
* y: [2, 1, 4, 3],
|
|
43
|
+
* sizes: [0.05, 0.1, 0.15, 0.2],
|
|
44
|
+
* colors: ['#ff0000', '#00ff00'],
|
|
45
|
+
* });
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare class ScatterPlot extends Group {
|
|
49
|
+
/** The coordinate system the points are plotted on. */
|
|
50
|
+
axes: Axes;
|
|
51
|
+
/** The plotted dots, one per (x, y) pair. */
|
|
52
|
+
dots: VGroup;
|
|
53
|
+
protected _x: number[];
|
|
54
|
+
protected _y: number[];
|
|
55
|
+
constructor(options: ScatterPlotOptions);
|
|
56
|
+
/** Get the coordinate system. */
|
|
57
|
+
getAxes(): Axes;
|
|
58
|
+
/** Get the group of plotted dots. */
|
|
59
|
+
getDots(): VGroup;
|
|
60
|
+
/** Get a single dot by point index, or undefined when out of range. */
|
|
61
|
+
getDot(index: number): Dot | undefined;
|
|
62
|
+
/** The number of plotted points. */
|
|
63
|
+
get numPoints(): number;
|
|
64
|
+
copy(): ScatterPlot;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=ScatterPlot.d.ts.map
|