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,517 @@
|
|
|
1
|
+
import { Point } from '../../tools/g2';
|
|
2
|
+
import type { TypeParsablePoint } from '../../tools/g2';
|
|
3
|
+
import { FigureElementCollection, FigureElementPrimitive } from '../Element';
|
|
4
|
+
import type { OBJ_Font, OBJ_Font_Fixed, TypeDash, TypeColor } from '../../tools/types';
|
|
5
|
+
import type { OBJ_Line } from '../FigurePrimitives/FigurePrimitiveTypes2D';
|
|
6
|
+
import type { OBJ_Collection } from '../FigurePrimitives/FigurePrimitiveTypes';
|
|
7
|
+
import type FigureCollections from './FigureCollections';
|
|
8
|
+
import type { OBJ_FormattedText } from './Text';
|
|
9
|
+
import type { TypeArrowHead, OBJ_LineArrows } from '../geometries/arrow';
|
|
10
|
+
import type FigureElementPrimitive2DText from '../FigurePrimitives/FigureElementPrimitive2DText';
|
|
11
|
+
import type FigureElementPrimitiveGLText from '../FigurePrimitives/FigureElementPrimitiveGLText';
|
|
12
|
+
/**
|
|
13
|
+
* Tick location type:
|
|
14
|
+
*
|
|
15
|
+
* `'bottom' | 'left' | 'right' | 'left' | 'center'`
|
|
16
|
+
*
|
|
17
|
+
* `'bottom'`, `'top'` and `'center'` are only for x axes.
|
|
18
|
+
*
|
|
19
|
+
* `'left'`, `'right'` and `'center'` are only for y axes.
|
|
20
|
+
* @group Misc Shapes
|
|
21
|
+
*/
|
|
22
|
+
export type TypeTickLocation = 'bottom' | 'left' | 'right' | 'left' | 'center';
|
|
23
|
+
/**
|
|
24
|
+
* Tick location type:
|
|
25
|
+
*
|
|
26
|
+
* `'bottom' | 'left' | 'right' | 'left'`
|
|
27
|
+
*
|
|
28
|
+
* `'bottom'` and `'top'` are only for x axes.
|
|
29
|
+
*
|
|
30
|
+
* `'left'` and `'right'` are only for y axes.
|
|
31
|
+
*/
|
|
32
|
+
export type TypeLabelLocation = 'bottom' | 'left' | 'right' | 'left';
|
|
33
|
+
/**
|
|
34
|
+
* Object passed to callback function that returns label strings for axis.
|
|
35
|
+
*
|
|
36
|
+
* @property {Array<number>} values
|
|
37
|
+
* @property {number} start start value of axis at current zoom/pan
|
|
38
|
+
* @property {number} stop stop value of axis at current zoom/pan
|
|
39
|
+
* @property {number} step step value for current zoom
|
|
40
|
+
* @property {number} mag zoom magnification
|
|
41
|
+
* @see
|
|
42
|
+
*
|
|
43
|
+
* {@link COL_Axis}
|
|
44
|
+
* @interface
|
|
45
|
+
* @group Misc Shapes
|
|
46
|
+
*/
|
|
47
|
+
export type OBJ_LabelsCallbackParams = {
|
|
48
|
+
values: Array<number>;
|
|
49
|
+
start: number;
|
|
50
|
+
stop: number;
|
|
51
|
+
step: number;
|
|
52
|
+
z: number;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Simple line style.
|
|
56
|
+
*
|
|
57
|
+
* @property {number} [width]
|
|
58
|
+
* @property {TypeDash} [dash]
|
|
59
|
+
* @property {TypeColor} [color]
|
|
60
|
+
* @property {OBJ_LineArrows | TypeArrowHead} [arrow]
|
|
61
|
+
* @property {number} [arrowExt] extension to line length for arrow
|
|
62
|
+
* @interface
|
|
63
|
+
* @group Misc Shapes
|
|
64
|
+
*/
|
|
65
|
+
export type OBJ_AxisLineStyle = {
|
|
66
|
+
width?: number;
|
|
67
|
+
dash?: TypeDash;
|
|
68
|
+
color?: TypeColor;
|
|
69
|
+
arrowExt?: number;
|
|
70
|
+
arrow?: OBJ_LineArrows | TypeArrowHead;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Axis Ticks and Grid options object for {@link COL_Axis}.
|
|
74
|
+
*
|
|
75
|
+
* @property {number} [length] length of the ticks/grid (draw space)
|
|
76
|
+
* @property {number} [offset] offset of the ticks/grid (draw space) - use this
|
|
77
|
+
* to center ticks around the axis or not (`-length / 2`)
|
|
78
|
+
* @property {number} [width] width of ticks/grid (draw space)
|
|
79
|
+
* @property {TypeDash} [dash] dash style of ticks (draw space)
|
|
80
|
+
* @property {TypeColor} [color] color of ticks/grid (defaults to plot color)
|
|
81
|
+
* @property {TypeTickLocation} [location] location of tick which if defined
|
|
82
|
+
* will overrides `offset` (`undefined`)
|
|
83
|
+
*
|
|
84
|
+
* @see
|
|
85
|
+
*
|
|
86
|
+
* {@link COL_Axis}
|
|
87
|
+
* @interface
|
|
88
|
+
* @group Misc Shapes
|
|
89
|
+
*/
|
|
90
|
+
export type OBJ_AxisTicks = {
|
|
91
|
+
length?: number;
|
|
92
|
+
offset?: number;
|
|
93
|
+
width?: number;
|
|
94
|
+
dash?: TypeDash;
|
|
95
|
+
color?: TypeColor;
|
|
96
|
+
location?: TypeTickLocation;
|
|
97
|
+
};
|
|
98
|
+
export type OBJ_AxisTicks_Fixed = {
|
|
99
|
+
length: number;
|
|
100
|
+
offset: number;
|
|
101
|
+
width: number;
|
|
102
|
+
dash?: TypeDash;
|
|
103
|
+
color?: TypeColor;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* @property {Array<number>} values values to offset
|
|
107
|
+
* @property {TypeParsablePoint} offset position offset to apply to values
|
|
108
|
+
* @interface
|
|
109
|
+
* @group Misc Shapes
|
|
110
|
+
*/
|
|
111
|
+
export type OBJ_ValuesOffset = {
|
|
112
|
+
values: Array<number>;
|
|
113
|
+
offset: TypeParsablePoint;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Axis label options object for the {@link COL_Axis}.
|
|
117
|
+
*
|
|
118
|
+
*
|
|
119
|
+
* By default, labels are positioned with the first `ticks` defined in the
|
|
120
|
+
* axis. Labels can also be positioned at custom values with `values`.
|
|
121
|
+
*
|
|
122
|
+
* Labels will be values at the label positions, unless specified as a specific
|
|
123
|
+
* string or number in the `text` property.
|
|
124
|
+
*
|
|
125
|
+
* Different properties are defined in different spaces.
|
|
126
|
+
* - `values`, is defined in axis space, or the values along the axis.
|
|
127
|
+
* - `space` and `offset` are defined in draw space and relate
|
|
128
|
+
* to dimensions in the space the axis is being drawn into.
|
|
129
|
+
*
|
|
130
|
+
* @property {number} [precision] Maximum number of decimal places to be shown
|
|
131
|
+
* @property {number} [precision] Fix the decimal places to the precision (all
|
|
132
|
+
* labels have the same number of decimal places)
|
|
133
|
+
* @property {'decimal' | 'exp'} [format] `'exp'` will present numbers in
|
|
134
|
+
* exponential form (`'decimal'`)
|
|
135
|
+
* @property {number} [space] space between the ticks and the label
|
|
136
|
+
* @property {TypeParsablePoint} [offset] additional offset for the labels
|
|
137
|
+
* (`[0, 0]`)
|
|
138
|
+
* @property {number} [rotation] label rotation (`0`)
|
|
139
|
+
* @property {'left' | 'right' | 'center'} [xAlign] horizontal alignment of
|
|
140
|
+
* labels (`'center'` for x axes, `'right'` for y axes)
|
|
141
|
+
* @property {'bottom' | 'baseline' | 'middle' | 'top'} [yAlign] vertical
|
|
142
|
+
* alignment of labels (`'top'` for x axes, `'middle'` for y axes)
|
|
143
|
+
* @property {OBJ_Font} [font] specific font changes for labels
|
|
144
|
+
* @property {Array<number> | number} [hide] value indexes to hide (`[]`)
|
|
145
|
+
* @property {OBJ_ValuesOffset} [valueOffset] offset the position of selected
|
|
146
|
+
* values (useful to offset values in position near axis cross over points)
|
|
147
|
+
* @property {TypeLabelLocation} [location] location of label (defaults to
|
|
148
|
+
* `'bottom'` for x axis and `'left'` for y axis)
|
|
149
|
+
* @property {Array<string>} [text] use custom labels
|
|
150
|
+
*
|
|
151
|
+
* To test examples below, append them to the
|
|
152
|
+
* <a href="#drawing-boilerplate">boilerplate</a>.
|
|
153
|
+
*
|
|
154
|
+
* For more examples see {@link OBJ_Axis}.
|
|
155
|
+
* @interface
|
|
156
|
+
* @group Misc Shapes
|
|
157
|
+
*/
|
|
158
|
+
export type OBJ_AxisLabels = {
|
|
159
|
+
precision?: number;
|
|
160
|
+
format?: 'decimal' | 'exp';
|
|
161
|
+
space?: number;
|
|
162
|
+
offset?: TypeParsablePoint;
|
|
163
|
+
rotation?: number;
|
|
164
|
+
xAlign?: 'left' | 'right' | 'center';
|
|
165
|
+
yAlign?: 'bottom' | 'baseline' | 'middle' | 'top';
|
|
166
|
+
font?: OBJ_Font;
|
|
167
|
+
hide?: Array<number>;
|
|
168
|
+
valueOffset?: OBJ_ValuesOffset;
|
|
169
|
+
fixed?: boolean;
|
|
170
|
+
location?: TypeLabelLocation;
|
|
171
|
+
text?: Array<string>;
|
|
172
|
+
};
|
|
173
|
+
export type OBJ_AxisLabels_Fixed = {
|
|
174
|
+
precision: number;
|
|
175
|
+
format: 'decimal' | 'exp';
|
|
176
|
+
space: number;
|
|
177
|
+
offset: Point;
|
|
178
|
+
rotation: number;
|
|
179
|
+
xAlign: 'left' | 'right' | 'center';
|
|
180
|
+
yAlign: 'bottom' | 'baseline' | 'middle' | 'top';
|
|
181
|
+
font: OBJ_Font_Fixed;
|
|
182
|
+
hide: Array<number>;
|
|
183
|
+
fixed: boolean;
|
|
184
|
+
valueOffset: {
|
|
185
|
+
values: Array<number>;
|
|
186
|
+
offset: Point;
|
|
187
|
+
};
|
|
188
|
+
text: Array<string>;
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* Axis title.
|
|
192
|
+
*
|
|
193
|
+
* @property {number} [rotation] title rotation
|
|
194
|
+
* @property {'bottom' | 'top' | 'left' | 'right'} [location] location of text
|
|
195
|
+
* relative to axis
|
|
196
|
+
* @property {TypeParsablePoint} [offset] title offset from default location
|
|
197
|
+
*
|
|
198
|
+
* @extends {@link OBJ_TextLines}
|
|
199
|
+
* @interface
|
|
200
|
+
* @group Misc Shapes
|
|
201
|
+
*/
|
|
202
|
+
export type OBJ_AxisTitle = OBJ_FormattedText & {
|
|
203
|
+
rotation?: number;
|
|
204
|
+
offset?: TypeParsablePoint;
|
|
205
|
+
location?: 'bottom' | 'top' | 'left' | 'right';
|
|
206
|
+
};
|
|
207
|
+
/**
|
|
208
|
+
* {@link CollectionsAxis} options object that extends {@link OBJ_Collection}
|
|
209
|
+
* options object (without `parent`).
|
|
210
|
+
*
|
|
211
|
+
* A zoom axis can be used to create a number line, used as an axis in
|
|
212
|
+
* {@link COL_Plot} and/or used to plot a {@link COL_Trace} against.
|
|
213
|
+
*
|
|
214
|
+
* An axis is a line that may have
|
|
215
|
+
* - tick marks
|
|
216
|
+
* - labels
|
|
217
|
+
* - grid lines
|
|
218
|
+
* - a title
|
|
219
|
+
*
|
|
220
|
+
* An axis is drawn to a `length`. It will have values along its length
|
|
221
|
+
* from `start` to `stop`. Ticks, grid lines and labels are all drawn
|
|
222
|
+
* at axis value positions. All other dimensions, such as line lengths,
|
|
223
|
+
* widths, positions, spaces and offsets are defined in draw space, or in the
|
|
224
|
+
* same space as the `length` of the axis.
|
|
225
|
+
*
|
|
226
|
+
* @property {'x' | 'y'} [axis] `'x'` axes are horizontal, `'y'` axes are
|
|
227
|
+
* vertical (`'x'`)
|
|
228
|
+
* @property {number} [length] length of the axis in draw space
|
|
229
|
+
* @property {OBJ_AxisLineStyle | boolean} [line] line style of the axis -
|
|
230
|
+
* `false` will draw no line. By default, a solid line will be drawn if not
|
|
231
|
+
* defined.
|
|
232
|
+
* @property {number} [start] start value of axis (`0`)
|
|
233
|
+
* @property {number} [stop] stop value of axis. `stop` must be larger than
|
|
234
|
+
* `start` (`start + 1`)
|
|
235
|
+
* @property {OBJ_AxisTicks | Array<OBJ_AxisTicks> | boolean} [ticks] tick
|
|
236
|
+
* options. Use an Array to setup multiple sets/styles of ticks. Use a boolean
|
|
237
|
+
* value to turn ticks on or off. Use a {@link TypeTickLocation} to only set
|
|
238
|
+
* tick location property (`false`)
|
|
239
|
+
* @property {OBJ_AxisLabels | string | () => Array<string>} [labels]
|
|
240
|
+
* label options. Use `false` to turn labels off, or a string or function as
|
|
241
|
+
* a callback to define custom labels for a set of values. Use
|
|
242
|
+
* {@link TypeLabelLocation} to only set the label location property.
|
|
243
|
+
* @property {OBJ_AxisTicks | Array<OBJ_AxisTicks> | boolean} [grid] grid
|
|
244
|
+
* options. Use an array for multiple sets of grids, and use a boolean to
|
|
245
|
+
* turn grids on and off (`false`)
|
|
246
|
+
* @property {OBJ_AxisTitle | string} [title] axis title
|
|
247
|
+
* @property {OBJ_Font} [font] default font of axis (used by title and labels)
|
|
248
|
+
* @property {boolean} [show] `false` hides the axis. Two axes are needed
|
|
249
|
+
* to plot an {@link CollectionsTrace} on a {@link CollectionsPlot}, but if either or
|
|
250
|
+
* both axes aren't to be drawn, then use `false` to hide each axis (`true`)
|
|
251
|
+
* @property {[number, number]} [auto] Will select automatic values for
|
|
252
|
+
* `start`, `stop`, and `step` that cover the range [min, max]
|
|
253
|
+
* @property {boolean | 'decimal'} [autoStep] If `true` then start, stop and
|
|
254
|
+
* step tick, grid and label values will be automatically calculated such that
|
|
255
|
+
* they land on 0 and either double/half the original step (`true`) or ensure
|
|
256
|
+
* the steps land on factors of 10 (`'decimal'`). This needs to be not `false`
|
|
257
|
+
* if panning or zooming. If `false`, then the tick, grid and label values will
|
|
258
|
+
* be from the `start`, `stop` and `step` properties. (`false`)
|
|
259
|
+
* @property {number | null} min minimum value axis can be zoomed or panned to
|
|
260
|
+
* where `null` no limit (`null`)
|
|
261
|
+
* @property {number | null} max maximum value axis can be zoomed or panned to
|
|
262
|
+
* where `null` no limit (`null`)
|
|
263
|
+
* @property {TypeParsablePoint} [position] axis position (`[0, 0]`)
|
|
264
|
+
* @property {Array<number>} [values] custom values for labels, ticks and grid.
|
|
265
|
+
* Only works for one level of ticks and grid, and doesn't not accomodate
|
|
266
|
+
* zooming or panning.
|
|
267
|
+
*
|
|
268
|
+
* @extends OBJ_Collection
|
|
269
|
+
* @interface
|
|
270
|
+
* @group 2D Shape Collections
|
|
271
|
+
*/
|
|
272
|
+
export type COL_Axis = {
|
|
273
|
+
axis?: 'x' | 'y';
|
|
274
|
+
length?: number;
|
|
275
|
+
line?: boolean | OBJ_AxisLineStyle;
|
|
276
|
+
start?: number;
|
|
277
|
+
stop?: number;
|
|
278
|
+
step?: number;
|
|
279
|
+
ticks?: OBJ_AxisTicks | boolean | TypeTickLocation | Array<OBJ_AxisTicks | boolean | TypeTickLocation>;
|
|
280
|
+
labels?: OBJ_AxisLabels | boolean | TypeLabelLocation | string | ((params: OBJ_LabelsCallbackParams) => Array<string>);
|
|
281
|
+
grid?: OBJ_AxisTicks | boolean | Array<OBJ_AxisTicks | boolean>;
|
|
282
|
+
title?: OBJ_AxisTitle | string;
|
|
283
|
+
font?: OBJ_Font;
|
|
284
|
+
show?: boolean;
|
|
285
|
+
min?: number | null;
|
|
286
|
+
max?: number | null;
|
|
287
|
+
auto?: [number, number];
|
|
288
|
+
autoStep?: boolean | 'decimal';
|
|
289
|
+
values?: Array<number>;
|
|
290
|
+
} & OBJ_Collection;
|
|
291
|
+
/**
|
|
292
|
+
* {@link FigureElementCollection} representing an Axis.
|
|
293
|
+
*
|
|
294
|
+
* 
|
|
295
|
+
*
|
|
296
|
+
* 
|
|
297
|
+
*
|
|
298
|
+
* 
|
|
299
|
+
*
|
|
300
|
+
* 
|
|
301
|
+
*
|
|
302
|
+
* 
|
|
303
|
+
*
|
|
304
|
+
* This object defines an axis with an axis line, tick marks, labels,
|
|
305
|
+
* grid lines and a title.
|
|
306
|
+
*
|
|
307
|
+
* See {@link COL_Axis} for the options that can be used when creating
|
|
308
|
+
* the axis.
|
|
309
|
+
*
|
|
310
|
+
* An axis is drawn to a `length`. It will have values along its length
|
|
311
|
+
* from `start` to `stop`. Ticks, grid lines and labels are all drawn
|
|
312
|
+
* at axis value positions. All other dimensions, such as line lengths,
|
|
313
|
+
* widths, positions, spaces and offsets are defined in draw space, or in the
|
|
314
|
+
* same space as the `length` of the axis.
|
|
315
|
+
*
|
|
316
|
+
* The object contains additional methods that convert between axis values
|
|
317
|
+
* and draw space positions, as well as a convenience method to report if a
|
|
318
|
+
* value is within an axis.
|
|
319
|
+
* - <a href="#collectionsaxisvaluetodraw">valueToDraw</a>
|
|
320
|
+
* - <a href="#collectionsaxisdrawtovalue">drawToValue</a>
|
|
321
|
+
* - <a href="#collectionsaxisinaxis">inAxis</a>
|
|
322
|
+
*
|
|
323
|
+
* To test examples below, append them to the
|
|
324
|
+
* <a href="#drawing-boilerplate">boilerplate</a>.
|
|
325
|
+
*
|
|
326
|
+
* For more examples of axis labels and axis ticks, see {@link OBJ_AxisLabels}
|
|
327
|
+
* and {@link OBJ_AxisTicks}.
|
|
328
|
+
*
|
|
329
|
+
* @see {@link COL_Axis} for parameter descriptions
|
|
330
|
+
*
|
|
331
|
+
* @example
|
|
332
|
+
* // By default an axis is an 'x' axis
|
|
333
|
+
* figure.add({
|
|
334
|
+
* make: 'collections.axis',
|
|
335
|
+
* });
|
|
336
|
+
*
|
|
337
|
+
* @example
|
|
338
|
+
* // An axis can also be created and then added to a figure
|
|
339
|
+
* // An axis can have specific start and stop values
|
|
340
|
+
* // An axis can be a y axis
|
|
341
|
+
* const axis = figure.collections.axis({
|
|
342
|
+
* axis: 'y',
|
|
343
|
+
* start: -10,
|
|
344
|
+
* stop: 10,
|
|
345
|
+
* step: 5,
|
|
346
|
+
* });
|
|
347
|
+
* figure.add('axis', axis);
|
|
348
|
+
*
|
|
349
|
+
*
|
|
350
|
+
* @example
|
|
351
|
+
* // An axis can have multiple sets of ticks and a title
|
|
352
|
+
* figure.add({
|
|
353
|
+
* make: 'collections.axis',
|
|
354
|
+
* step: [0.2, 0.05],
|
|
355
|
+
* ticks: [
|
|
356
|
+
* true,
|
|
357
|
+
* { length: 0.04, location: 'bottom' },
|
|
358
|
+
* ],
|
|
359
|
+
* title: 'time (s)',
|
|
360
|
+
* });
|
|
361
|
+
*
|
|
362
|
+
*
|
|
363
|
+
* @example
|
|
364
|
+
* // An axis line and ticks can be customized to be dashed
|
|
365
|
+
* // and have arrows
|
|
366
|
+
* figure.add({
|
|
367
|
+
* make: 'collections.axis',
|
|
368
|
+
* length: 2.5,
|
|
369
|
+
* start: -100,
|
|
370
|
+
* stop: 100,
|
|
371
|
+
* step: 25,
|
|
372
|
+
* line: {
|
|
373
|
+
* dash: [0.01, 0.01],
|
|
374
|
+
* arrow: 'barb',
|
|
375
|
+
* },
|
|
376
|
+
* ticks: { dash: [0.01, 0.01] },
|
|
377
|
+
* title: {
|
|
378
|
+
* font: { style: 'italic', family: 'Times New Roman' },
|
|
379
|
+
* text: 'x',
|
|
380
|
+
* location: 'right',
|
|
381
|
+
* },
|
|
382
|
+
* });
|
|
383
|
+
*
|
|
384
|
+
*
|
|
385
|
+
* @example
|
|
386
|
+
* // An axis can have grid lines extend from it, and
|
|
387
|
+
* // multi-line, formatted titles
|
|
388
|
+
* figure.add({
|
|
389
|
+
* make: 'collections.axis',
|
|
390
|
+
* stop: 2,
|
|
391
|
+
* step: [0.5, 0.1],
|
|
392
|
+
* grid: [
|
|
393
|
+
* { length: 1, color: [0.5, 0.5, 0.5, 1] },
|
|
394
|
+
* { length: 1, dash: [0.01, 0.01], color: [0.7, 0.7, 0.7, 1] },
|
|
395
|
+
* ],
|
|
396
|
+
* title: {
|
|
397
|
+
* font: { color: [0.4, 0.4, 0.4, 1] },
|
|
398
|
+
* text: [
|
|
399
|
+
* 'Total Time',
|
|
400
|
+
* {
|
|
401
|
+
* text: 'in seconds',
|
|
402
|
+
* font: { size: 0.1 },
|
|
403
|
+
* lineSpace: 0.12,
|
|
404
|
+
* },
|
|
405
|
+
* ],
|
|
406
|
+
* },
|
|
407
|
+
* });
|
|
408
|
+
*
|
|
409
|
+
* @group 2D Shape Collections
|
|
410
|
+
*/
|
|
411
|
+
declare class CollectionsAxis extends FigureElementCollection {
|
|
412
|
+
_line: FigureElementPrimitive | null | undefined;
|
|
413
|
+
_labels: (FigureElementPrimitive2DText | FigureElementPrimitiveGLText) | null | undefined;
|
|
414
|
+
_grid: FigureElementPrimitive | null | undefined;
|
|
415
|
+
_ticks0: FigureElementPrimitive | null | undefined;
|
|
416
|
+
_grid0: FigureElementPrimitive | null | undefined;
|
|
417
|
+
length: number;
|
|
418
|
+
angle: number;
|
|
419
|
+
startValue: number;
|
|
420
|
+
stopValue: number;
|
|
421
|
+
showAxis: boolean;
|
|
422
|
+
step: Array<number>;
|
|
423
|
+
min: number | null;
|
|
424
|
+
max: number | null;
|
|
425
|
+
ticks: any;
|
|
426
|
+
grid: any;
|
|
427
|
+
labels: OBJ_AxisLabels_Fixed | null;
|
|
428
|
+
drawToValueRatio: number;
|
|
429
|
+
valueToDrawRatio: number;
|
|
430
|
+
defaultFont: OBJ_Font_Fixed;
|
|
431
|
+
axis: 'x' | 'y';
|
|
432
|
+
line: {
|
|
433
|
+
width: number;
|
|
434
|
+
} & OBJ_Line | null;
|
|
435
|
+
values: null | Array<number>;
|
|
436
|
+
labelsCallback: null | string | ((params: OBJ_LabelsCallbackParams) => Array<string>);
|
|
437
|
+
precision: number;
|
|
438
|
+
currentZoom: number;
|
|
439
|
+
initialScale: number;
|
|
440
|
+
initialStart: number;
|
|
441
|
+
autoStep: boolean | 'decimal';
|
|
442
|
+
[key: string]: any;
|
|
443
|
+
/**
|
|
444
|
+
* @hideconstructor
|
|
445
|
+
*/
|
|
446
|
+
constructor(collections: FigureCollections, optionsIn: COL_Axis);
|
|
447
|
+
fontUpdated(): void;
|
|
448
|
+
addTicks(type: 'grid' | 'ticks', options: OBJ_AxisTicks | boolean, index: number): any;
|
|
449
|
+
calcRatios(): void;
|
|
450
|
+
rnd(value: number): number;
|
|
451
|
+
/**
|
|
452
|
+
* Pan so an axis value is located at a draw location.
|
|
453
|
+
*/
|
|
454
|
+
pan(toValue: number, atDraw: number): void;
|
|
455
|
+
_getStateProperties(options: {
|
|
456
|
+
ignoreShown?: boolean;
|
|
457
|
+
}): string[];
|
|
458
|
+
clipRange(startIn: number, stopIn: number): number[];
|
|
459
|
+
/**
|
|
460
|
+
* Pan by some delta axis value.
|
|
461
|
+
*/
|
|
462
|
+
panDeltaValue(deltaValue: number): void;
|
|
463
|
+
/**
|
|
464
|
+
* Pan by some delta draw value.
|
|
465
|
+
*/
|
|
466
|
+
panDeltaDraw(deltaDraw: number): void;
|
|
467
|
+
/**
|
|
468
|
+
* Zoom to some magnitude (`mag`), such that `value`
|
|
469
|
+
* is located at `drawPosition` on the axis.
|
|
470
|
+
*/
|
|
471
|
+
zoom(value: number, drawPosition: number, mag: number): void;
|
|
472
|
+
/**
|
|
473
|
+
* Zoom on a value that is already shown on the axis.
|
|
474
|
+
*/
|
|
475
|
+
zoomValue(value: number, mag: number): void;
|
|
476
|
+
/**
|
|
477
|
+
* Zoom by a delta magnitude on a value already shown on the axis.
|
|
478
|
+
*/
|
|
479
|
+
zoomDelta(value: number, magDelta: number): void;
|
|
480
|
+
update(startValueIn?: number, stopValueIn?: number): void;
|
|
481
|
+
updateText(values: Array<number>): void;
|
|
482
|
+
updateTicks(type: 'ticks' | 'grid' | string, values: Array<number>, index: number): void;
|
|
483
|
+
addTitle(optionsIn: OBJ_FormattedText & OBJ_AxisTitle | string): void;
|
|
484
|
+
/**
|
|
485
|
+
* Convert an axis value or values to a draw space position or positions.
|
|
486
|
+
*
|
|
487
|
+
* 'x' axes have a draw space position of 0 on the left end of the axis and
|
|
488
|
+
* 'y' axes have a draw space position of 0 on the bottom end of the axis.
|
|
489
|
+
*
|
|
490
|
+
* @return {number} draw space position
|
|
491
|
+
*/
|
|
492
|
+
valueToDraw(value: number): number;
|
|
493
|
+
valueToDraw(value: Array<number>): Array<number>;
|
|
494
|
+
/**
|
|
495
|
+
* Convert an axis draw space value or values to an axis value or values.
|
|
496
|
+
*
|
|
497
|
+
* 'x' axes have a draw space position of 0 on the left end of the axis and
|
|
498
|
+
* 'y' axes have a draw space position of 0 on the bottom end of the axis.
|
|
499
|
+
*
|
|
500
|
+
* @return {number} draw space position
|
|
501
|
+
*/
|
|
502
|
+
drawToValue(drawValue: number): number;
|
|
503
|
+
drawToValue(drawValue: Array<number>): Array<number>;
|
|
504
|
+
/**
|
|
505
|
+
* Check if a value is within the axis.
|
|
506
|
+
*
|
|
507
|
+
* @return {boolean} `true` if value is within length of axis.
|
|
508
|
+
*/
|
|
509
|
+
inAxis(value: number, precision?: number): boolean;
|
|
510
|
+
showLine(): void;
|
|
511
|
+
hideLine(): void;
|
|
512
|
+
showTicks(): void;
|
|
513
|
+
hideTicks(): void;
|
|
514
|
+
showGrid(): void;
|
|
515
|
+
hideGrid(): void;
|
|
516
|
+
}
|
|
517
|
+
export default CollectionsAxis;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { OBJ_Line3Arrow } from '../../tools/d3/line3';
|
|
2
|
+
import { FigureElementCollection, FigureElementPrimitive } from '../Element';
|
|
3
|
+
import type { OBJ_Collection } from '../FigurePrimitives/FigurePrimitiveTypes';
|
|
4
|
+
import type { TypeColor } from '../../tools/types';
|
|
5
|
+
import type FigureCollections from './FigureCollections';
|
|
6
|
+
/**
|
|
7
|
+
* {@link CollectionsAxis3} options object that extends {@link OBJ_Collection}
|
|
8
|
+
* options object (without `parent`).
|
|
9
|
+
*
|
|
10
|
+
* Each option can either be singular and applied to all axes, or in a 3 element
|
|
11
|
+
* tuple where the first, second and third elements apply to the x, y, and z
|
|
12
|
+
* axes respectively.
|
|
13
|
+
*
|
|
14
|
+
* To not create an axis, use a width of exactly 0.
|
|
15
|
+
*
|
|
16
|
+
*
|
|
17
|
+
* @property {number | [number, number, number]} [width] width of axis
|
|
18
|
+
* @property {number | [number, number, number]} [start] start value of axis
|
|
19
|
+
* (`0`)
|
|
20
|
+
* @property {number | [number, number, number]} [length] length of axis
|
|
21
|
+
* @property {number | [number, number, number]} [sides] number of sides in
|
|
22
|
+
* cross section of axis (`10`)
|
|
23
|
+
* @property {number | [number, number, number]} [lines] `true` if to draw as
|
|
24
|
+
* lines instead of a solid (`false`)
|
|
25
|
+
* @property {OBJ_Line3Arrow | boolean | [OBJ_Line3Arrow | boolean, OBJ_Line3Arrow | boolean, OBJ_Line3Arrow | boolean]} [arrow] arrow options
|
|
26
|
+
* for axes
|
|
27
|
+
* @property {TypeColor | [TypeColor, TypeColor, TypeColor]} [color]
|
|
28
|
+
* axes color - default is x: red, y: green, z: blue.
|
|
29
|
+
*
|
|
30
|
+
* @extends OBJ_Collection
|
|
31
|
+
*
|
|
32
|
+
* @interface
|
|
33
|
+
* @group 3D Shape Collections
|
|
34
|
+
*/
|
|
35
|
+
export type COL_Axis3 = {
|
|
36
|
+
width?: number | [number, number, number];
|
|
37
|
+
length?: number | [number, number, number];
|
|
38
|
+
start?: number | [number, number, number];
|
|
39
|
+
sides?: number | [number, number, number];
|
|
40
|
+
lines?: boolean | [boolean, boolean, boolean];
|
|
41
|
+
arrow?: OBJ_Line3Arrow | boolean | [OBJ_Line3Arrow | boolean, OBJ_Line3Arrow | boolean, OBJ_Line3Arrow | boolean];
|
|
42
|
+
color?: TypeColor | [TypeColor, TypeColor, TypeColor];
|
|
43
|
+
} & OBJ_Collection;
|
|
44
|
+
/**
|
|
45
|
+
* {@link FigureElementCollection} representing x, y, z axes.
|
|
46
|
+
*
|
|
47
|
+
* 
|
|
48
|
+
*
|
|
49
|
+
* This object creates an x, y, and z axes.
|
|
50
|
+
*
|
|
51
|
+
* The axes can be created uniformly, or customized individually.
|
|
52
|
+
*
|
|
53
|
+
* See {@link COL_Axis3} for setup options.
|
|
54
|
+
*
|
|
55
|
+
* To test examples below, append them to the
|
|
56
|
+
* <a href="#shapes3d-boilerplate">boilerplate</a>
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* // Create positive x, y, and z axes
|
|
60
|
+
* figure.add(
|
|
61
|
+
* {
|
|
62
|
+
* make: 'collections.axis3',
|
|
63
|
+
* arrow: true,
|
|
64
|
+
* length: 0.5,
|
|
65
|
+
* },
|
|
66
|
+
* );
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* // Create full x, y, and z axes with arrows
|
|
70
|
+
* figure.add(
|
|
71
|
+
* {
|
|
72
|
+
* make: 'collections.axis3',
|
|
73
|
+
* arrow: { ends: 'all' },
|
|
74
|
+
* start: -0.5,
|
|
75
|
+
* length: 1,
|
|
76
|
+
* },
|
|
77
|
+
* );
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* // Customize each axis
|
|
81
|
+
* figure.add(
|
|
82
|
+
* {
|
|
83
|
+
* make: 'collections.axis3',
|
|
84
|
+
* arrow: [{ ends: 'end' }, false, { ends: 'all', width: 0.02 }],
|
|
85
|
+
* width: 0.02,
|
|
86
|
+
* start: [0, 0, -0.5],
|
|
87
|
+
* length: [0.5, 0.5, 1],
|
|
88
|
+
* },
|
|
89
|
+
* );
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* // Lines axes all the same color
|
|
93
|
+
* figure.add(
|
|
94
|
+
* {
|
|
95
|
+
* make: 'collections.axis3',
|
|
96
|
+
* arrow: { ends: 'all' },
|
|
97
|
+
* start: -0.5,
|
|
98
|
+
* length: 1,
|
|
99
|
+
* lines: true,
|
|
100
|
+
* color: [1, 0, 0, 1],
|
|
101
|
+
* },
|
|
102
|
+
* );
|
|
103
|
+
* @group 3D Shape Collections
|
|
104
|
+
*/
|
|
105
|
+
declare class CollectionsAxis3 extends FigureElementCollection {
|
|
106
|
+
_x: FigureElementPrimitive | null;
|
|
107
|
+
_y: FigureElementPrimitive | null;
|
|
108
|
+
_z: FigureElementPrimitive | null;
|
|
109
|
+
x: Record<string, any>;
|
|
110
|
+
y: Record<string, any>;
|
|
111
|
+
z: Record<string, any>;
|
|
112
|
+
/**
|
|
113
|
+
* @hideconstructor
|
|
114
|
+
*/
|
|
115
|
+
constructor(collections: FigureCollections, optionsIn: COL_Axis3);
|
|
116
|
+
addAxis(axisName: 'x' | 'y' | 'z'): void;
|
|
117
|
+
}
|
|
118
|
+
export default CollectionsAxis3;
|