@dhtmlx/chart 9.3.11 → 9.4.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.
Files changed (53) hide show
  1. package/README.md +1 -1
  2. package/codebase/chart.min.css +1 -1
  3. package/codebase/chart.min.js +3 -3
  4. package/codebase/chart.min.js.map +1 -1
  5. package/codebase/types/ts-calendar/sources/Calendar.d.ts +6 -0
  6. package/codebase/types/ts-calendar/sources/helper.d.ts +1 -0
  7. package/codebase/types/ts-calendar/sources/types.d.ts +3 -0
  8. package/codebase/types/ts-chart/sources/AxisCreator.d.ts +10 -0
  9. package/codebase/types/ts-chart/sources/Chart.d.ts +26 -1
  10. package/codebase/types/ts-chart/sources/helpers/common.d.ts +12 -1
  11. package/codebase/types/ts-chart/sources/helpers/constants.d.ts +2 -0
  12. package/codebase/types/ts-chart/sources/scales/Scale.d.ts +3 -0
  13. package/codebase/types/ts-chart/sources/scales/SvgScales.d.ts +1 -1
  14. package/codebase/types/ts-chart/sources/series/Bar.d.ts +11 -1
  15. package/codebase/types/ts-chart/sources/series/BarX.d.ts +4 -1
  16. package/codebase/types/ts-chart/sources/series/BaseSeria.d.ts +1 -0
  17. package/codebase/types/ts-chart/sources/series/NoScaleSeria.d.ts +1 -1
  18. package/codebase/types/ts-chart/sources/series/ScaleSeria.d.ts +0 -1
  19. package/codebase/types/ts-chart/sources/series/Stacker.d.ts +9 -0
  20. package/codebase/types/ts-chart/sources/types.d.ts +16 -3
  21. package/codebase/types/ts-common/date.d.ts +2 -0
  22. package/codebase/types/ts-data/sources/datacollection/group.d.ts +11 -0
  23. package/codebase/types/ts-data/sources/datacollection.d.ts +84 -3
  24. package/codebase/types/ts-data/sources/methods.d.ts +8 -3
  25. package/codebase/types/ts-data/sources/treecollection.d.ts +99 -0
  26. package/codebase/types/ts-data/sources/types.d.ts +12 -2
  27. package/codebase/types/ts-grid/sources/ExtendedGrid.d.ts +3 -1
  28. package/codebase/types/ts-grid/sources/Grid.d.ts +12 -2
  29. package/codebase/types/ts-grid/sources/helpers/cells.d.ts +7 -1
  30. package/codebase/types/ts-grid/sources/helpers/data.d.ts +16 -1
  31. package/codebase/types/ts-grid/sources/helpers/default.d.ts +1 -0
  32. package/codebase/types/ts-grid/sources/helpers/dom.d.ts +3 -0
  33. package/codebase/types/ts-grid/sources/helpers/zoneFocus.d.ts +25 -4
  34. package/codebase/types/ts-grid/sources/locales/en.d.ts +0 -2
  35. package/codebase/types/ts-grid/sources/modules/ActiveCell.d.ts +26 -0
  36. package/codebase/types/ts-grid/sources/modules/History.d.ts +4 -0
  37. package/codebase/types/ts-grid/sources/modules/Selection.d.ts +5 -6
  38. package/codebase/types/ts-grid/sources/types.d.ts +82 -5
  39. package/codebase/types/ts-grid/sources/ui/cells.d.ts +28 -1
  40. package/codebase/types/ts-grid/sources/ui/content/ComboFilter.d.ts +1 -0
  41. package/codebase/types/ts-grid/sources/ui/content/SelectFilter.d.ts +1 -0
  42. package/codebase/types/ts-grid/sources/ui/content.d.ts +6 -2
  43. package/codebase/types/ts-grid/sources/ui/editors/DateEditor.d.ts +1 -0
  44. package/codebase/types/ts-grid/sources/ui/proContent.d.ts +3 -16
  45. package/codebase/types/ts-layout/sources/Cell.d.ts +10 -0
  46. package/codebase/types/ts-layout/sources/helpers/constants.d.ts +2 -0
  47. package/codebase/types/ts-layout/sources/{helpers.d.ts → helpers/helpers.d.ts} +1 -1
  48. package/codebase/types/ts-layout/sources/types.d.ts +2 -1
  49. package/codebase/types/ts-message/sources/locales/en.d.ts +4 -0
  50. package/codebase/types/ts-treegrid/sources/TreeGrid.d.ts +0 -2
  51. package/codebase/types/ts-treegrid/sources/TreeGridCollection.d.ts +2 -1
  52. package/package.json +1 -1
  53. package/whatsnew.txt +74 -33
