@pacem/pacem-charts 1.0.0-abel

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.
@@ -0,0 +1,239 @@
1
+ import { Components as Components_2 } from '@pacem/pacem-core';
2
+ import { CustomUIEvent } from '@pacem/pacem-core';
3
+ import { Point } from '@pacem/pacem-foundation';
4
+ import { Size } from '@pacem/pacem-foundation';
5
+
6
+ declare interface ChartDataItem {
7
+ label: any;
8
+ value: number;
9
+ }
10
+
11
+ declare interface ChartDataSeries {
12
+ readonly values: ChartDataItem[];
13
+ readonly label: any;
14
+ readonly color?: string;
15
+ readonly className?: string;
16
+ readonly datapoints?: boolean;
17
+ }
18
+
19
+ declare type ChartDataSeriesItem = {
20
+ series: any;
21
+ label: any;
22
+ color: string;
23
+ value: number;
24
+ };
25
+
26
+ declare type ChartDatasource = ChartDataSeries[];
27
+
28
+ declare class ChartEvent extends CustomUIEvent<ChartEventArgs> {
29
+ constructor(type: string, eventInit: CustomEventInit<ChartEventArgs>, originalEvent: MouseEvent | TouchEvent | KeyboardEvent);
30
+ }
31
+
32
+ declare interface ChartEventArgs {
33
+ readonly dataItem: ChartDataSeriesItem;
34
+ readonly anchorPoint: Point;
35
+ }
36
+
37
+ export declare namespace Charts {
38
+ export {
39
+ MANAGED_EVENTS,
40
+ ChartDataItem,
41
+ ChartDataSeries,
42
+ ChartDatasource,
43
+ ChartDataSeriesItem,
44
+ ChartEventArgs,
45
+ ChartEvent,
46
+ PacemChartSeriesElement,
47
+ PacemSeriesChartElement,
48
+ PacemChartElement,
49
+ PacemColumnChartElement,
50
+ PacemPieSliceElement,
51
+ PacemPieChartElement
52
+ }
53
+ }
54
+
55
+ export declare namespace Components {
56
+ export {
57
+ Charts
58
+ }
59
+ }
60
+
61
+ declare const MANAGED_EVENTS: string[];
62
+
63
+ declare class PacemChartElement extends PacemSeriesChartElement {
64
+ #private;
65
+ type: 'line' | 'spline' | 'area' | 'splinearea';
66
+ /** Gets or sets how aspect ratio between x- and y-axis must be handled (considered only when xAxisType is `numeric`). Default is `adapt`. */
67
+ aspectRatio: 'adapt' | 'monometric' | 'logaritmic';
68
+ private _getVirtualGrid;
69
+ private _wipe;
70
+ viewActivatedCallback(): void;
71
+ disconnectedCallback(): void;
72
+ propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
73
+ private _setupBehavior;
74
+ private _dismantleBehavior;
75
+ private _enterHandler;
76
+ private _leaveHandler;
77
+ private _moveHandler;
78
+ private _chartFillSeries;
79
+ private _buildLinearGradient;
80
+ private _setGradientColor;
81
+ protected drawSeries(datasource: ChartDatasource): void;
82
+ }
83
+
84
+ declare class PacemChartSeriesElement extends Components_2.PacemItemElement implements ChartDataSeries {
85
+ /** Gets or sets the - already sorted - set of chart data items. */
86
+ datasource: ChartDataItem[];
87
+ /** Gets or sets the series label. */
88
+ label: string;
89
+ color: string;
90
+ datapoints: boolean;
91
+ get values(): ChartDataItem[];
92
+ /** @internal
93
+ * The elements that visually 'reflect' each ChartDataItem. */
94
+ _uiElements: Element[];
95
+ }
96
+
97
+ declare class PacemColumnChartElement extends PacemSeriesChartElement {
98
+ type: 'cluster' | 'stack';
99
+ /** Set a value between 0 and 1, for the columns' stack/cluster horizontal size (percentage of the available space). */
100
+ groupWidth: number;
101
+ propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
102
+ private _safen;
103
+ drawSeries(datasource: ChartDatasource): void;
104
+ }
105
+
106
+ declare class PacemPieChartElement extends Components_2.PacemItemsContainerElement<PacemPieSliceElement> {
107
+ constructor();
108
+ validate(item: PacemPieSliceElement): boolean;
109
+ viewActivatedCallback(): void;
110
+ propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
111
+ /** Set a value between 0 and 1, for doughnut appearance. */
112
+ cutout: number;
113
+ target: HTMLElement;
114
+ maskBasedRendering: boolean;
115
+ /** Distance between two consecutive slices, in pixels. */
116
+ slicePadding: number;
117
+ get area(): SVGSVGElement;
118
+ private _key;
119
+ private _svg;
120
+ private _mask;
121
+ private _g;
122
+ private _div;
123
+ disconnectedCallback(): void;
124
+ private _ensureArea;
125
+ private get _sliceMaskId();
126
+ private get _safeCutout();
127
+ private get _safeSlicePaddingPixels();
128
+ private _drawSlice;
129
+ private _isSliceOk;
130
+ private _padSlice;
131
+ private _slices;
132
+ draw(): void;
133
+ }
134
+
135
+ declare class PacemPieSliceElement extends Components_2.PacemItemElement implements ChartDataItem {
136
+ protected findContainer(): PacemPieChartElement;
137
+ private get chart();
138
+ value: number;
139
+ label: string;
140
+ color: string;
141
+ normalizedPolarCoords: {
142
+ radius: number;
143
+ angle: number;
144
+ };
145
+ /** Returns the center of mass (point) of this pie/doughnut slice, in absolute coords (pixels). */
146
+ getCenterOfMass(): Point;
147
+ propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
148
+ private _ui;
149
+ /** @internal */
150
+ _assignUi(el: Element): void;
151
+ /** @internal */
152
+ _disposeUi(): void;
153
+ private _broadcastHandler;
154
+ }
155
+
156
+ declare abstract class PacemSeriesChartElement extends Components_2.PacemItemsContainerElement<PacemChartSeriesElement> {
157
+ constructor();
158
+ validate(item: PacemChartSeriesElement): boolean;
159
+ target: HTMLElement;
160
+ /**
161
+ Gets or sets the x-axis type for sorting, measuring and labeling.
162
+ */
163
+ xAxisType: 'string' | 'date' | 'number';
164
+ xAxisPosition: 'bottom' | 'top' | 'none';
165
+ datasource: ChartDatasource;
166
+ /** Maximum number of horizontal grid lines. */
167
+ yAxisDensity: number;
168
+ /** Maximum number of x-axis labels. */
169
+ xAxisDensity: number;
170
+ /** Minimum y value. */
171
+ yAxisMin: number;
172
+ /** Maximum y value. */
173
+ yAxisMax: number;
174
+ yAxisFormat: Intl.NumberFormatOptions;
175
+ xAxisFormat: Intl.NumberFormatOptions | Intl.DateTimeFormatOptions;
176
+ register(item: PacemChartSeriesElement): boolean;
177
+ unregister(item: PacemChartSeriesElement): boolean;
178
+ private _itemPropertyChangedCallback;
179
+ propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
180
+ private _handle;
181
+ private _databindAndDrawDebounced;
182
+ private _databind;
183
+ private _key;
184
+ private _mask;
185
+ private _body;
186
+ private _div;
187
+ private _datasource;
188
+ private _grid;
189
+ private _series;
190
+ private _resizer;
191
+ private _size;
192
+ disconnectedCallback(): void;
193
+ viewActivatedCallback(): void;
194
+ private _ensureResizer;
195
+ private _resizeHandler;
196
+ protected get chartSize(): Size;
197
+ protected get chartSeries(): SVGSVGElement[];
198
+ protected get chartBody(): SVGSVGElement;
199
+ protected get chartGrid(): SVGSVGElement;
200
+ protected get chartMask(): SVGMaskElement;
201
+ protected get chartKey(): string;
202
+ protected get chartContainer(): HTMLElement;
203
+ private _broadcastHandler;
204
+ protected assignUiBehaviors(ui: Element, series: ChartDataSeries, data: ChartDataItem, color?: string): void;
205
+ protected disposeUiBehaviors(ui: Element): void;
206
+ protected ensureChartContainer(): HTMLElement;
207
+ protected ensureChartBody(type: string, w?: number, h?: number): SVGSVGElement;
208
+ protected chartDataItemToPoint(input: ChartDataItem, source: ChartDataItem[]): Point;
209
+ protected getVirtualGrid(items: ChartDataItem[], minX: number, maxX: number, minY: number, maxY: number, xAxisType?: "date" | "number" | "string", steps?: number, labels?: number): {
210
+ x: string[];
211
+ y: number[];
212
+ };
213
+ protected wipeOut(series?: SVGSVGElement[], startIndex?: number): void;
214
+ protected buildLinearGradient(seriesIndex: number, invert?: boolean): SVGLinearGradientElement;
215
+ protected setGradientColor(grad: SVGLinearGradientElement, color: string): void;
216
+ protected estimateYAxisLabelWidth(max: number): number;
217
+ protected estimateLabelWidth(txt: string): number;
218
+ protected formatYAxisLabel(y: number): string;
219
+ protected estimateXAxisLabelWidth(max: number | Date | string): number;
220
+ protected formatXAxisLabel(x: number | Date | string): string;
221
+ draw(): void;
222
+ protected abstract drawSeries(datasource: ChartDatasource): any;
223
+ /**
224
+ * Default implementation.
225
+ * @param element
226
+ */
227
+ getAnchorPoint(element: Element): Point;
228
+ }
229
+
230
+
231
+
232
+ declare global {
233
+ namespace Pacem {
234
+ export {
235
+ Charts,
236
+ Components
237
+ };
238
+ }
239
+ }