figureone 0.15.10 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/figureone.min.js +1 -1
- package/index.js +79167 -0
- package/package.json +15 -1
- package/types/index.d.ts +132 -0
- package/types/js/figure/Animation/Animation.d.ts +36 -0
- package/types/js/figure/Animation/AnimationBuilder.d.ts +173 -0
- package/types/js/figure/Animation/AnimationManager.d.ts +392 -0
- package/types/js/figure/Animation/AnimationStep/CustomStep.d.ts +99 -0
- package/types/js/figure/Animation/AnimationStep/DelayStep.d.ts +24 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/ColorAnimationStep.d.ts +203 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/OpacityAnimationStep.d.ts +220 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/PositionAnimationStep.d.ts +124 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/PulseAnimationStep.d.ts +137 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/PulseTransformAnimationStep.d.ts +52 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/RotationAnimationStep.d.ts +119 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/ScaleAnimationStep.d.ts +93 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/ScenarioAnimationStep.d.ts +204 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/TransformAnimationStep.d.ts +163 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep.d.ts +56 -0
- package/types/js/figure/Animation/AnimationStep/ParallelAnimationStep.d.ts +70 -0
- package/types/js/figure/Animation/AnimationStep/SerialAnimationStep.d.ts +84 -0
- package/types/js/figure/Animation/AnimationStep/TriggerStep.d.ts +106 -0
- package/types/js/figure/Animation/AnimationStep.d.ts +110 -0
- package/types/js/figure/DrawContext2D.d.ts +9 -0
- package/types/js/figure/DrawingObjects/DrawingObject.d.ts +45 -0
- package/types/js/figure/DrawingObjects/GLObject/GLObject.d.ts +146 -0
- package/types/js/figure/DrawingObjects/HTMLObject/HTMLObject.d.ts +29 -0
- package/types/js/figure/DrawingObjects/TextObject/TextObject.d.ts +94 -0
- package/types/js/figure/DrawingObjects/TextObject/glyphMeasures.d.ts +7 -0
- package/types/js/figure/DrawingObjects/VertexObject/VertexGeneric.d.ts +21 -0
- package/types/js/figure/DrawingObjects/VertexObject/VertexObject.d.ts +0 -0
- package/types/js/figure/DrawingObjects/VertexObject/VertexText.d.ts +34 -0
- package/types/js/figure/Element.d.ts +1212 -0
- package/types/js/figure/Equation/Elements/BaseAnnotationFunction.d.ts +118 -0
- package/types/js/figure/Equation/Elements/BaseEquationFunction.d.ts +20 -0
- package/types/js/figure/Equation/Elements/Bounds.d.ts +49 -0
- package/types/js/figure/Equation/Elements/Color.d.ts +7 -0
- package/types/js/figure/Equation/Elements/Container.d.ts +5 -0
- package/types/js/figure/Equation/Elements/Element.d.ts +95 -0
- package/types/js/figure/Equation/Elements/Fraction.d.ts +5 -0
- package/types/js/figure/Equation/Elements/Lines.d.ts +5 -0
- package/types/js/figure/Equation/Elements/Matrix.d.ts +5 -0
- package/types/js/figure/Equation/Elements/Offset.d.ts +5 -0
- package/types/js/figure/Equation/Elements/Scale.d.ts +5 -0
- package/types/js/figure/Equation/Equation.d.ts +984 -0
- package/types/js/figure/Equation/EquationForm.d.ts +139 -0
- package/types/js/figure/Equation/EquationFunctions.d.ts +3367 -0
- package/types/js/figure/Equation/EquationSymbols.d.ts +1646 -0
- package/types/js/figure/Equation/HTMLEquation.d.ts +56 -0
- package/types/js/figure/Equation/Symbols/AngleBracket.d.ts +6 -0
- package/types/js/figure/Equation/Symbols/Arrow.d.ts +17 -0
- package/types/js/figure/Equation/Symbols/Bar.d.ts +6 -0
- package/types/js/figure/Equation/Symbols/Box.d.ts +11 -0
- package/types/js/figure/Equation/Symbols/Brace.d.ts +6 -0
- package/types/js/figure/Equation/Symbols/Bracket.d.ts +8 -0
- package/types/js/figure/Equation/Symbols/Division.d.ts +8 -0
- package/types/js/figure/Equation/Symbols/Integral.d.ts +7 -0
- package/types/js/figure/Equation/Symbols/Line.d.ts +5 -0
- package/types/js/figure/Equation/Symbols/Product.d.ts +6 -0
- package/types/js/figure/Equation/Symbols/Radical.d.ts +9 -0
- package/types/js/figure/Equation/Symbols/SquareBracket.d.ts +6 -0
- package/types/js/figure/Equation/Symbols/Strike.d.ts +8 -0
- package/types/js/figure/Equation/Symbols/Sum.d.ts +6 -0
- package/types/js/figure/Equation/Symbols/SymbolNew.d.ts +15 -0
- package/types/js/figure/Equation/Symbols/Vinculum.d.ts +6 -0
- package/types/js/figure/Figure.d.ts +711 -0
- package/types/js/figure/FigureCollections/Angle.d.ts +766 -0
- package/types/js/figure/FigureCollections/Axis.d.ts +517 -0
- package/types/js/figure/FigureCollections/Axis3.d.ts +118 -0
- package/types/js/figure/FigureCollections/Button.d.ts +195 -0
- package/types/js/figure/FigureCollections/EquationLabel.d.ts +77 -0
- package/types/js/figure/FigureCollections/FigureCollections.d.ts +122 -0
- package/types/js/figure/FigureCollections/Legend.d.ts +270 -0
- package/types/js/figure/FigureCollections/Line.d.ts +587 -0
- package/types/js/figure/FigureCollections/Plot.d.ts +558 -0
- package/types/js/figure/FigureCollections/PolyLine.d.ts +487 -0
- package/types/js/figure/FigureCollections/Rectangle.d.ts +235 -0
- package/types/js/figure/FigureCollections/SlideNavigator.d.ts +255 -0
- package/types/js/figure/FigureCollections/Slider.d.ts +155 -0
- package/types/js/figure/FigureCollections/Text.d.ts +307 -0
- package/types/js/figure/FigureCollections/Toggle.d.ts +185 -0
- package/types/js/figure/FigureCollections/Trace.d.ts +237 -0
- package/types/js/figure/FigurePrimitives/FigureElementPrimitive2DText.d.ts +119 -0
- package/types/js/figure/FigurePrimitives/FigureElementPrimitiveGLText.d.ts +94 -0
- package/types/js/figure/FigurePrimitives/FigureElementPrimitiveGesture.d.ts +536 -0
- package/types/js/figure/FigurePrimitives/FigureElementPrimitiveMorph.d.ts +175 -0
- package/types/js/figure/FigurePrimitives/FigurePrimitiveTypes.d.ts +788 -0
- package/types/js/figure/FigurePrimitives/FigurePrimitiveTypes2D.d.ts +1324 -0
- package/types/js/figure/FigurePrimitives/FigurePrimitiveTypes3D.d.ts +1105 -0
- package/types/js/figure/FigurePrimitives/FigurePrimitives.d.ts +173 -0
- package/types/js/figure/FigurePrimitives/Generic.d.ts +5 -0
- package/types/js/figure/FigurePrimitives/Text.d.ts +17 -0
- package/types/js/figure/FontManager.d.ts +113 -0
- package/types/js/figure/Gesture.d.ts +39 -0
- package/types/js/figure/Recorder/Recorder.d.ts +291 -0
- package/types/js/figure/Recorder/parseState.d.ts +3 -0
- package/types/js/figure/Recorder/recorder.worker.d.ts +1 -0
- package/types/js/figure/Recorder/state.d.ts +7 -0
- package/types/js/figure/SlideNavigator.d.ts +606 -0
- package/types/js/figure/TimeKeeper.d.ts +174 -0
- package/types/js/figure/geometries/arc.d.ts +18 -0
- package/types/js/figure/geometries/arrow.d.ts +215 -0
- package/types/js/figure/geometries/buffer.d.ts +4 -0
- package/types/js/figure/geometries/copy/copy.d.ts +178 -0
- package/types/js/figure/geometries/ellipse.d.ts +17 -0
- package/types/js/figure/geometries/line.d.ts +13 -0
- package/types/js/figure/geometries/lines/corners.d.ts +7 -0
- package/types/js/figure/geometries/lines/dashes.d.ts +23 -0
- package/types/js/figure/geometries/lines/lines.d.ts +31 -0
- package/types/js/figure/geometries/polygon/polygon.d.ts +12 -0
- package/types/js/figure/geometries/rectangle.d.ts +19 -0
- package/types/js/figure/geometries/triangle.d.ts +27 -0
- package/types/js/figure/webgl/Atlas.d.ts +42 -0
- package/types/js/figure/webgl/shaders.d.ts +143 -0
- package/types/js/figure/webgl/target.d.ts +9 -0
- package/types/js/figure/webgl/webgl.d.ts +54 -0
- package/types/js/tools/FunctionMap.d.ts +69 -0
- package/types/js/tools/color.d.ts +11 -0
- package/types/js/tools/colorNames.d.ts +2 -0
- package/types/js/tools/d2/polygon.d.ts +60 -0
- package/types/js/tools/d2/triangles.d.ts +0 -0
- package/types/js/tools/d3/cone.d.ts +57 -0
- package/types/js/tools/d3/cube.d.ts +26 -0
- package/types/js/tools/d3/cylinder.d.ts +45 -0
- package/types/js/tools/d3/line3.d.ts +55 -0
- package/types/js/tools/d3/prism.d.ts +49 -0
- package/types/js/tools/d3/revolve.d.ts +87 -0
- package/types/js/tools/d3/sphere.d.ts +33 -0
- package/types/js/tools/d3/surface.d.ts +47 -0
- package/types/js/tools/g2.d.ts +242 -0
- package/types/js/tools/geometry/Bounds.d.ts +446 -0
- package/types/js/tools/geometry/Line.d.ts +314 -0
- package/types/js/tools/geometry/Path.d.ts +67 -0
- package/types/js/tools/geometry/Plane.d.ts +201 -0
- package/types/js/tools/geometry/Point.d.ts +359 -0
- package/types/js/tools/geometry/Rect.d.ts +115 -0
- package/types/js/tools/geometry/Transform.d.ts +623 -0
- package/types/js/tools/geometry/angle.d.ts +105 -0
- package/types/js/tools/geometry/common.d.ts +9 -0
- package/types/js/tools/geometry/coordinates.d.ts +30 -0
- package/types/js/tools/geometry/deceleration.d.ts +13 -0
- package/types/js/tools/geometry/polygon.d.ts +4 -0
- package/types/js/tools/geometry/quaternion.d.ts +15 -0
- package/types/js/tools/geometry/scene.d.ts +282 -0
- package/types/js/tools/geometry/tools.d.ts +8 -0
- package/types/js/tools/geometry/types.d.ts +2 -0
- package/types/js/tools/getCssColors.d.ts +1 -0
- package/types/js/tools/getCssVariables.d.ts +4 -0
- package/types/js/tools/getImageData.d.ts +1 -0
- package/types/js/tools/getScssColors.d.ts +2 -0
- package/types/js/tools/htmlGenerator.d.ts +85 -0
- package/types/js/tools/m2.d.ts +24 -0
- package/types/js/tools/m3.d.ts +71 -0
- package/types/js/tools/math.d.ts +112 -0
- package/types/js/tools/morph.d.ts +651 -0
- package/types/js/tools/styleSheets.d.ts +3 -0
- package/types/js/tools/tools.d.ts +281 -0
- package/types/js/tools/types.d.ts +305 -0
- package/figureone.worker.js +0 -1
|
@@ -0,0 +1,558 @@
|
|
|
1
|
+
import { Point, Rect } from '../../tools/g2';
|
|
2
|
+
import type { TypeParsablePoint } from '../../tools/g2';
|
|
3
|
+
import { FigureElementCollection, FigureElement } from '../Element';
|
|
4
|
+
import type CollectionsAxis from './Axis';
|
|
5
|
+
import type { COL_Axis } from './Axis';
|
|
6
|
+
import type CollectionsTrace from './Trace';
|
|
7
|
+
import type { COL_Trace } from './Trace';
|
|
8
|
+
import type { COL_PlotLegend } from './Legend';
|
|
9
|
+
import type CollectionsRectangle from './Rectangle';
|
|
10
|
+
import type { COL_Rectangle } from './Rectangle';
|
|
11
|
+
import type { OBJ_Collection, OBJ_LineStyleSimple, OBJ_Texture } from '../FigurePrimitives/FigurePrimitiveTypes';
|
|
12
|
+
import type { OBJ_FormattedText } from './Text';
|
|
13
|
+
import type { OBJ_Font, TypeColor, OBJ_Font_Fixed, OBJ_CurvedCorner } from '../../tools/types';
|
|
14
|
+
import type FigureCollections from './FigureCollections';
|
|
15
|
+
/**
|
|
16
|
+
* Gesture area extension. `left` and `bottom` should be negative numbers
|
|
17
|
+
* if extending beyond the plot area.
|
|
18
|
+
*
|
|
19
|
+
* @property {number} [left]
|
|
20
|
+
* @property {number} [right]
|
|
21
|
+
* @property {number} [top]
|
|
22
|
+
* @property {number} [bottom]
|
|
23
|
+
* @interface
|
|
24
|
+
* @group Misc Shapes
|
|
25
|
+
*/
|
|
26
|
+
export type OBJ_GestureArea = {
|
|
27
|
+
left?: number;
|
|
28
|
+
right?: number;
|
|
29
|
+
top?: number;
|
|
30
|
+
bottom?: number;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Plot frame.
|
|
34
|
+
*
|
|
35
|
+
*
|
|
36
|
+
* @property {OBJ_LineStyleSimple} [line] line detail
|
|
37
|
+
* @property {TypeColor | OBJ_Texture} [fill] fill detail
|
|
38
|
+
* @property {OBJ_CurvedCorner} [corner] define if need curved corners
|
|
39
|
+
* @property {number} [space] space between plot, labels and title and frame
|
|
40
|
+
* boundary
|
|
41
|
+
* @interface
|
|
42
|
+
* @group Misc Shapes
|
|
43
|
+
*/
|
|
44
|
+
export type OBJ_PlotFrame = {
|
|
45
|
+
line?: OBJ_LineStyleSimple;
|
|
46
|
+
fill?: TypeColor | OBJ_Texture;
|
|
47
|
+
corner?: OBJ_CurvedCorner;
|
|
48
|
+
space?: number;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* @property {'x' | 'y' | 'xy'} [axis] which axis to zoom (`xy`)
|
|
52
|
+
* @property {number} [pinchSensitivity] pinch zoom sensitivity
|
|
53
|
+
* where >1 is more sensitive and <1 is less sensitive (`1`)
|
|
54
|
+
* @property {number} [wheelSensitivity] mouse wheel sensitivity
|
|
55
|
+
* where >1 is more sensitive and <1 is less sensitive (`1`)
|
|
56
|
+
* @property {TypeParsablePoint | number} [value] fix value to zoom on - will
|
|
57
|
+
* override pinch or mouse wheel zoom location
|
|
58
|
+
* @property {null | number} [min] minimum zoom where `null` is no limit
|
|
59
|
+
* (`null`)
|
|
60
|
+
* @property {null | number} [max] maximum zoom where `null` is no limit
|
|
61
|
+
* (`null`)
|
|
62
|
+
* @interface
|
|
63
|
+
* @group Misc Shapes
|
|
64
|
+
*/
|
|
65
|
+
export type OBJ_PlotZoomOptions = {
|
|
66
|
+
axis?: 'x' | 'y' | 'xy';
|
|
67
|
+
wheelSensitivity?: number;
|
|
68
|
+
pinchSensitivity?: number;
|
|
69
|
+
value?: TypeParsablePoint | number;
|
|
70
|
+
min?: null | number;
|
|
71
|
+
max?: null | number;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* @property {'x' | 'y' | 'xy'} [axis] which axis to zoom (`xy`)
|
|
75
|
+
* @property {number} [wheelSensitivity] mouse wheel sensitivity
|
|
76
|
+
* where >1 is more sensitive and <1 is less sensitive (`1`)
|
|
77
|
+
* @property {boolean} [wheel] enable mouse wheel to pan (`true`)
|
|
78
|
+
* @property {boolean} [momentum] enable panning momentum (`true`)
|
|
79
|
+
* @property {number} [maxVelocity] maximum panning velocity (`10`)
|
|
80
|
+
* @interface
|
|
81
|
+
* @group Misc Shapes
|
|
82
|
+
*/
|
|
83
|
+
export type OBJ_PlotPanOptions = {
|
|
84
|
+
axis: 'x' | 'y' | 'xy';
|
|
85
|
+
wheelSensitivity?: number;
|
|
86
|
+
wheel?: boolean;
|
|
87
|
+
momentum?: boolean;
|
|
88
|
+
maxVelocity?: number;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* An axis definition for a plot is the same as that for an
|
|
92
|
+
* {@link CollectionsAxis} with an additional property `location` which can be
|
|
93
|
+
* used to conveniently set the axis `position`. Note, if `position` is set in
|
|
94
|
+
* the axis definition, then it will override `location`.
|
|
95
|
+
*
|
|
96
|
+
* @extends {COL_Axis}
|
|
97
|
+
*
|
|
98
|
+
* @property {OBJ_PlotAxis} [location]
|
|
99
|
+
* @interface
|
|
100
|
+
* @group Misc Shapes
|
|
101
|
+
*/
|
|
102
|
+
export type OBJ_PlotAxis = {
|
|
103
|
+
location?: 'left' | 'right' | 'top' | 'bottom';
|
|
104
|
+
} & COL_Axis;
|
|
105
|
+
/**
|
|
106
|
+
* Plot area label buffer where a positive value is more buffer
|
|
107
|
+
* @property {number} [left]
|
|
108
|
+
* @property {number} [right]
|
|
109
|
+
* @property {number} [top]
|
|
110
|
+
* @property {number} [bottom]
|
|
111
|
+
* @interface
|
|
112
|
+
* @group Misc Shapes
|
|
113
|
+
*/
|
|
114
|
+
export type OBJ_PlotAreaLabelBuffer = {
|
|
115
|
+
left?: number;
|
|
116
|
+
right?: number;
|
|
117
|
+
top?: number;
|
|
118
|
+
bottom?: number;
|
|
119
|
+
};
|
|
120
|
+
export type OBJ_PlotAreaLabelBufferFixed = {
|
|
121
|
+
left: number;
|
|
122
|
+
right: number;
|
|
123
|
+
top: number;
|
|
124
|
+
bottom: number;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Plot title.
|
|
128
|
+
*
|
|
129
|
+
* {@link OBJ_TextLines}` & { offset: `{@link TypeParsablePoint}` }`
|
|
130
|
+
*
|
|
131
|
+
* Use `offset` to adjust the location of the title.
|
|
132
|
+
* @interface
|
|
133
|
+
* @group Misc Shapes
|
|
134
|
+
*/
|
|
135
|
+
export type OBJ_PlotTitle = OBJ_FormattedText & {
|
|
136
|
+
offset: TypeParsablePoint;
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* {@link CollectionsPlot} options object that extends {@link OBJ_Collection}
|
|
140
|
+
* options object (without `parent`).
|
|
141
|
+
*
|
|
142
|
+
* A plot is a collection of axes and traces, and may include a title, legend
|
|
143
|
+
* and bounding frame.
|
|
144
|
+
*
|
|
145
|
+
* Use `width`, `height` and `position` to define the size of the plot area
|
|
146
|
+
* (area where the traces are drawn) and where it is in the figure.
|
|
147
|
+
*
|
|
148
|
+
* @extends OBJ_Collection
|
|
149
|
+
*
|
|
150
|
+
* @property {number} [width] width of the plot area
|
|
151
|
+
* @property {number} [height] height of the plot area
|
|
152
|
+
* @property {OBJ_PlotAxis | boolean} [x] customize the x axis, or use `false`
|
|
153
|
+
* to hide it
|
|
154
|
+
* @property {OBJ_PlotAxis | boolean} [y] customize the y axis, or use `false`
|
|
155
|
+
* to hide it
|
|
156
|
+
* @property {Array<OBJ_PlotAxis>} [axes] add axes additional to x and y
|
|
157
|
+
* @property {boolean} [grid] turn on and off the grid - use the grid options
|
|
158
|
+
* in x axis, y axis or axes for finer customization
|
|
159
|
+
* @property {OBJ_PlotTitle | string} [title] plot title can be simply a
|
|
160
|
+
* `string` or fully customized with OBJ_PlotTitle
|
|
161
|
+
* @property {Array<COL_Trace | TypeParsablePoint> | COL_Trace | Array<TypeParsablePoint>} [trace]
|
|
162
|
+
* Use array if plotting more than one trace. Use COL_Trace to customize the
|
|
163
|
+
* trace.
|
|
164
|
+
* @property {COL_PlotLegend | boolean} [legend] `true` to turn the legend on,
|
|
165
|
+
* or use COL_PlotLegend to customize it's location and layout
|
|
166
|
+
* @property {boolean | TypeColor | OBJ_PlotFrame} [frame] frame around the
|
|
167
|
+
* plot can be turned on with `true`, can be a simple color fill using
|
|
168
|
+
* `Array<number>` as a color, or can be fully customized with OBJ_PlotFrame
|
|
169
|
+
* @property {TypeColor | COL_Rectangle} [plotArea] plot area can be a
|
|
170
|
+
* color fill with `TypeColor` as a color, or be fully customized with
|
|
171
|
+
* COL_Rectangle
|
|
172
|
+
* @property {OBJ_Font} [font] Default font for plot (title, axes, labels, etc.)
|
|
173
|
+
* @property {TypeColor} [color] Default color
|
|
174
|
+
* @property {TypeParsablePoint} [position] Position of the plot
|
|
175
|
+
* @property {OBJ_PlotZoomOptions | 'x' | 'y' | 'xy'} [zoom] options for
|
|
176
|
+
* interactive zooming
|
|
177
|
+
* @property {OBJ_PlotPanOptions | 'x' | 'y' | 'xy'} [pan] options for
|
|
178
|
+
* interactive panning
|
|
179
|
+
* @property {TypeParsablePoint} [cross] value where the default x and y
|
|
180
|
+
* axes should cross. If defined, each `axis.position` will be overridden. If
|
|
181
|
+
* the cross point is outside of the plot area, then the axes will be drawn on
|
|
182
|
+
* the border of the plot area. (`undefined`)
|
|
183
|
+
* @property {boolean | OBJ_PlotAreaLabelBuffer} [plotAreaLabels] if `true`
|
|
184
|
+
* then axes with a cross point
|
|
185
|
+
* will be drawn such that the labels stay within the plot area. So, if the
|
|
186
|
+
* labels are on the left side of a y axis, and the cross point is out of the
|
|
187
|
+
* plot area to the left, then instead of the axis being drawn on the left edge
|
|
188
|
+
* of the plot area, it will be drawn within the plot area such that its labels
|
|
189
|
+
* are within the plot area (`false`).
|
|
190
|
+
* @property {boolean} [autoGrid] if `true` sets the grid for an axes to expand
|
|
191
|
+
* accross the entire plot area. Set to `false` if only a partial length grid
|
|
192
|
+
* is needed (`true`)
|
|
193
|
+
* @property {'box' | 'numberLine' | 'positiveNumberLine'} [styleTheme] defines
|
|
194
|
+
* default values for tick, label, axis locations and cross points. (`'box'`)
|
|
195
|
+
* @property {'light' | 'dark'} [colorTheme] defines defaul colors. `'dark'`
|
|
196
|
+
* theme is better on light backgrounds while '`light'` theme is better on dark
|
|
197
|
+
* backgrounds (`'dark'`)
|
|
198
|
+
* @property {OBJ_GestureArea} [gestureArea] the gesture area is the plot area
|
|
199
|
+
* by default. Use this property to extend the gesture area beyond the plot
|
|
200
|
+
* area. This is useful for the user to zoom in on areas on the edge of the
|
|
201
|
+
* plot area.
|
|
202
|
+
* @interface
|
|
203
|
+
* @group 2D Shape Collections
|
|
204
|
+
*/
|
|
205
|
+
export type COL_Plot = {
|
|
206
|
+
width?: number;
|
|
207
|
+
height?: number;
|
|
208
|
+
x?: OBJ_PlotAxis | boolean;
|
|
209
|
+
y?: OBJ_PlotAxis | boolean;
|
|
210
|
+
axes?: Array<OBJ_PlotAxis>;
|
|
211
|
+
cross?: TypeParsablePoint | null;
|
|
212
|
+
grid?: boolean;
|
|
213
|
+
title?: string | OBJ_PlotTitle;
|
|
214
|
+
trace?: Array<COL_Trace | TypeParsablePoint> | COL_Trace | Array<TypeParsablePoint>;
|
|
215
|
+
legend?: COL_PlotLegend;
|
|
216
|
+
frame?: boolean | TypeColor | OBJ_PlotFrame;
|
|
217
|
+
plotArea?: TypeColor | COL_Rectangle;
|
|
218
|
+
font?: OBJ_Font;
|
|
219
|
+
color?: TypeColor;
|
|
220
|
+
position?: TypeParsablePoint;
|
|
221
|
+
zoom?: OBJ_PlotZoomOptions | 'x' | 'y' | 'xy';
|
|
222
|
+
pan?: OBJ_PlotPanOptions | 'x' | 'y' | 'xy';
|
|
223
|
+
gestureArea?: OBJ_GestureArea;
|
|
224
|
+
autoGrid?: boolean;
|
|
225
|
+
plotAreaLabels?: boolean | OBJ_PlotAreaLabelBuffer;
|
|
226
|
+
styleTheme?: 'box' | 'numberLine' | 'positiveNumberLine';
|
|
227
|
+
colorTheme?: 'light' | 'dark';
|
|
228
|
+
} & OBJ_Collection;
|
|
229
|
+
/**
|
|
230
|
+
* {@link FigureElementCollection} representing a plot including axes, traces,
|
|
231
|
+
* labels and titles.
|
|
232
|
+
*
|
|
233
|
+
* 
|
|
234
|
+
*
|
|
235
|
+
* 
|
|
236
|
+
*
|
|
237
|
+
* 
|
|
238
|
+
*
|
|
239
|
+
* 
|
|
240
|
+
*
|
|
241
|
+
* 
|
|
242
|
+
*
|
|
243
|
+
* 
|
|
244
|
+
*
|
|
245
|
+
* 
|
|
246
|
+
*
|
|
247
|
+
* This object provides convient and customizable plot functionality.
|
|
248
|
+
*
|
|
249
|
+
* At its simplist, just the points of the trace to be plotted need to be
|
|
250
|
+
* passed in to get a plot with automatically generated axes, tick marks,
|
|
251
|
+
* labels and grid lines.
|
|
252
|
+
*
|
|
253
|
+
* Additional options can be used to finely customize each of these, as well
|
|
254
|
+
* as add and customize plot and axis titles, a legend, and a frame around the
|
|
255
|
+
* entire plot.
|
|
256
|
+
*
|
|
257
|
+
* Plots can also be interactive, with both zoom and pan functionality from
|
|
258
|
+
* mouse, mouse wheel, touch and pinch gestures.
|
|
259
|
+
*
|
|
260
|
+
* @see
|
|
261
|
+
* See {@link COL_Axis}, {@link OBJ_AxisLabels}, {@link OBJ_AxisTicks},
|
|
262
|
+
* {@link COL_Trace} and {@link COL_PlotLegend} for more examples of customizing
|
|
263
|
+
* specific parts of the plot.
|
|
264
|
+
*
|
|
265
|
+
* To test examples below, append them to the
|
|
266
|
+
* <a href="#drawing-boilerplate">boilerplate</a>.
|
|
267
|
+
*
|
|
268
|
+
* All examples below also use this power function to generate the traces:
|
|
269
|
+
* ```javascript
|
|
270
|
+
* const pow = (pow = 2, start = 0, stop = 10, step = 0.05) => {
|
|
271
|
+
* const xValues = Fig.range(start, stop, step);
|
|
272
|
+
* return xValues.map(x => new Fig.Point(x, x ** pow));
|
|
273
|
+
* }
|
|
274
|
+
* ```
|
|
275
|
+
* @example
|
|
276
|
+
* // Plot of single trace with auto axis scaling
|
|
277
|
+
* figure.add({
|
|
278
|
+
* make: 'collections.plot',
|
|
279
|
+
* trace: pow(),
|
|
280
|
+
* });
|
|
281
|
+
*
|
|
282
|
+
* @example
|
|
283
|
+
* // Multiple traces with a legend
|
|
284
|
+
* // Some traces are customized beyond the default color to include dashes and
|
|
285
|
+
* // markers
|
|
286
|
+
* figure.add({
|
|
287
|
+
* make: 'collections.plot',
|
|
288
|
+
* width: 2, // Plot width in figure
|
|
289
|
+
* height: 2, // Plot height in figure
|
|
290
|
+
* y: { start: 0, stop: 50 }, // Customize y axis limits
|
|
291
|
+
* trace: [
|
|
292
|
+
* { points: pow(1.5), name: 'Power 1.5' }, // Trace names are for legend
|
|
293
|
+
* { // Trace with only markers
|
|
294
|
+
* points: pow(2, 0, 10, 0.5),
|
|
295
|
+
* name: 'Power 2',
|
|
296
|
+
* markers: { sides: 4, radius: 0.03 },
|
|
297
|
+
* },
|
|
298
|
+
* { // Trace with markers and
|
|
299
|
+
* points: pow(3, 0, 10, 0.5), // dashed line
|
|
300
|
+
* name: 'Power 3',
|
|
301
|
+
* markers: { radius: 0.03, sides: 10, line: { width: 0.005 } },
|
|
302
|
+
* line: { dash: [0.04, 0.01] },
|
|
303
|
+
* },
|
|
304
|
+
* ],
|
|
305
|
+
* legend: true,
|
|
306
|
+
* });
|
|
307
|
+
*
|
|
308
|
+
* @example
|
|
309
|
+
* // Multiple grids and simple titles
|
|
310
|
+
* figure.add({
|
|
311
|
+
* make: 'collections.plot',
|
|
312
|
+
* y: {
|
|
313
|
+
* start: -50,
|
|
314
|
+
* stop: 50,
|
|
315
|
+
* step: [25, 5],
|
|
316
|
+
* grid: [
|
|
317
|
+
* true,
|
|
318
|
+
* { width: 0.005, dash: [0.01, 0.01], color: [1, 0.7, 0.7, 1] },
|
|
319
|
+
* ],
|
|
320
|
+
* title: 'velocity (m/s)',
|
|
321
|
+
* },
|
|
322
|
+
* x: {
|
|
323
|
+
* start: -5,
|
|
324
|
+
* stop: 5,
|
|
325
|
+
* step: [2.5, 0.5, 0.1],
|
|
326
|
+
* grid: [
|
|
327
|
+
* true,
|
|
328
|
+
* { width: 0.005, dash: [0.01, 0.01], color: [1, 0.7, 0.7, 1] },
|
|
329
|
+
* ],
|
|
330
|
+
* title: 'time (s)',
|
|
331
|
+
* },
|
|
332
|
+
* trace: pow(3, -10, 10),
|
|
333
|
+
* title: 'Velocity over Time',
|
|
334
|
+
* });
|
|
335
|
+
*
|
|
336
|
+
* @example
|
|
337
|
+
* // Hide axes
|
|
338
|
+
* // Use plot frame and plot area
|
|
339
|
+
* // Title has a subtitle
|
|
340
|
+
* figure.add({
|
|
341
|
+
* make: 'collections.plot',
|
|
342
|
+
* trace: pow(3),
|
|
343
|
+
* x: { show: false },
|
|
344
|
+
* y: { show: false },
|
|
345
|
+
* plotArea: [0.93, 0.93, 0.93, 1],
|
|
346
|
+
* frame: {
|
|
347
|
+
* line: { width: 0.005, color: [0.5, 0.5, 0.5, 1] },
|
|
348
|
+
* corner: { radius: 0.1, sides: 10 },
|
|
349
|
+
* space: 0.15,
|
|
350
|
+
* },
|
|
351
|
+
* title: {
|
|
352
|
+
* text: [
|
|
353
|
+
* 'Velocity over Time',
|
|
354
|
+
* { text: 'For object A', lineSpace: 0.13, font: { size: 0.08 } },
|
|
355
|
+
* ],
|
|
356
|
+
* offset: [0, 0],
|
|
357
|
+
* },
|
|
358
|
+
* });
|
|
359
|
+
*
|
|
360
|
+
* @example
|
|
361
|
+
* // Secondary y axis
|
|
362
|
+
* figure.add({
|
|
363
|
+
* make: 'collections.plot',
|
|
364
|
+
* trace: pow(2),
|
|
365
|
+
* y: {
|
|
366
|
+
* title: {
|
|
367
|
+
* text: 'velocity (m/s)',
|
|
368
|
+
* rotation: 0,
|
|
369
|
+
* xAlign: 'right',
|
|
370
|
+
* },
|
|
371
|
+
* },
|
|
372
|
+
* x: { title: 'time (s)' },
|
|
373
|
+
* axes: [
|
|
374
|
+
* {
|
|
375
|
+
* axis: 'y',
|
|
376
|
+
* start: 0,
|
|
377
|
+
* stop: 900,
|
|
378
|
+
* step: 300,
|
|
379
|
+
* color: [1, 0, 0, 1],
|
|
380
|
+
* location: 'right',
|
|
381
|
+
* title: {
|
|
382
|
+
* offset: [0.6, 0.1],
|
|
383
|
+
* text: 'displacment (m)',
|
|
384
|
+
* rotation: 0,
|
|
385
|
+
* },
|
|
386
|
+
* },
|
|
387
|
+
* ],
|
|
388
|
+
* position: [-1, -1],
|
|
389
|
+
* });
|
|
390
|
+
*
|
|
391
|
+
* @example
|
|
392
|
+
* // Cartesian axes crossing at the zero point
|
|
393
|
+
* // Automatic layout doesn't support this, but axes, ticks, labels and titles
|
|
394
|
+
* // can all be customized to create it.
|
|
395
|
+
* figure.add({
|
|
396
|
+
* make: 'collections.plot',
|
|
397
|
+
* trace: pow(3, -10, 10),
|
|
398
|
+
* font: { size: 0.1 },
|
|
399
|
+
* styleTheme: 'numberLine',
|
|
400
|
+
* x: {
|
|
401
|
+
* title: {
|
|
402
|
+
* text: 'x',
|
|
403
|
+
* font: { style: 'italic', family: 'Times New Roman', size: 0.15 },
|
|
404
|
+
* },
|
|
405
|
+
* },
|
|
406
|
+
* y: {
|
|
407
|
+
* step: 500,
|
|
408
|
+
* title: {
|
|
409
|
+
* text: 'y',
|
|
410
|
+
* font: { style: 'italic', family: 'Times New Roman', size: 0.15 },
|
|
411
|
+
* },
|
|
412
|
+
* },
|
|
413
|
+
* grid: false,
|
|
414
|
+
* });
|
|
415
|
+
*
|
|
416
|
+
* @example
|
|
417
|
+
* // Zoomable and Pannable plot
|
|
418
|
+
*
|
|
419
|
+
* // Create the points for the plot
|
|
420
|
+
* const points = Array(3000).fill(0).map(() => {
|
|
421
|
+
* const x = Math.random() * 8 - 4;
|
|
422
|
+
* const y = Math.random() / Math.sqrt(2 * Math.PI) * Math.exp(-0.5 * x ** 2);
|
|
423
|
+
* return [x, y];
|
|
424
|
+
* });
|
|
425
|
+
*
|
|
426
|
+
* // Make a zoomable and pannable plot
|
|
427
|
+
* const plot = figure.add({
|
|
428
|
+
* make: 'collections.plot',
|
|
429
|
+
* trace: { points, markers: { sides: 6, radius: 0.01 } },
|
|
430
|
+
* zoom: { axis: 'xy', min: 0.5, max: 16 },
|
|
431
|
+
* pan: true,
|
|
432
|
+
* });
|
|
433
|
+
*
|
|
434
|
+
* // Initialize by zooming in by a magnification factor of 10
|
|
435
|
+
* plot.zoomValue([1.8333, 0.06672], 10);
|
|
436
|
+
*
|
|
437
|
+
* @group 2D Shape Collections
|
|
438
|
+
*/
|
|
439
|
+
declare class CollectionsPlot extends FigureElementCollection {
|
|
440
|
+
_x: CollectionsAxis | null | undefined;
|
|
441
|
+
_y: CollectionsAxis | null | undefined;
|
|
442
|
+
__frame: CollectionsRectangle | null | undefined;
|
|
443
|
+
axes: Array<CollectionsAxis>;
|
|
444
|
+
traces: Array<CollectionsTrace>;
|
|
445
|
+
cross: null | Point;
|
|
446
|
+
defaultFont: OBJ_Font_Fixed;
|
|
447
|
+
width: number;
|
|
448
|
+
height: number;
|
|
449
|
+
colorTheme: string;
|
|
450
|
+
styleTheme: string;
|
|
451
|
+
grid: boolean;
|
|
452
|
+
xAxisShow: boolean;
|
|
453
|
+
yAxisShow: boolean;
|
|
454
|
+
frameSpace: number | null | undefined;
|
|
455
|
+
zoom: {
|
|
456
|
+
x: boolean;
|
|
457
|
+
y: boolean;
|
|
458
|
+
enabled: boolean;
|
|
459
|
+
min: null | number;
|
|
460
|
+
max: null | number;
|
|
461
|
+
};
|
|
462
|
+
pan: {
|
|
463
|
+
x: boolean;
|
|
464
|
+
y: boolean;
|
|
465
|
+
enabled: boolean;
|
|
466
|
+
};
|
|
467
|
+
autoGrid: boolean;
|
|
468
|
+
plotAreaLabels: boolean | OBJ_PlotAreaLabelBufferFixed;
|
|
469
|
+
forceColor: null | TypeColor;
|
|
470
|
+
zoomPoint: null | Point;
|
|
471
|
+
gestureArea: {
|
|
472
|
+
left: number;
|
|
473
|
+
bottom: number;
|
|
474
|
+
top: number;
|
|
475
|
+
right: number;
|
|
476
|
+
};
|
|
477
|
+
/**
|
|
478
|
+
* @hideconstructor
|
|
479
|
+
*/
|
|
480
|
+
constructor(collections: FigureCollections, optionsIn: COL_Plot);
|
|
481
|
+
setupCross(): void;
|
|
482
|
+
setupGrid(): void;
|
|
483
|
+
showGrid(): void;
|
|
484
|
+
hideGrid(): void;
|
|
485
|
+
getNonTraceBoundingRect(): Rect;
|
|
486
|
+
addAxes(axes: Array<OBJ_PlotAxis>): void;
|
|
487
|
+
addPlotArea(plotArea: Array<number> | COL_Rectangle): void;
|
|
488
|
+
addGestureRectangle(zoomOptions: OBJ_PlotZoomOptions | 'xy' | 'x' | 'y' | false, panOptions: OBJ_PlotPanOptions | 'xy' | 'x' | 'y' | false, xAxis: OBJ_PlotAxis, yAxis: OBJ_PlotAxis): void;
|
|
489
|
+
addFrame(frameIn: OBJ_PlotFrame | true | TypeColor): void;
|
|
490
|
+
fontUpdated(): void;
|
|
491
|
+
update(): void;
|
|
492
|
+
getTraceIndex(name: string | number): number;
|
|
493
|
+
addLegend(legendOptions: COL_PlotLegend | boolean): void;
|
|
494
|
+
getAxis(name: string): CollectionsAxis | null;
|
|
495
|
+
getXAxis(): CollectionsAxis | null;
|
|
496
|
+
getYAxis(): CollectionsAxis | null;
|
|
497
|
+
/**
|
|
498
|
+
* Convert a plot point value on the axes `yAxisName` and `xAxisName` to
|
|
499
|
+
* a plot draw space position.
|
|
500
|
+
*
|
|
501
|
+
* The plot draw space is (0, 0) at the bottom
|
|
502
|
+
* left of the plot area and extends to (`width`, `height`) in the top right
|
|
503
|
+
* corner of the plot area where `width` and `height` are defined when
|
|
504
|
+
* creating the plot.
|
|
505
|
+
* @param {TypeParsablePoint} point
|
|
506
|
+
* @param {string = 'x'} xAxisName
|
|
507
|
+
* @param {string = 'y'} yAxisName
|
|
508
|
+
*/
|
|
509
|
+
pointToDraw(point: TypeParsablePoint, xAxisName?: string, yAxisName?: string): Point;
|
|
510
|
+
/**
|
|
511
|
+
* Convert a plot draw space position to a plot point value on the axes
|
|
512
|
+
* `yAxisName` and `xAxisName`.
|
|
513
|
+
*
|
|
514
|
+
* The plot draw space is (0, 0) at the bottom
|
|
515
|
+
* left of the plot area and extends to (`width`, `height`) in the top right
|
|
516
|
+
* corner of the plot area where `width` and `height` are defined when
|
|
517
|
+
* creating the plot.
|
|
518
|
+
* @param {TypeParsablePoint} drawSpacePoint
|
|
519
|
+
* @param {string = 'x'} xAxisName
|
|
520
|
+
* @param {string = 'y'} yAxisName
|
|
521
|
+
*/
|
|
522
|
+
drawToPoint(drawSpacePoint: TypeParsablePoint, xAxisName?: string, yAxisName?: string): Point;
|
|
523
|
+
/**
|
|
524
|
+
* Set a figure element's position to the position in the figure where some
|
|
525
|
+
* point on the plot is.
|
|
526
|
+
* @param {FigureElement} element
|
|
527
|
+
* @param {TypeParsablePoint} point
|
|
528
|
+
*/
|
|
529
|
+
setElementTo(element: FigureElement, point: TypeParsablePoint): void;
|
|
530
|
+
/**
|
|
531
|
+
* Get the plot value where some element is.
|
|
532
|
+
* @param {FigureElement} element
|
|
533
|
+
*/
|
|
534
|
+
getPointAtElement(element: FigureElement): Point;
|
|
535
|
+
addTraces(traces: Array<COL_Trace>): void;
|
|
536
|
+
updateTraces(): void;
|
|
537
|
+
getStyleTheme(name: string, axis?: 'x' | 'y', location?: null | 'left' | 'bottom' | 'right' | 'top' | undefined): Record<string, any>;
|
|
538
|
+
getColorTheme(name: string, defaultColor?: TypeColor | null): Record<string, any>;
|
|
539
|
+
addTitle(optionsIn: OBJ_FormattedText & {
|
|
540
|
+
offset: TypeParsablePoint;
|
|
541
|
+
} | string): void;
|
|
542
|
+
panDeltaValue(deltaValueIn: TypeParsablePoint): void;
|
|
543
|
+
panDeltaDraw(deltaDrawIn: TypeParsablePoint): void;
|
|
544
|
+
panToValue(value: TypeParsablePoint, atDraw: TypeParsablePoint): void;
|
|
545
|
+
zoomValue(valueIn: TypeParsablePoint, mag: number): void;
|
|
546
|
+
zoomDelta(valueIn: TypeParsablePoint, magDelta: number): void;
|
|
547
|
+
/**
|
|
548
|
+
* Get the current zoom.
|
|
549
|
+
* @return {number}
|
|
550
|
+
*/
|
|
551
|
+
getZoom(): any;
|
|
552
|
+
/**
|
|
553
|
+
* Get the current pan.
|
|
554
|
+
* @return {Point}
|
|
555
|
+
*/
|
|
556
|
+
getPan(): Point;
|
|
557
|
+
}
|
|
558
|
+
export default CollectionsPlot;
|