@@ -20,10 +20,12 @@ export declare class Calendar extends View implements ICalendar {
20
20
  showDate(date?: Date, mode?: ViewMode): void;
21
21
  destructor(): void;
22
22
  clear(): void;
23
+ private _clear;
23
24
  link(targetCalendar: Calendar): void;
24
25
  private _unlink;
25
26
  private _setSelected;
26
27
  private _getSelected;
28
+ private _normalizeControls;
27
29
  private _draw;
28
30
  private _initHandlers;
29
31
  private _getData;
@@ -31,7 +33,11 @@ export declare class Calendar extends View implements ICalendar {
31
33
  private _drawMonthSelector;
32
34
  private _drawYearSelector;
33
35
  private _drawHeader;
36
+ private _drawControls;
37
+ private _drawControlButton;
38
+ private _drawTimepickerControl;
34
39
  private _drawTimepicker;
35
40
  private _selectDate;
41
+ private _selectToday;
36
42
  private _moveBrowseFocus;
37
43
  }
@@ -1 +1,2 @@
1
1
  export declare const linkButtonClasses = ".dhx_button.dhx_button--view_link.dhx_button--icon.dhx_button--size_medium.dhx_button--color_secondary";
2
+ export declare const getControlButtonClass: (control: "clear" | "today" | "timepicker", fullWidth?: boolean) => string;
@@ -14,6 +14,7 @@ export interface ICalendarConfig {
14
14
  width?: string | number;
15
15
  range?: boolean;
16
16
  $rangeMark?: (a: Date) => string;
17
+ controls?: boolean | TCalendarControlsInput[];
17
18
  /** @deprecated See a documentation: https://docs.dhtmlx.com/ */
18
19
  block?: (a: Date) => boolean;
19
20
  /** @deprecated See a documentation: https://docs.dhtmlx.com/ */
@@ -30,6 +31,8 @@ export interface ICalendar {
30
31
  link(calendar: ICalendar): void;
31
32
  }
32
33
  export type ViewMode = "calendar" | "year" | "month" | "timepicker";
34
+ export type TCalendarControls = "clear" | "today" | "timepicker" | "spacer";
35
+ export type TCalendarControlsInput = TCalendarControls | Uppercase<TCalendarControls> | Capitalize<TCalendarControls>;
33
36
  export interface ICalendarDay {
34
37
  css: string;
35
38
  date: Date;
@@ -2,10 +2,20 @@ import { IAxisCreator, IAxisCreatorConfig, IAxisScale } from "./types";
2
2
  export declare class AxisCreator implements IAxisCreator {
3
3
  private _data;
4
4
  config: IAxisCreatorConfig;
5
+ private _hasFixedMin;
6
+ private _hasFixedMax;
5
7
  constructor(_data: any, conf?: IAxisCreatorConfig);
6
8
  getScale(): IAxisScale;
7
9
  private _getStep;
8
10
  private _calculateSteps;
11
+ private _exactSteps;
12
+ /**
13
+ * The `count` round ticks that cover the range, or null when no allowed step fits it.
14
+ * A bound set in the config is never crossed: a step has to land on such a bound exactly,
15
+ * and the range is only extended past a bound that the axis picked on its own.
16
+ */
17
+ private _roundExactSteps;
18
+ private _buildSteps;
9
19
  private _logSteps;
10
20
  private _addPadding;
11
21
  }
@@ -1,8 +1,11 @@
1
1
  import { IEventSystem } from "../../ts-common/events";
2
2
  import { View } from "../../ts-common/view";
3
3
  import { DataCollection, DataEvents, TreeCollection } from "../../ts-data";
4
- import { ChartEvents, IChart, IChartConfig, IChartSeries, IComposeLayer, IScaleConfig, IScales, ISeria } from "./types";
4
+ import { ChartEvents, IChart, IChartConfig, IChartSeries, IComposeLayer, ILegendConfig, IScaleConfig, IScales, ISeria, ScaleType, SeriaConfig, TChartType } from "./types";
5
5
  import { Exporter } from "./Export";
6
+ type ScaleConfigs = {
7
+ [position: string]: IScaleConfig;
8
+ };
6
9
  export declare class Chart extends View implements IChart {
7
10
  data: DataCollection | TreeCollection;
8
11
  events: IEventSystem<DataEvents | ChartEvents>;
@@ -11,6 +14,10 @@ export declare class Chart extends View implements IChart {
11
14
  protected _layers: IComposeLayer;
12
15
  protected _series: IChartSeries;
13
16
  protected _scales: IScales;
17
+ protected _primaryScales: {
18
+ x?: ScaleType;
19
+ y?: ScaleType;
20
+ };
14
21
  private _tooltip;
15
22
  private _globalHTMLHandlers;
16
23
  private _width;
@@ -22,7 +29,25 @@ export declare class Chart extends View implements IChart {
22
29
  eachSeries(handler: (serie: ISeria) => any): any[];
23
30
  destructor(): void;
24
31
  setConfig(config: IChartConfig): void;
32
+ protected _isProOnlyType(type: TChartType): boolean;
33
+ protected _seriaType(cfg: SeriaConfig): TChartType;
34
+ /**
35
+ * Positions of the scales a series is drawn against: the argument axis and the value axis.
36
+ * The value axis is chosen by the type of the series, not by the direction of the scale -
37
+ * BarX remaps the positions on its own, see BarX.addScale.
38
+ */
39
+ protected _resolveSeriaScales(cfg: SeriaConfig, type: TChartType): ScaleType[];
40
+ protected _valueAxis(type: TChartType, scales: ScaleType[]): ScaleType;
41
+ protected _prepareSeriaConfig(cfg: SeriaConfig, index: number): SeriaConfig;
42
+ protected _prepareLegendConfig(cfg: ILegendConfig): ILegendConfig;
25
43
  protected _setScale(config: IScaleConfig, position: string): void;
44
+ /**
45
+ * Binds the scale to the one it takes the number of ticks from, so that the grids match.
46
+ * Both of them have to be linear: the ticks of a logarithmic axis are not evenly spaced,
47
+ * so an equal number of them would still land at different offsets.
48
+ */
49
+ protected _alignScale(configs: ScaleConfigs, position: ScaleType): void;
26
50
  protected _detectScaleType(config: any, key: any): any;
27
51
  private _initEvents;
28
52
  }
53
+ export {};
@@ -1,7 +1,13 @@
1
1
  import { IContainerConfig } from "../../../ts-common/core";
2
+ import { ScaleType, SmartColor, TChartTotal, TChartType } from "../types";
3
+ export declare const X_AXES: ScaleType[];
4
+ export declare const Y_AXES: ScaleType[];
5
+ export declare function isXAxis(position: ScaleType): boolean;
6
+ export declare function hasValueAxis(type: TChartType): boolean;
2
7
  export declare function getDefaultColor(index?: number, isTreeMapRange?: boolean): string;
3
8
  type Locator = (data: any) => number | string;
4
9
  export declare function locator(value: string | Locator): Locator;
10
+ export declare function getSeriaColor(color: SmartColor, item: any): string;
5
11
  export declare function log10(x: number): number;
6
12
  export declare const getTextWidth: (...args: string[]) => number;
7
13
  export declare function getColorShade(color: string, light: number): string;
@@ -33,12 +39,17 @@ export declare function linearGradient(grad: IGradient, id: string): any;
33
39
  export declare function getRadialGradient(opts: any, stops: IStop[], id: string): any;
34
40
  export declare function euclideanDistance(x1: number, y1: number, x2: number, y2: number): number;
35
41
  export declare function roundToTwoNumAfterPoint(p: number): number;
42
+ export declare function formatTotal(total: TChartTotal, value: number): string;
43
+ export declare function getTotalAriaAttrs(total: string): {
44
+ role: string;
45
+ "aria-roledescription": string;
46
+ "aria-label": string;
47
+ };
36
48
  export declare function verticalCenteredText(text: string): any;
37
49
  export declare function verticalTopText(text: string): any;
38
50
  export declare function verticalBottomText(text: string): any;
39
51
  export declare function calcPointRef(pointId: string, serieId: string): string;
40
52
  export declare function getClassesForRotateScale(position: any, angle: any): string;
41
- export declare function getScales(config: any): any[];
42
53
  export declare function getSizesSVGText(text: string, config?: IContainerConfig): any[];
43
54
  export declare function superposition(objA: IText, objB: IText): boolean;
44
55
  export declare function checkPositions(current: IText, previos: IText, radiusX: number, radiusY: number, obj: ITextObj): void;
@@ -0,0 +1,2 @@
1
+ export declare const TOTAL_TEXT_PADDING = 8;
2
+ export declare const TOTAL_TEXT_HEIGHT = 14;
@@ -8,10 +8,13 @@ export declare class Scale implements IScale {
8
8
  protected _axis: IAxisLike<any>;
9
9
  protected _position: ScaleType;
10
10
  protected _padding: boolean;
11
+ protected _alignTo: IScale;
11
12
  protected _charts: ILikeSeria[];
12
13
  constructor(_data: DataCollection, config: IScaleConfig, position: ScaleType);
13
14
  addPadding(): void;
14
15
  getSize(): number;
16
+ getAxis(): IAxisLike<any>;
17
+ alignTo(scale: IScale): void;
15
18
  scaleReady(sizes: any): void;
16
19
  point(pos: number): number;
17
20
  add(val: ILikeSeria): void;
@@ -4,7 +4,7 @@ type PointInfo = [number, string];
4
4
  export declare function bottom(points: PointInfo[], config: IScaleConfig, width: number, height: number): VNode;
5
5
  export declare function bottomGrid(points: PointInfo[], width: number, height: number, config: IGridRenderConfig): VNode;
6
6
  export declare function top(points: PointInfo[], config: IScaleConfig, width: number, _height: number): VNode;
7
- export declare function topGrid(points: PointInfo[], _width: number, height: number, config: IGridRenderConfig): VNode;
7
+ export declare function topGrid(points: PointInfo[], width: number, height: number, config: IGridRenderConfig): VNode;
8
8
  export declare function left(points: PointInfo[], config: IScaleConfig, _width: number, height: number): VNode;
9
9
  export declare function leftGrid(points: PointInfo[], width: number, height: number, config: IGridRenderConfig): VNode;
10
10
  export declare function right(points: PointInfo[], config: IScaleConfig, width: number, height: number): VNode;
@@ -1,10 +1,12 @@
1
+ import { IFitPosition } from "../../../ts-common/html";
1
2
  import { IScale, ISeriaConfig, PointData, ScaleType, SvgElement, TooltipType } from "../types";
2
3
  import ScaleSeria from "./ScaleSeria";
3
4
  export default class Bar extends ScaleSeria {
4
5
  protected _shift: number;
5
6
  protected _baseLinePosition: number;
7
+ private _gradients;
6
8
  addScale(type: ScaleType, scale: IScale): void;
7
- seriesShift(shift: number): number;
9
+ seriesShift(shift?: number): number;
8
10
  paint(width: number, height: number, prev?: PointData[]): SvgElement;
9
11
  getTooltipType(_id: string, _x?: number, y?: number): TooltipType;
10
12
  protected _getClosestDist(x: any, y: any, px: any, py: any): number;
@@ -17,6 +19,14 @@ export default class Bar extends ScaleSeria {
17
19
  transform: string;
18
20
  };
19
21
  protected _getForm(points: PointData[], _width: number, height: number, prev: PointData[]): object;
22
+ paintTotals(labels: string[], stack: PointData[][]): SvgElement;
23
+ getTotalsPadding(_labels: string[]): IFitPosition;
20
24
  protected _getText(item: any): any;
25
+ protected _getTotalAnchor(index: number, stack: PointData[][]): [number, number];
26
+ protected _getTotalText([x, y]: [number, number], total: string): SvgElement;
27
+ protected _getTotalTextHeight(): number;
28
+ protected _getFill(id: string): string;
29
+ private _gradientFill;
30
+ private _gradientDefs;
21
31
  protected _setDefaults(config: ISeriaConfig): void;
22
32
  }
@@ -1,3 +1,4 @@
1
+ import { IFitPosition } from "../../../ts-common/html";
1
2
  import { IScale, PointData, ScaleType, SvgElement, TooltipType } from "../types";
2
3
  import Bar from "./Bar";
3
4
  export default class BarX extends Bar {
@@ -5,7 +6,9 @@ export default class BarX extends Bar {
5
6
  paint(width: number, height: number, prev?: PointData[]): SvgElement;
6
7
  getTooltipType(id: string, x?: number, y?: number): TooltipType;
7
8
  getClosest(x: number, y: number): [number, number, number, string];
8
- protected _getText(item: any): any;
9
+ getTotalsPadding(labels: string[]): IFitPosition;
10
+ protected _getTotalAnchor(index: number, stack: PointData[][]): [number, number];
11
+ protected _getTotalText([x, y]: [number, number], total: string): SvgElement;
9
12
  protected _getClosestDist(x: any, y: any, px: any, py: any): number;
10
13
  protected _path(item: any, prev: any): string;
11
14
  protected _base(height: any): number;
@@ -28,4 +28,5 @@ export default abstract class BaseSeria implements ISeria {
28
28
  protected _setDefaults(config: any): void;
29
29
  protected _defaultLocator(_: any): any[];
30
30
  protected _getPointType(form: PointType, color: string): DrawPoint;
31
+ protected _getPointColor(): string;
31
32
  }
@@ -9,7 +9,7 @@ export default class NoScaleSeria extends BaseSeria {
9
9
  protected _gradient: any;
10
10
  protected _center: [number, number];
11
11
  protected _tooltipData: Array<[number, number]>;
12
- private _sum;
12
+ protected _sum: number;
13
13
  scaleReady(sizes: IFitPosition): IFitPosition;
14
14
  dataReady(): PointData[];
15
15
  toggle(id?: string): void;
@@ -5,7 +5,6 @@ export default class ScaleSeria extends BaseSeria {
5
5
  protected _xLocator: Locator;
6
6
  protected xScale: IScale;
7
7
  protected yScale: IScale;
8
- protected _gradient: any;
9
8
  addScale(type: ScaleType, scale: IScale): void;
10
9
  paint(width: number, height: number): void;
11
10
  dataReady(prev?: PointData[]): PointData[];
@@ -1,9 +1,18 @@
1
+ import { IFitPosition } from "../../../ts-common/html";
1
2
  import { IStacker, PointData } from "../types";
2
3
  export default class Stacker implements IStacker {
3
4
  private _series;
4
5
  private _toPaint;
6
+ private _totalLabels;
7
+ private _measuredStacks;
5
8
  add(seria: any): void;
9
+ seriesShift(shift?: number): number;
10
+ measureTotalsOf(stacks: IStacker[]): void;
11
+ getTotalsPadding(): IFitPosition | null;
6
12
  dataReady(prev?: PointData[]): PointData[];
13
+ scaleReady(sizes: IFitPosition): void;
7
14
  getPoints(): PointData[];
8
15
  paint(width: number, height: number, prev?: PointData[]): any;
16
+ private _getTotalsSeria;
17
+ private _getTotalLabels;
9
18
  }
@@ -19,7 +19,9 @@ export interface IChartConfig {
19
19
  maxPoints?: number;
20
20
  data?: DataCollection<any> | any[];
21
21
  exportStyles?: boolean | string[];
22
+ total?: TChartTotal;
22
23
  }
24
+ export type TChartTotal = boolean | ((total: number) => string | number);
23
25
  export type TChartType = "bar" | "line" | "spline" | "scatter" | "area" | "donut" | "pie" | "pie3D" | "radar" | "xbar" | "splineArea" | "treeMap" | "calendarHeatMap";
24
26
  export declare enum ChartEvents {
25
27
  toggleSeries = "toggleSeries",
@@ -53,6 +55,8 @@ export interface ISeria extends ILikeSeria {
53
55
  getTooltipType(id: string, x?: number, y?: number): TooltipType;
54
56
  getClosest(x: number, y: number): [number, number, number, string];
55
57
  getClosestVertical(x: number): [number, number, number, string, number];
58
+ paintTotals?(labels: string[], stack: PointData[][]): SvgElement;
59
+ getTotalsPadding?(labels: string[]): IFitPosition;
56
60
  }
57
61
  export type TreeDirectionType = "asc" | "desc";
58
62
  export interface ISeriaConfig {
@@ -63,6 +67,7 @@ export interface ISeriaConfig {
63
67
  label?: ((item: ISeriaConfig) => string) | string;
64
68
  pointType?: PointType;
65
69
  legendType?: LegendType;
70
+ scale?: ScaleType;
66
71
  scales?: ScaleType[];
67
72
  active?: boolean;
68
73
  pointColor?: string;
@@ -71,8 +76,8 @@ export interface ISeriaConfig {
71
76
  strokeWidth?: number;
72
77
  barWidth?: number;
73
78
  css?: string;
74
- fill?: string;
75
- color?: string;
79
+ fill?: SmartColor;
80
+ color?: SmartColor;
76
81
  alpha?: number;
77
82
  gradient?: Gradient;
78
83
  showText?: boolean;
@@ -85,7 +90,8 @@ export interface ISeriaConfig {
85
90
  direction?: TreeDirectionType;
86
91
  treeSeries?: ITreeSeries[];
87
92
  baseLine?: number;
88
- stacked?: boolean;
93
+ stacked?: boolean | string;
94
+ total?: TChartTotal;
89
95
  }
90
96
  export type SeriaConfig = ISeriaConfig | INoScaleConfig;
91
97
  export interface IScale extends IComposable {
@@ -93,6 +99,8 @@ export interface IScale extends IComposable {
93
99
  add(chart: ILikeSeria): void;
94
100
  point(item: object | number): number;
95
101
  getSize(): number;
102
+ getAxis(): IAxisLike<any>;
103
+ alignTo(scale: IScale): void;
96
104
  addPadding(): void;
97
105
  }
98
106
  export interface IScaleConfig extends IAxisCreatorConfig {
@@ -106,6 +114,7 @@ export interface IScaleConfig extends IAxisCreatorConfig {
106
114
  textPadding?: number;
107
115
  hidden?: boolean;
108
116
  grid?: boolean;
117
+ alignTicks?: boolean | ScaleType;
109
118
  dashed?: boolean;
110
119
  targetLine?: number | string;
111
120
  targetValue?: number;
@@ -236,6 +245,7 @@ export interface IAxisCreatorConfig {
236
245
  log?: boolean;
237
246
  padding?: number;
238
247
  maxTicks?: number;
248
+ exactTicks?: number;
239
249
  type?: string;
240
250
  }
241
251
  export interface IAxisScale {
@@ -285,8 +295,11 @@ export type Locator = (item: any) => any;
285
295
  export type DrawPoint = (x: number, y: number, ref?: string) => any;
286
296
  export type NoScaleSubType = "basic" | "percentOnly" | "valueOnly";
287
297
  export type SmartLocator = Locator | string;
298
+ export type SmartColor = ((item: any) => string) | string;
288
299
  export interface IStacker extends IComposable, ILikeSeria {
289
300
  add(seria: ISeria): void;
301
+ measureTotalsOf(stacks: IStacker[]): void;
302
+ getTotalsPadding(): IFitPosition | null;
290
303
  }
291
304
  export type PointData = [number, number, string, (number | string)?, number?, TreePointData?];
292
305
  export type TreePointData = {
@@ -4,6 +4,8 @@ export declare const locale: {
4
4
  daysShort: string[];
5
5
  days: string[];
6
6
  cancel: string;
7
+ today: string;
8
+ clear: string;
7
9
  };
8
10
  export declare function getFormattedDate(format: string, date: Date): string;
9
11
  export declare function getExcelDate(date: Date): number;
@@ -1,3 +1,4 @@
1
+ import { IAnyObj, Id } from "../../../ts-common/types";
1
2
  import { IDataItem } from "../types";
2
3
  export type TGroupOrderFunc = (i: IDataItem) => string;
3
4
  export type TAggregate = "sum" | "count" | "min" | "max" | "avg" | string;
@@ -16,6 +17,11 @@ export type TDisplayMode = "original" | "column" | "row";
16
17
  export interface IGroupConfig {
17
18
  displayMode?: TDisplayMode;
18
19
  showMissed?: boolean | string;
20
+ /**
21
+ * Whether a group whose items are all filtered out stays in the data with a zero count.
22
+ * Defaults to `false`, i.e. such a group is dropped.
23
+ */
24
+ showEmptyGroups?: boolean;
19
25
  field?: string;
20
26
  }
21
27
  export interface IGroup {
@@ -24,18 +30,23 @@ export interface IGroup {
24
30
  isGrouped(): boolean;
25
31
  getGroupedFields(): string[];
26
32
  getGroupConfig(config?: IGroupConfig): IGroupConfig;
33
+ recalculate(node: IDataItem, items: IDataItem[], count?: number, total?: number): IAnyObj;
34
+ hasMap(id: Id): boolean;
27
35
  }
28
36
  export declare class Group implements IGroup {
29
37
  private _init;
30
38
  private _config;
31
39
  private _groupSet;
32
40
  private _groupOrderFields;
41
+ private _nodes;
33
42
  constructor();
34
43
  group(order: TGroupOrder[], arr: IDataItem[], config?: IGroupConfig): IDataItem[];
35
44
  ungroup(modifiedData?: IDataItem[]): IDataItem[];
36
45
  isGrouped(): boolean;
37
46
  getGroupedFields(): string[];
38
47
  getGroupConfig(config?: IGroupConfig): IGroupConfig;
48
+ recalculate(node: IDataItem, items: IDataItem[], count?: number, total?: number): IAnyObj;
49
+ hasMap(id: Id): boolean;
39
50
  private _group;
40
51
  private _addSummaryRow;
41
52
  private _toAggregate;
@@ -1,7 +1,7 @@
1
1
  import { IEventSystem } from "../../ts-common/events";
2
2
  import { Id } from "../../ts-common/types";
3
3
  import { Sort } from "./datacollection/sort";
4
- import { DataCallback, DataEvents, IDataCollection, IDataItem, IDataProxy, IFilterCallback, IFilterConfig, IFilterMode, ISortMode, ITreeCollection, IUpdateObject, ReduceCallBack, Statuses, IDataEventsHandlersMap, DataDriver, IDataConfig, ISortConfig, IDataDriver, IFilterComplexMode, IFilter, IResetFilterConfig, IGroupDataConfig, ISortingState } from "./types";
4
+ import { DataCallback, DataEvents, IDataChangeService, IDataCollection, IDataItem, IDataProxy, IFilterCallback, IFilterConfig, IFilterMode, ISortMode, ITreeCollection, IUpdateObject, ReduceCallBack, Statuses, IDataEventsHandlersMap, DataDriver, IDataConfig, ISortConfig, IDataDriver, IFilterComplexMode, IFilter, IResetFilterConfig, IGroupDataConfig, ISortingState } from "./types";
5
5
  import { TGroupOrder, IGroup } from "./datacollection/group";
6
6
  export declare class DataCollection<T extends IDataItem = IDataItem> implements IDataCollection<T> {
7
7
  loadData: Promise<any>;
@@ -41,6 +41,22 @@ export declare class DataCollection<T extends IDataItem = IDataItem> implements
41
41
  getItem(id: Id): T;
42
42
  update(id: Id, newItem: IUpdateObject, silent?: boolean): void;
43
43
  getIndex(id: Id): number;
44
+ /**
45
+ * Returns the index of an item among the visible ones, i.e. in the order the items are
46
+ * rendered in. Unlike {@link DataCollection.getIndex} the hidden items are not counted, and
47
+ * a range set by {@link DataCollection.setRange} narrows the counting down to that range.
48
+ * @param id - The id of the item.
49
+ * @returns The zero-based index of the item, or `-1` if the item doesn't exist, is hidden,
50
+ * or is out of the currently set range.
51
+ * @example
52
+ * ```ts
53
+ * collection.update("2", { hidden: true });
54
+ * collection.getIndex("3"); // 2
55
+ * collection.getVisibleIndex("3"); // 1
56
+ * collection.getVisibleIndex("2"); // -1
57
+ * ```
58
+ */
59
+ getVisibleIndex(id: Id): number;
44
60
  getId(index: number): Id;
45
61
  getLength(): number;
46
62
  isDataLoaded(from?: number, to?: number): boolean;
@@ -157,7 +173,14 @@ export declare class DataCollection<T extends IDataItem = IDataItem> implements
157
173
  */
158
174
  $parse(data: any[], resetRules?: boolean): void;
159
175
  save(url: IDataProxy | string): void;
160
- changeId(id: Id, newId?: Id, silent?: boolean): void;
176
+ /**
177
+ * Changes the id of a data item.
178
+ * @param id - The current id of the item.
179
+ * @param newId - The new id for the item. If omitted, a unique id is generated automatically.
180
+ * @param silent - If true, the change event is not fired.
181
+ * @returns The new id of the item, or the original id if the change was rejected.
182
+ */
183
+ changeId(id: Id, newId?: Id, silent?: boolean): Id;
161
184
  isSaved(): boolean;
162
185
  map(callback: DataCallback<T>): any[];
163
186
  mapRange(from: number, to: number, callback: DataCallback<T>): any[];
@@ -182,7 +205,20 @@ export declare class DataCollection<T extends IDataItem = IDataItem> implements
182
205
  protected _removeCore(id: Id): void;
183
206
  protected _parse_data(data: any[]): void;
184
207
  protected _approximate(data: any[], values: string[], maxNum: number): any[];
185
- protected _onChange(status: Statuses, id: Id, obj: any): void;
208
+ /**
209
+ * Remaps the item to the new id inside all the internal structures.
210
+ * `_order`, `_initFilterOrder` and `_initSortOrder` keep the references to the same
211
+ * objects as `_pull`, so changing `item.id` is enough for them.
212
+ * @internal
213
+ */
214
+ protected _changeIdCore(id: Id, newId: Id): void;
215
+ /**
216
+ * Retargets the pending save operations of the item to its new id,
217
+ * so that a rename between `add` and `save` doesn't produce a second request.
218
+ * @internal
219
+ */
220
+ private _remapChanges;
221
+ protected _onChange(status: Statuses, id: Id, obj: any, service?: IDataChangeService): void;
186
222
  protected _addToOrder(array: any[], obj: any, index?: number): void;
187
223
  /**
188
224
  * Reorders the data by all currently stored sorting rules.
@@ -224,6 +260,44 @@ export declare class DataCollection<T extends IDataItem = IDataItem> implements
224
260
  * @internal
225
261
  */
226
262
  protected _reapplyRules(): void;
263
+ /**
264
+ * Brings the group headers in line with the items the collection holds now: the counts and the
265
+ * aggregates next to the group names are computed while the tree is built, so every change of
266
+ * what is in the collection leaves them stale. Headers left with nothing under them are dropped
267
+ * unless `showEmptyGroups` is set — see {@link DataCollection._dropGroups} for what dropping a
268
+ * header costs it.
269
+ * @internal
270
+ */
271
+ protected _recalculateGroups(): void;
272
+ /**
273
+ * Collects a group header together with everything below it: the nested headers, their summary
274
+ * rows and the items. Removing the header alone would leave the items with a parent that is not
275
+ * there any more, and the counts of the groups above it short.
276
+ * A `TreeCollection` needs none of this, its {@link TreeCollection._removeCore} already takes
277
+ * the subtree of an item with it.
278
+ * @param id - The id of the header.
279
+ * @returns The ids to remove, the header itself last.
280
+ * @internal
281
+ */
282
+ protected _getGroupSubtree(id: Id): Id[];
283
+ /**
284
+ * Takes the group headers left with nothing in them out of the data, their summary rows and
285
+ * their nested groups included: a group is empty only when everything under it is.
286
+ * While a filter is applied the headers only leave `_order`, because `_initFilterOrder` keeps
287
+ * the whole grouped order and resetting the filter has to bring them back. Without a filter
288
+ * there is nothing to restore them from, so they leave the collection for good.
289
+ * @param ids - Ids of the headers to drop.
290
+ * @internal
291
+ */
292
+ protected _dropGroups(ids: Set<string>): void;
293
+ /**
294
+ * Counts the items every group header holds in a given order, its whole subtree and not just
295
+ * the items directly under it. Summary rows are not items.
296
+ * @param order - The order to count over.
297
+ * @returns The counts, keyed by header id.
298
+ * @internal
299
+ */
300
+ protected _countGroupItems(order: T[]): Map<Id, number>;
227
301
  /**
228
302
  * Turns a field/value rule into a predicate.
229
303
  * @param rule - The rule to convert.
@@ -261,4 +335,11 @@ export declare class DataCollection<T extends IDataItem = IDataItem> implements
261
335
  * @internal
262
336
  */
263
337
  private _parse;
338
+ /**
339
+ * Fires the change event. The service payload is appended only when it is set,
340
+ * so that the arguments of the event stay exactly the same as before for every
341
+ * operation that doesn't provide it.
342
+ * @internal
343
+ */
344
+ private _fireChange;
264
345
  }
@@ -1,11 +1,16 @@
1
1
  type Item = {
2
2
  [key: string]: any;
3
3
  };
4
+ /**
5
+ * Aggregation functions shared by the group aggregates and the widget summaries.
6
+ * `sum` and `count` return `0` for an empty set, the rest return `null`: there is no
7
+ * meaningful average, minimum or maximum of nothing.
8
+ */
4
9
  export declare const methods: {
5
10
  sum: (items: Item[], field: string) => number;
6
- avg: (items: Item[], field: string) => number;
11
+ avg: (items: Item[], field: string) => number | null;
7
12
  count: (items: Item[], field: string) => number;
8
- min: (items: Item[], field: string) => number;
9
- max: (items: Item[], field: string) => number;
13
+ min: (items: Item[], field: string) => number | null;
14
+ max: (items: Item[], field: string) => number | null;
10
15
  };
11
16
  export {};