1- type SeriesName = string ;
2-
1+ /** Defines a data series of the data set, and contains a particular variable's
2+ * values in the data set and meta info about the variable. */
33interface DataSeries {
4- name : SeriesName ;
4+ /** Name of the data series. It will be the unique id of the series to
5+ * reference it in various parts of the API, mainly in {@link Channel} and
6+ * {@link DataRecord}. Also this name will be used by default as Axis and
7+ * Legend title. */
8+ name : string ;
9+ /** Type of the data series:
10+ * 'categories' - discrete data containing strings;
11+ * 'values' - continuous data containing numbers. */
512 type : 'categories' | 'values' ;
13+ /** The array that contains the values of the data series. The value types
14+ * should match {@link DataSeries.type}. If the data series
15+ * is sorter than the longest data series defined, it will be internally
16+ * extended with empty values internally. */
617 values : string [ ] | number [ ] ;
718}
819
20+ /** Represents a categorical or data value */
21+ type DataValue = string | number ;
22+
23+ /** A record of the data set, containing the one value of each data series
24+ * corresponding to the same index. */
925interface DataRecord {
10- [ key : string ] : string | number ;
11- getValue : ( name : SeriesName ) => string | number ;
26+ /** Properties are provided for each data series, returning the value of
27+ * the series referenced by its {@link DataSeries.name|name}. */
28+ [ seriesName : string ] : DataValue ;
1229}
1330
31+ /** Data set is a collection of related {@link DataSeries|data series}.
32+ * Each chart works on a single data set. */
1433interface DataSet {
34+ /** The list of the data series makes up the data set. */
1535 series : DataSeries [ ] ;
36+ /** A filter callback is called on each record of the dataset on chart
37+ * generation. If the callback returns false, the record will be ignored.
38+ */
1639 filter : ( record : DataRecord ) => boolean ;
1740}
1841
42+ /** Channel range specifies how to scale the represented data.
43+ * The first two parameters are the minimum and maximum values.
44+ * The third parameter is the unit.
45+ * 1 means the same unit as the data,
46+ * % means relative to the actual extremes of the data. */
47+ type ChannelRange = `${number } ,${number } ,${1 | '%' } `;
48+
49+ /** Channels are the main building blocks of the chart. Each channel describes
50+ * a particular aspect of the markers (position, color, etc.) and connects
51+ * them to the underlying data. Each channel can be connected to a single
52+ * continuous data series that will determine the measure of the channel,
53+ * and an ordered list of categorical data sets, which will recursively slice
54+ * the channel.
55+ * The channels are represented on the chart as an axis or legend. */
1956interface Channel {
57+ /** This title shown on the axis or legend corresponds to the channel.
58+ * If not specified, the title will hold the data series name connected to
59+ * the channel. */
2060 title : string | null ;
21- attach : SeriesName [ ] ;
22- detach : SeriesName [ ] ;
23- range : `${number } ,${number } ,${number } `;
61+ /** List of {@link DataSeries.name|data series names} to be added to the
62+ * channel. */
63+ attach : string [ ] ;
64+ /** List of {@link DataSeries.name|data series names} to be removed to the
65+ * channel. */
66+ detach : string [ ] ;
67+ /** Specifies the range which determines how the represented data will be
68+ * scales on the channel. */
69+ range : ChannelRange ;
70+ /** Only one categorical data series can be shown on an axis or legend by
71+ * name. This index specifies which attached series should be used. */
2472 labelLevel : number ;
2573}
2674
75+ /** The descriptor contains all the parameters needed to render a particular
76+ * static chart or a state of an animated chart. */
2777interface Descriptor {
78+ /** List of the chart's channels. */
2879 channels : {
80+ /** Parameters for X-axis determine the position of the markers on the
81+ * x (or angle for the polar coordinate system) axis.
82+ * Note: leaving x and y channels empty will result in a
83+ * "without coordinates" chart. */
2984 x : Channel ;
85+ /** Parameters for Y-axis, determine the position of the markers on the
86+ * y (or radius for the polar coordinate system) axis. */
3087 y : Channel ;
88+ /** Parameters for markers' base color. The marker's effective color is
89+ * also affected by the lightness channel. */
3190 color : Channel ;
91+ /** Parameters for markers' lightness. */
3292 lightness : Channel ;
93+ /** Parameters for markers' size, effective only for Circle and Line
94+ * geometry affecting the circle area or the line width respectively.
95+ */
3396 size : Channel ;
97+ /** Not implemented, for now, will not have an effect on the markers */
3498 shape : Channel ;
99+ /** Parameters for the content of the markers' labels. */
35100 label : Channel ;
36101 } ;
102+ /** This title is shown at the top of the chart.
103+ * If set to null, the Title will not be shown and will not take up any
104+ * space in the chart layout. */
37105 title : string | null ;
106+ /** Specifies which channel should be detailed on the legend.
107+ * If set to null, the legend will not be shown and will not take up any
108+ * space in the chart layout. */
38109 legend : 'color' | 'lightness' | 'size' | null ;
110+ /** Sets the coordinate system for the chart. Switch to the 'polar'
111+ * coordinate system to create a chart from the pie/radial chart family. */
39112 coordSystem : 'cartesian' | 'polar' ;
113+ /** Rotates the plot area by the specified angle in degree. */
40114 rotation : number ;
115+ /** Sets the geometric element used for the markers to represent the data.*/
41116 geometry : 'rectangle' | 'circle' | 'area' | 'line' ;
117+ /** If both axes represent continuous data, this parameter sets the
118+ * orientation of the chart, meaning to which axis the graphical elements
119+ * are oriented to. */
42120 orientation : 'horizontal' | 'vertical' ;
121+ /** 'none': markers are sorted in the order as the corresponding data appear
122+ in the data set.
123+ 'experimental': markers will be sorted by the corresponding continuous
124+ data (if present) in decreasing order. */
43125 sort : 'none' | 'experimental' ;
126+ /** Reverts the order of the markers if set. */
44127 reverse : boolean ;
128+ /** Sets the alignment of the markers with relation to the x- and y-axis. */
45129 align : 'none' | 'min' | 'center' | 'max' | 'stretch' ;
130+ /** If set, markers will be aligned by the categories instead of getting
131+ * stacked. */
46132 split : boolean ;
47133}
48134
135+ declare namespace Styles
136+ {
137+
49138type Length = `${number } px`| `${number } %`| number ;
50139
51140type Color = `#${number } `
@@ -77,7 +166,7 @@ interface Text {
77166 textAlign : 'center' | 'left' | 'right' ;
78167 backgroundColor : Color ;
79168 overflow : 'visible' | 'hidden' ;
80- numberFormat : 'none' | 'groupped ' | 'prefixed' ;
169+ numberFormat : 'none' | 'grouped ' | 'prefixed' ;
81170}
82171
83172type ColorTransform = `color(${Color } )`
@@ -151,7 +240,9 @@ type ColorPalette = Color
151240 | `${Color } ${Color } ${Color } ${Color } ${Color } `;
152241
153242interface Data {
243+ /** Sets the color gradient used for continuous data on the color channel.*/
154244 colorGradient : ColorGradient ;
245+ /** Sets the color palette used for categorical data on the color channel.*/
155246 colorPalette : ColorPalette ;
156247 minLightness : number ;
157248 maxLightness : number ;
@@ -168,17 +259,24 @@ interface Data {
168259
169260type Label = Padding & Font & Text ;
170261
171- interface Styles extends Padding , Box , Font {
262+ interface Chart extends Padding , Box , Font {
172263 plot : Plot ;
173264 legend : Legend ;
174265 title : Label ;
175266 data : Data ;
176267}
177268
269+ }
270+
271+ /** Represents a state in the animation describing the data, the chart, and
272+ * the style parameters to be changed from the actual state. */
178273interface AnimTarget {
274+ /** Data set changes. */
179275 data : DataSet ;
276+ /** Chart parameter changes. */
180277 descriptor : Descriptor ;
181- style : Styles ;
278+ /** Style changes. */
279+ style : Styles . Chart ;
182280}
183281
184282type Duration = `${number } s`| `${number } ms`| number ;
@@ -187,33 +285,67 @@ type Easing = 'none' | 'linear' | 'step-start' | 'step-end' | 'ease'
187285 | 'ease-in' | 'ease-out'
188286 | `cubic-bezier(${number } ,${number } ,${number } ,${number } )`;
189287
190- interface AnimOption {
288+ /** Animation parameters for an animation group. */
289+ interface AnimOption
290+ {
291+ /** The timing function for the animation, which can be used to affect
292+ * the animation dynamics. */
191293 easing : Easing ;
294+ /** The length of time an animation should take to complete. */
192295 duration : Duration ;
296+ /** Waiting time interval before the animation starts. */
193297 delay : Duration ;
194298}
195299
196- interface AnimOptions {
300+ /** If no animation settings are passed to Vizzu, it will use an automatic
301+ * setting depending on the actual content of the chart. This behavior can be
302+ * overridden via the animation setting parameter.
303+ *
304+ * The animation between two states of the chart can require the transitioning
305+ * of several different chart properties. These properties are grouped into
306+ * separately configurable animation groups.
307+ *
308+ * The parameters also can be set for the overall animation. Overall parameters
309+ * are used as default values for the corresponding parameters in each
310+ * animation group, which are not set separately.
311+ */
312+ interface AnimOptions extends AnimOption {
313+ /** Determines if the animation should start automatically after the
314+ * animate() call. */
197315 playState : 'paused' | 'running' ;
198- easing : Easing ;
199- duration : Duration ;
200- delay : Duration ;
316+ /** Animation group for style parameters. */
201317 style : AnimOption ;
318+ /** Title animation parameters. */
202319 title : AnimOption ;
320+ /** Animation group for marker visibility change
321+ * (due to filtering or data series add/remove). */
203322 enable : AnimOption ;
323+ /** Marker color animation group. */
204324 color : AnimOption ;
325+ /** Coordinate system transformations animation group. */
205326 coordSystem : AnimOption ;
327+ /** Marker geometry morph animation group. */
206328 geometry : AnimOption ;
329+ /** Animation group for marker transitions to the Y direction. */
207330 y : AnimOption ;
331+ /** Animation group for marker transitions to the X direction. */
208332 x : AnimOption ;
209333}
210334
335+ /** Control object for animation. */
211336interface AnimControl {
212- seek ( value : `${number } %`| Duration ) : void ;
213- pause ( ) : void ;
214- play ( ) : void ;
215- stop ( ) : void ;
216- reverse ( ) : void ;
337+ /** Seeks the animation to the position specified by time or progress
338+ * percentage. Seeking the animation to the end position will not trigger
339+ * the (@link Vizzu.animate|animation promise) to resolve. */
340+ seek ( value : `${number } %`| Duration ) : void ;
341+ /** Pauses the controlled animation. */
342+ pause ( ) : void ;
343+ /** Plays/resumes playing of the controlled animation. */
344+ play ( ) : void ;
345+ /** Stops the current animation seeking it back to its start position. */
346+ stop ( ) : void ;
347+ /** Changes the direction of the controlled animation. */
348+ reverse ( ) : void ;
217349}
218350
219351type EventName = 'click'
@@ -237,16 +369,34 @@ type EventName = 'click'
237369 | 'plot-axis-guide-draw'
238370 | 'plot-axis-interlacing-draw' ;
239371
372+ /** The interface of the event object is passed to event handlers by the library.
373+ * Additional properties will vary by event type. */
240374interface Event {
375+ /** If called, the default action of the event will be canceled. */
241376 preventDefault : ( ) => void ;
242377}
243378
379+ /** Class representing a single chart in Vizzu. */
244380export default class Vizzu {
381+ /** Creates a new empty chart and connects it to the div or canvas HTML
382+ * element specified by its ID or DOM object. */
245383 constructor ( container : string | HTMLElement ) ;
246- initializing : Promise < Vizzu > ;
247- on ( eventName : EventName , handler : ( event : Event ) => void ) : void ;
248- off ( eventName : EventName , handler : ( event : Event ) => void ) : void ;
249- animate ( obj : AnimTarget , opt : AnimOptions ) : Promise < Vizzu > ;
250- get animation ( ) : AnimControl ;
251- version ( ) : string ;
384+ /** Promise representing the initialization will resolve when
385+ * initialization is finished. Any API call will potentially cause
386+ * an error before this promise is resolved. */
387+ initializing : Promise < Vizzu > ;
388+ /** Installs the provided event handler to the event specified by name */
389+ on ( eventName : EventName , handler : ( event : Event ) => void ) : void ;
390+ /** Uninstalls the provided event handler to the event specified by name */
391+ off ( eventName : EventName , handler : ( event : Event ) => void ) : void ;
392+ /** Initiates a new animation to the new chart states pass as the first
393+ * argument. The optional second parameter specifies the animation
394+ * options.
395+ * The method returns a promise, which will resolve when the animation is
396+ * finished. */
397+ animate ( obj : AnimTarget , opt : AnimOptions ) : Promise < Vizzu > ;
398+ /** Returns controls for the ongoing animation, if any. */
399+ get animation ( ) : AnimControl ;
400+ /** Returns the version number of the library. */
401+ version ( ) : string ;
252402}
0 commit comments