mdt-charts 1.33.3 → 1.34.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 (59) hide show
  1. package/lib/config/config.d.ts +25 -4
  2. package/lib/engine/features/axis/axis.d.ts +1 -0
  3. package/lib/engine/features/axis/axis.js +6 -2
  4. package/lib/engine/features/axis/axisHelper.js +1 -3
  5. package/lib/engine/features/groupLabels/groupLabels.d.ts +17 -0
  6. package/lib/engine/features/groupLabels/groupLabels.js +61 -0
  7. package/lib/engine/features/scale/scale.d.ts +3 -2
  8. package/lib/engine/features/scale/scale.js +11 -1
  9. package/lib/engine/features/valueLabels/valueLabels.d.ts +3 -3
  10. package/lib/engine/features/valueLabels/valueLabels.js +1 -1
  11. package/lib/engine/filterManager/filterEventManager.d.ts +1 -1
  12. package/lib/engine/filterManager/filterEventManager.js +1 -1
  13. package/lib/engine/twoDimensionalNotation/twoDimensionalManager.d.ts +1 -0
  14. package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +8 -0
  15. package/lib/model/featuresModel/axis/axisModel.d.ts +10 -10
  16. package/lib/model/featuresModel/axis/axisModel.js +10 -3
  17. package/lib/model/featuresModel/axis/axisModelService.js +2 -2
  18. package/lib/model/featuresModel/grouping/groupingLabels/groupingLabelsCoordinateHandlers.d.ts +20 -0
  19. package/lib/model/featuresModel/grouping/groupingLabels/groupingLabelsCoordinateHandlers.js +36 -0
  20. package/lib/model/featuresModel/grouping/groupingLabels/groupingLabelsScaler.d.ts +22 -0
  21. package/lib/model/featuresModel/grouping/groupingLabels/groupingLabelsScaler.js +49 -0
  22. package/lib/model/featuresModel/legendModel/legendModel.d.ts +1 -1
  23. package/lib/model/featuresModel/legendModel/legendModel.js +4 -4
  24. package/lib/model/featuresModel/legendModel/polarMarginCalculator.js +1 -1
  25. package/lib/model/featuresModel/legendModel/twoDimLegendModel.d.ts +1 -1
  26. package/lib/model/featuresModel/legendModel/twoDimLegendModel.js +5 -3
  27. package/lib/model/featuresModel/otherComponents.js +1 -2
  28. package/lib/model/featuresModel/scaleModel/scaleModel.d.ts +6 -3
  29. package/lib/model/featuresModel/scaleModel/scaleModel.js +49 -7
  30. package/lib/model/featuresModel/scaleModel/scaleModelServices.js +3 -3
  31. package/lib/model/featuresModel/tooltipModel/tooltipContentModel.js +3 -3
  32. package/lib/model/featuresModel/valueLabelsModel/valueLabelsModel.d.ts +3 -3
  33. package/lib/model/{EventEmitter.d.ts → helpers/eventEmitter.d.ts} +1 -1
  34. package/lib/model/helpers/twoDimensionalModelHelper.d.ts +1 -1
  35. package/lib/model/margin/marginModel.js +4 -4
  36. package/lib/model/margin/twoDim/twoDimMarginModel.d.ts +1 -1
  37. package/lib/model/margin/twoDim/twoDimMarginModel.js +6 -3
  38. package/lib/model/model.d.ts +51 -8
  39. package/lib/model/modelBuilder.js +2 -1
  40. package/lib/model/modelInstance/canvasModel/legendCanvasModel.d.ts +5 -0
  41. package/lib/model/modelInstance/canvasModel/legendCanvasModel.js +13 -0
  42. package/lib/model/modelInstance/canvasModel/titleCanvas.d.ts +3 -3
  43. package/lib/model/modelInstance/canvasModel/titleCanvas.js +21 -2
  44. package/lib/model/modelInstance/configReader/baseConfigReader.d.ts +6 -0
  45. package/lib/model/modelInstance/configReader/baseConfigReader.js +9 -0
  46. package/lib/model/modelInstance/configReader/polarConfigReader/polarConfigReader.d.ts +7 -0
  47. package/lib/model/modelInstance/configReader/polarConfigReader/polarConfigReader.js +8 -0
  48. package/lib/model/modelInstance/configReader/twoDimConfigReader.ts/groupingConfigReader/groupingConfigReader.d.ts +29 -0
  49. package/lib/model/modelInstance/configReader/twoDimConfigReader.ts/groupingConfigReader/groupingConfigReader.js +102 -0
  50. package/lib/model/modelInstance/{configReader.d.ts → configReader/twoDimConfigReader.ts/twoDimConfigReader.d.ts} +6 -13
  51. package/lib/model/modelInstance/{configReader.js → configReader/twoDimConfigReader.ts/twoDimConfigReader.js} +8 -19
  52. package/lib/model/modelInstance/modelInstance.js +1 -1
  53. package/lib/model/modelInstance/titleConfigReader.d.ts +2 -2
  54. package/lib/model/notations/twoDimensionalModel.d.ts +1 -1
  55. package/lib/model/notations/twoDimensionalModel.js +47 -2
  56. package/package.json +1 -1
  57. package/lib/model/featuresModel/titleModel.d.ts +0 -5
  58. package/lib/model/featuresModel/titleModel.js +0 -16
  59. /package/lib/model/{EventEmitter.js → helpers/eventEmitter.js} +0 -0
@@ -1,10 +1,9 @@
1
1
  import { LegendModel } from "./legendModel/legendModel";
2
- import { TitleModel } from "./titleModel";
3
2
  import { TooltipCanvasModel } from "./tooltipModel/tooltipCanvasModel";
4
3
  export class OtherComponentsModel {
5
4
  static getOtherComponentsModel(dependencies, modelInstance) {
6
5
  const canvasModel = modelInstance.canvasModel;
7
- canvasModel.titleCanvas.init(TitleModel.getTitleModel(dependencies.titleConfig));
6
+ canvasModel.titleCanvas.init(dependencies.titleConfig);
8
7
  return {
9
8
  legendBlock: LegendModel.getBaseLegendBlockModel(canvasModel, dependencies.legendConfig),
10
9
  titleBlock: canvasModel.titleCanvas.getModel(),
@@ -1,7 +1,8 @@
1
1
  import { ScaleKeyModel, ScaleValueModel } from "../../model";
2
2
  import { MdtChartsTwoDimensionalOptions, MdtChartsDataRow } from "../../../config/config";
3
3
  import { CanvasModel } from "../../modelInstance/canvasModel/canvasModel";
4
- import { TwoDimConfigReader } from "../../modelInstance/configReader";
4
+ import { TwoDimConfigReader } from "../../modelInstance/configReader/twoDimConfigReader.ts/twoDimConfigReader";
5
+ import { BarOptionsCanvas } from "../../../designer/designerConfig";
5
6
  export declare enum ScaleType {
6
7
  Key = 0,
7
8
  Value = 1
@@ -9,10 +10,12 @@ export declare enum ScaleType {
9
10
  export declare class ScaleModel {
10
11
  private readonly options;
11
12
  private readonly canvasModel;
12
- constructor(options: MdtChartsTwoDimensionalOptions, canvasModel: CanvasModel);
13
- getScaleKey(allowableKeys: string[]): ScaleKeyModel;
13
+ private readonly barCanvas;
14
+ constructor(options: MdtChartsTwoDimensionalOptions, canvasModel: CanvasModel, barCanvas: BarOptionsCanvas);
15
+ getScaleKey(domainValues: string[]): ScaleKeyModel;
14
16
  getScaleLinear(dataRows: MdtChartsDataRow[], configReader?: TwoDimConfigReader): ScaleValueModel;
15
17
  getScaleSecondaryLinear(dataRows: MdtChartsDataRow[], configReader?: TwoDimConfigReader): ScaleValueModel;
18
+ private getBandScaleSizeParams;
16
19
  private getChartsByTypes;
17
20
  private getScaleKeyType;
18
21
  }
@@ -6,21 +6,29 @@ export var ScaleType;
6
6
  ScaleType[ScaleType["Value"] = 1] = "Value";
7
7
  })(ScaleType || (ScaleType = {}));
8
8
  export class ScaleModel {
9
- constructor(options, canvasModel) {
9
+ constructor(options, canvasModel, barCanvas) {
10
10
  this.options = options;
11
11
  this.canvasModel = canvasModel;
12
+ this.barCanvas = barCanvas;
12
13
  }
13
- getScaleKey(allowableKeys) {
14
+ getScaleKey(domainValues) {
14
15
  const bandLikeCharts = this.getChartsByTypes(this.options.charts, ["bar", "dot"]);
15
- return {
16
- domain: allowableKeys,
16
+ const baseModel = {
17
+ domain: domainValues,
17
18
  range: {
18
19
  start: 0,
19
20
  end: getScaleKeyRangePeek(this.options.orientation, this.canvasModel)
20
- },
21
- type: this.getScaleKeyType(this.options.charts),
22
- elementsAmount: getElementsAmountForScale(bandLikeCharts)
21
+ }
23
22
  };
23
+ const type = this.getScaleKeyType(this.options.charts);
24
+ if (type === "point") {
25
+ return Object.assign(Object.assign({}, baseModel), { type: "point" });
26
+ }
27
+ if (type === "band") {
28
+ const elementsInGroupAmount = getElementsAmountForScale(bandLikeCharts);
29
+ return Object.assign(Object.assign({}, baseModel), { type: "band", elementsAmount: elementsInGroupAmount, sizes: this.getBandScaleSizeParams(baseModel.domain, baseModel.range, elementsInGroupAmount) });
30
+ }
31
+ throw new Error("Unknown scale key type");
24
32
  }
25
33
  getScaleLinear(dataRows, configReader) {
26
34
  var _a;
@@ -46,6 +54,40 @@ export class ScaleModel {
46
54
  formatter: (_a = configReader === null || configReader === void 0 ? void 0 : configReader.getSecondaryAxisLabelFormatter()) !== null && _a !== void 0 ? _a : null
47
55
  };
48
56
  }
57
+ getBandScaleSizeParams(domainValues, range, elementsInGroupAmount) {
58
+ const paddings = {
59
+ outer: 0,
60
+ inner: 0
61
+ };
62
+ const getStepSize = () => (Math.abs(range.end - range.start) + paddings.inner - 2 * paddings.outer) / domainValues.length;
63
+ const getBandSize = () => getStepSize() - paddings.inner;
64
+ const initialBandSize = getBandSize();
65
+ if (this.barCanvas.groupMinDistance < initialBandSize) {
66
+ paddings.inner = this.barCanvas.groupMinDistance;
67
+ paddings.outer = this.barCanvas.groupMinDistance / 2;
68
+ }
69
+ //TODO: calculate without loop
70
+ while (getBandSize() >
71
+ this.barCanvas.maxBarWidth * elementsInGroupAmount +
72
+ this.barCanvas.barDistance * (elementsInGroupAmount - 1) &&
73
+ paddings.inner < this.barCanvas.groupMaxDistance) {
74
+ paddings.inner++;
75
+ }
76
+ paddings.outer = 1;
77
+ //TODO: calculate without loop
78
+ while (getStepSize() >
79
+ this.barCanvas.maxBarWidth * elementsInGroupAmount +
80
+ this.barCanvas.groupMaxDistance +
81
+ this.barCanvas.barDistance * (elementsInGroupAmount - 1)) {
82
+ paddings.outer += 1;
83
+ }
84
+ return {
85
+ paddingInner: paddings.inner,
86
+ paddingOuter: paddings.outer,
87
+ bandSize: initialBandSize,
88
+ recalculatedStepSize: getStepSize()
89
+ };
90
+ }
49
91
  getChartsByTypes(charts, types) {
50
92
  return charts.filter((chart) => types.includes(chart.type));
51
93
  }
@@ -11,12 +11,12 @@ export function getScaleValueRangePeek(chartOrientation, canvasModel) {
11
11
  export function getElementsAmountForScale(bandLikeCharts) {
12
12
  if (bandLikeCharts.length === 0)
13
13
  return 1;
14
- let barAmounts = {};
14
+ let barAmounts = {
15
+ dot: 1
16
+ };
15
17
  bandLikeCharts.forEach((chart) => {
16
18
  if (!barAmounts[chart.type])
17
19
  barAmounts[chart.type] = 0;
18
- if (chart.type === "dot")
19
- barAmounts[chart.type] = 1;
20
20
  if (chart.type === "bar") {
21
21
  if (chart.isSegmented)
22
22
  barAmounts[chart.type] += 1;
@@ -28,9 +28,9 @@ export class TwoDimTooltipContentGenerator {
28
28
  valueField: initialRow.valueField
29
29
  };
30
30
  });
31
- initialRows = ((_b = (_a = this.options.publicOptions) === null || _a === void 0 ? void 0 : _a.rows) === null || _b === void 0 ? void 0 : _b.filterPredicate)
32
- ? initialRows.filter((row) => this.options.publicOptions.rows.filterPredicate(row))
33
- : initialRows;
31
+ const filterPredicate = (_b = (_a = this.options.publicOptions) === null || _a === void 0 ? void 0 : _a.rows) === null || _b === void 0 ? void 0 : _b.filterPredicate;
32
+ if (filterPredicate)
33
+ initialRows = initialRows.filter((row) => filterPredicate(row));
34
34
  if ((_d = (_c = this.options.publicOptions) === null || _c === void 0 ? void 0 : _c.rows) === null || _d === void 0 ? void 0 : _d.sortCompareFn)
35
35
  initialRows.sort(this.options.publicOptions.rows.sortCompareFn);
36
36
  initialRows.forEach((initialRow) => {
@@ -1,9 +1,9 @@
1
- import { BlockMargin, Orient, ValueLabelAnchor, ValueLabelDominantBaseline } from "../../model";
1
+ import { BlockMargin, Orient, TextAnchor, DominantBaseline } from "../../model";
2
2
  import { BoundingRect } from "../../../engine/features/valueLabelsCollision/valueLabelsCollision";
3
3
  import { MdtChartsDataRow, Size, ValueLabelsPositionMode, ValueLabelsPositionOptions, ValueLabelsRotationOptions } from "../../../config/config";
4
4
  interface ValueLabelAlignment {
5
- dominantBaseline: ValueLabelDominantBaseline;
6
- textAnchor: ValueLabelAnchor;
5
+ dominantBaseline: DominantBaseline;
6
+ textAnchor: TextAnchor;
7
7
  }
8
8
  export declare const VALUE_LABEL_OFFSET_ABS_SIZE_PX = 10;
9
9
  export declare const BORDER_OFFSET_SIZE_PX = 2;
@@ -2,7 +2,7 @@ export declare class EventEmitter<E = Record<string, Record<string, any>>> {
2
2
  private events;
3
3
  subscribe<T extends keyof E>(code: T, listener: (args: E[T]) => void): () => void;
4
4
  unsubscribe<T extends keyof E>(code: T, listener: (args: E[T]) => void): void;
5
- emit<T extends keyof E>(code: T, args?: E[T]): void;
5
+ emit<T extends keyof E>(code: T, args: E[T]): void;
6
6
  getSubscribeController(): {
7
7
  subscribe: <T extends keyof E>(code: T, listener: (args: E[T]) => void) => () => void;
8
8
  unsubscribe: <T_1 extends keyof E>(code: T_1, listener: (args: E[T_1]) => void) => void;
@@ -7,6 +7,6 @@ export declare class TwoDimensionalModelHelper {
7
7
  private static getGradientItems;
8
8
  private static calculateOpacityItem;
9
9
  private static getGradientItemColor;
10
- static getValueLabels(valueLabels: MdtChartsTwoDimensionalValueLabels, canvasModel: CanvasModel, chartOrientation: ChartOrientation, styleModel: ValueLabelsStyleModel): TwoDimensionalValueLabels;
10
+ static getValueLabels(valueLabels: MdtChartsTwoDimensionalValueLabels | undefined, canvasModel: CanvasModel, chartOrientation: ChartOrientation, styleModel: ValueLabelsStyleModel): TwoDimensionalValueLabels;
11
11
  private static getChartBlockSidesOptions;
12
12
  }
@@ -1,22 +1,22 @@
1
1
  import { TwoDimMarginModel } from "./twoDim/twoDimMarginModel";
2
- import { TwoDimConfigReader } from "../modelInstance/configReader";
2
+ import { TwoDimConfigReader } from "../modelInstance/configReader/twoDimConfigReader.ts/twoDimConfigReader";
3
3
  export class MarginModel {
4
4
  constructor(designerConfig, config) {
5
5
  this.designerConfig = designerConfig;
6
6
  this.config = config;
7
- //TODO: ensure
8
- this.twoDimModel = new TwoDimMarginModel(this.designerConfig, new TwoDimConfigReader(this.config, this.designerConfig));
9
7
  }
10
8
  initMargin(otherComponents, modelInstance) {
11
9
  const canvasModel = modelInstance.canvasModel;
12
10
  canvasModel.initMargin(Object.assign({}, this.designerConfig.canvas.chartBlockMargin));
13
11
  this.recalcMarginByTitle(canvasModel);
14
12
  if (this.config.options.type === "2d") {
13
+ this.twoDimModel = new TwoDimMarginModel(this.designerConfig, new TwoDimConfigReader(this.config, this.designerConfig));
15
14
  this.twoDimModel.recalcMargin(otherComponents, modelInstance);
16
15
  }
17
16
  }
18
17
  recalcMarginByVerticalAxisLabel(modelInstance) {
19
- this.twoDimModel.recalcMarginByVerticalAxisLabel(modelInstance);
18
+ var _a;
19
+ (_a = this.twoDimModel) === null || _a === void 0 ? void 0 : _a.recalcMarginByVerticalAxisLabel(modelInstance);
20
20
  }
21
21
  recalcMarginByTitle(canvasModel) {
22
22
  canvasModel.increaseMarginSide("top", canvasModel.titleCanvas.getAllNeededSpace());
@@ -1,6 +1,6 @@
1
1
  import { DesignerConfig } from "../../../designer/designerConfig";
2
2
  import { OtherCommonComponents } from "../../model";
3
- import { TwoDimConfigReader } from "../../modelInstance/configReader";
3
+ import { TwoDimConfigReader } from "../../modelInstance/configReader/twoDimConfigReader.ts/twoDimConfigReader";
4
4
  import { ModelInstance } from "../../modelInstance/modelInstance";
5
5
  export declare const AXIS_HORIZONTAL_LABEL_PADDING = 12;
6
6
  export declare const AXIS_VERTICAL_LABEL_PADDING = 8;
@@ -35,6 +35,8 @@ export class TwoDimMarginModel {
35
35
  this.configReader.options.orientation === "vertical") {
36
36
  this.recalcVerticalMarginWithValueLabelsOn(canvasModel);
37
37
  }
38
+ const groupingSlices = this.configReader.grouping.getSlicesSizesByOrients(modelInstance.dataModel.repository.getRawRows());
39
+ groupingSlices.forEach((slice) => canvasModel.increaseMarginSide(slice.orient, slice.size));
38
40
  }
39
41
  recalcMarginByVerticalAxisLabel(modelInstance) {
40
42
  if (this.configReader.options.orientation === "vertical") {
@@ -55,13 +57,13 @@ export class TwoDimMarginModel {
55
57
  labelsTexts = modelInstance.dataModel.repository.getValuesByKeyField();
56
58
  }
57
59
  else {
58
- const scaleModel = new ScaleModel(this.configReader.options, modelInstance.canvasModel).getScaleLinear(modelInstance.dataModel.repository.getRawRows(), this.configReader);
60
+ const scaleModel = new ScaleModel(this.configReader.options, modelInstance.canvasModel, this.designerConfig.canvas.chartOptions.bar).getScaleLinear(modelInstance.dataModel.repository.getRawRows(), this.configReader);
59
61
  labelsTexts = this.getValueAxisLabels(scaleModel).map((v) => this.configReader.getAxisLabelFormatter()(v).toString());
60
62
  }
61
63
  return AxisModel.getLabelSize(this.designerConfig.canvas.axisLabel.maxSize.main, labelsTexts);
62
64
  }
63
65
  getMaxLabelSizeSecondary(modelInstance) {
64
- const scaleModel = new ScaleModel(this.configReader.options, modelInstance.canvasModel).getScaleSecondaryLinear(modelInstance.dataModel.repository.getRawRows(), this.configReader);
66
+ const scaleModel = new ScaleModel(this.configReader.options, modelInstance.canvasModel, this.designerConfig.canvas.chartOptions.bar).getScaleSecondaryLinear(modelInstance.dataModel.repository.getRawRows(), this.configReader);
65
67
  const labelsTexts = this.getValueAxisLabels(scaleModel).map((v) => this.configReader.getSecondaryAxisLabelFormatter()(v).toString());
66
68
  return AxisModel.getLabelSize(this.designerConfig.canvas.axisLabel.maxSize.main, labelsTexts);
67
69
  }
@@ -87,6 +89,7 @@ export class TwoDimMarginModel {
87
89
  }
88
90
  }
89
91
  recalcMarginBySecondaryAxisLabelSize(labelSize, canvasModel) {
92
+ var _a;
90
93
  const valueAxisOrient = AxisModel.getAxisOrient(AxisType.Value, this.configReader.options.orientation, this.configReader.options.axis.value.position);
91
94
  const secondaryOrientByMain = {
92
95
  bottom: "top",
@@ -99,7 +102,7 @@ export class TwoDimMarginModel {
99
102
  vertical: labelSize.width + AXIS_VERTICAL_LABEL_PADDING,
100
103
  horizontal: labelSize.height + AXIS_HORIZONTAL_LABEL_PADDING
101
104
  };
102
- if (this.configReader.options.axis.valueSecondary.visibility) {
105
+ if ((_a = this.configReader.options.axis.valueSecondary) === null || _a === void 0 ? void 0 : _a.visibility) {
103
106
  canvasModel.increaseMarginSide(secondaryOrient, sizeMap[this.configReader.options.orientation]);
104
107
  }
105
108
  }
@@ -3,7 +3,7 @@ import { DataType, DonutOptionsCanvas, Formatter, StaticLegendBlockCanvas, Toolt
3
3
  import { BoundingRect } from "../engine/features/valueLabelsCollision/valueLabelsCollision";
4
4
  declare type AxisType = "key" | "value";
5
5
  export declare type Orient = "top" | "bottom" | "left" | "right";
6
- export declare type ScaleKeyType = "band" | "point";
6
+ export declare type ScaleKeyType = (ScaleBandModel | ScalePointModel)["type"];
7
7
  export declare type ScaleValueType = "linear";
8
8
  export declare type LegendPosition = "off" | "top" | "bottom" | "left" | "right";
9
9
  export declare type EmbeddedLabelTypeModel = "none" | "key" | "value";
@@ -11,8 +11,8 @@ export declare type DataOptions = {
11
11
  [option: string]: any;
12
12
  };
13
13
  export declare type UnitsFromConfig = "%" | "px";
14
- export declare type ValueLabelAnchor = "start" | "middle" | "end";
15
- export declare type ValueLabelDominantBaseline = "hanging" | "middle" | "auto";
14
+ export declare type TextAnchor = "start" | "middle" | "end";
15
+ export declare type DominantBaseline = "hanging" | "middle" | "auto";
16
16
  export declare type GradientId = string;
17
17
  export declare type OptionsModel = TwoDimensionalOptionsModel | PolarOptionsModel;
18
18
  export interface Model<O = OptionsModel> {
@@ -80,6 +80,7 @@ export interface TwoDimensionalOptionsModel extends GraphicNotationOptionsModel
80
80
  orient: ChartOrientation;
81
81
  chartSettings: TwoDimChartElementsSettings;
82
82
  valueLabels: TwoDimensionalValueLabels;
83
+ grouping: TwoDimGroupingModel;
83
84
  }
84
85
  export interface PolarOptionsModel extends GraphicNotationOptionsModel {
85
86
  type: "polar";
@@ -126,12 +127,26 @@ export interface IScaleModel {
126
127
  value: ScaleValueModel;
127
128
  valueSecondary?: ScaleValueModel;
128
129
  }
129
- export interface ScaleKeyModel {
130
+ export interface BaseScaleKeyModel {
130
131
  domain: any[];
131
132
  range: RangeModel;
132
- type: ScaleKeyType;
133
+ }
134
+ export declare type ScaleKeyModel = ScaleBandModel | ScalePointModel;
135
+ export interface ScaleBandModel extends BaseScaleKeyModel {
136
+ type: "band";
137
+ sizes: ScaleBandModelSizeParams;
138
+ /** @deprecated Use sizes instead */
133
139
  elementsAmount: number;
134
140
  }
141
+ export interface ScaleBandModelSizeParams {
142
+ paddingOuter: number;
143
+ paddingInner: number;
144
+ bandSize: number;
145
+ recalculatedStepSize: number;
146
+ }
147
+ export interface ScalePointModel extends BaseScaleKeyModel {
148
+ type: "point";
149
+ }
135
150
  export interface ScaleValueModel {
136
151
  domain: any[];
137
152
  range: RangeModel;
@@ -158,6 +173,9 @@ export interface AxisModelOptions {
158
173
  line: AxisLineModel;
159
174
  browserTooltip: AxisBrowserTooltipModel;
160
175
  }
176
+ export interface DiscreteAxisModelOptions extends AxisModelOptions {
177
+ labels: DiscreteAxisLabelModel;
178
+ }
161
179
  export interface AxisBrowserTooltipModel {
162
180
  format: (value: number | string) => string | number;
163
181
  }
@@ -180,6 +198,12 @@ export interface AxisLabelModel {
180
198
  linearTickStep: number;
181
199
  tickAmountSettings: TickAmountModel;
182
200
  }
201
+ export interface DiscreteAxisLabelModel extends AxisLabelModel {
202
+ format: DiscreteAxisLabelFormatterModel;
203
+ }
204
+ export declare type DiscreteAxisLabelFormatterModel = (options: {
205
+ key: string;
206
+ }) => string;
183
207
  interface TickAmountModel {
184
208
  policy: TickAmountPolicy;
185
209
  }
@@ -285,6 +309,25 @@ export declare type ValueLabelsChartBlockSide = {
285
309
  } | {
286
310
  mode: "none";
287
311
  };
312
+ export interface TwoDimGroupingModel {
313
+ enabled: boolean;
314
+ items: TwoDimGroupingItemModel[];
315
+ }
316
+ export interface GroupingLabelCoordinate {
317
+ x: number;
318
+ y: number;
319
+ }
320
+ export declare type GroupingLabelKey = string | number;
321
+ export interface TwoDimGroupingItemModel {
322
+ domain: GroupingLabelKey[];
323
+ orient: Orient;
324
+ textAnchor: TextAnchor;
325
+ dominantBaseline: DominantBaseline;
326
+ coordinate: {
327
+ handleX: (key: GroupingLabelKey) => number;
328
+ handleY: (key: GroupingLabelKey) => number;
329
+ };
330
+ }
288
331
  export interface DonutChartSettings extends Omit<DonutOptionsCanvas, "aggregatorPad" | "thickness"> {
289
332
  aggregator: DonutAggregatorModel;
290
333
  thickness: DonutThicknessOptions;
@@ -377,7 +420,7 @@ interface DotChartShapeOptions {
377
420
  handleEndCoordinate: (calculatedBandItemSize: number) => number;
378
421
  width: number;
379
422
  }
380
- export interface TwoDimensionalChartModel extends ChartModel, TwoDimensionalLineLikeChartModel, TwoDimensionalBarLikeChartModel, TwoDimensionalAreaChartModel, DotChartModel, DotChartModel {
423
+ export interface TwoDimensionalChartModel extends ChartModel, TwoDimensionalLineLikeChartModel, TwoDimensionalBarLikeChartModel, TwoDimensionalAreaChartModel, DotChartModel {
381
424
  type: TwoDimensionalChartType;
382
425
  data: TwoDimensionalChartDataModel;
383
426
  index: number;
@@ -410,9 +453,9 @@ export interface TwoDimChartValueLabelsOptions {
410
453
  showLabel: MarkerLikeElementVisibilityFn;
411
454
  handleX: (scaledValue: number) => number;
412
455
  handleY: (scaledValue: number) => number;
413
- textAnchor: ValueLabelAnchor;
456
+ textAnchor: TextAnchor;
414
457
  forFields: MdtChartsFieldName[];
415
- dominantBaseline: ValueLabelDominantBaseline;
458
+ dominantBaseline: DominantBaseline;
416
459
  setContent: ValueLabelsInnerContentSetter;
417
460
  handleScaledValue: (dataRow: MdtChartsDataRow, datumField: string) => number;
418
461
  rotation?: ValueLabelsRotationOptions;
@@ -5,7 +5,7 @@ import { DataManagerModel } from "./dataManagerModel/dataManagerModel";
5
5
  import { OtherComponentsModel } from "./featuresModel/otherComponents";
6
6
  import { ConfigValidator } from "./configsValidator/configValidator";
7
7
  import { ModelInstance } from "./modelInstance/modelInstance";
8
- import { TwoDimConfigReader } from "./modelInstance/configReader";
8
+ import { TwoDimConfigReader } from "./modelInstance/configReader/twoDimConfigReader.ts/twoDimConfigReader";
9
9
  import { TitleConfigReader } from "./modelInstance/titleConfigReader";
10
10
  export var AxisType;
11
11
  (function (AxisType) {
@@ -52,6 +52,7 @@ function getOptions(config, designerConfig, modelInstance) {
52
52
  else if (config.options.type === "polar") {
53
53
  return PolarModel.getOptions(config.options, designerConfig, modelInstance);
54
54
  }
55
+ throw new Error("Unknown chart type");
55
56
  }
56
57
  function getDataSettings(dataScope, designerConfig) {
57
58
  return {
@@ -1,7 +1,12 @@
1
1
  import { ILegendModel, LegendPosition } from "../../model";
2
2
  export declare class LegendCanvasModelInstance {
3
3
  private position;
4
+ private size;
5
+ private pad;
6
+ private sizeAndPadInited;
4
7
  getModel(): ILegendModel;
8
+ initSizeAndPad(size: number, pad: number): void;
5
9
  getPosition(): LegendPosition;
6
10
  setPosition(position: LegendPosition): void;
11
+ getAllNeededSpace(): number;
7
12
  }
@@ -1,13 +1,26 @@
1
1
  export class LegendCanvasModelInstance {
2
+ constructor() {
3
+ this.sizeAndPadInited = false;
4
+ }
2
5
  getModel() {
3
6
  return {
4
7
  position: this.position
5
8
  };
6
9
  }
10
+ initSizeAndPad(size, pad) {
11
+ this.size = size;
12
+ this.pad = pad;
13
+ this.sizeAndPadInited = true;
14
+ }
7
15
  getPosition() {
8
16
  return this.position;
9
17
  }
10
18
  setPosition(position) {
11
19
  this.position = position;
12
20
  }
21
+ getAllNeededSpace() {
22
+ if (!this.sizeAndPadInited)
23
+ throw new Error("LegendCanvasModel padding and size are not initialized");
24
+ return this.size + this.pad;
25
+ }
13
26
  }
@@ -1,9 +1,9 @@
1
1
  import { TitleBlockModel } from "../../model";
2
- declare type TitleBlockCanvas = TitleBlockModel;
2
+ import { TitleConfigReader } from "../titleConfigReader";
3
3
  export declare class TitleCanvasModel {
4
+ private inited;
4
5
  private model;
5
- init(model: TitleBlockCanvas): void;
6
+ init(titleConfig: TitleConfigReader): void;
6
7
  getModel(): TitleBlockModel;
7
8
  getAllNeededSpace(): number;
8
9
  }
9
- export {};
@@ -1,11 +1,30 @@
1
1
  export class TitleCanvasModel {
2
- init(model) {
3
- this.model = model;
2
+ constructor() {
3
+ this.inited = false;
4
+ }
5
+ init(titleConfig) {
6
+ const defaultPads = titleConfig.getFontSize();
7
+ const pad = titleConfig.getTextContent() ? defaultPads : 0;
8
+ this.model = {
9
+ margin: {
10
+ bottom: 5,
11
+ left: 0,
12
+ right: 0,
13
+ top: 0
14
+ },
15
+ size: pad,
16
+ pad: 0
17
+ };
18
+ this.inited = true;
4
19
  }
5
20
  getModel() {
21
+ if (!this.inited)
22
+ throw new Error("TitleCanvasModel is not initialized");
6
23
  return this.model;
7
24
  }
8
25
  getAllNeededSpace() {
26
+ if (!this.inited)
27
+ throw new Error("TitleCanvasModel is not initialized");
9
28
  return this.model.pad + this.model.size + this.model.margin.top + this.model.margin.bottom;
10
29
  }
11
30
  }
@@ -0,0 +1,6 @@
1
+ import { MdtChartsConfig, MdtChartsField } from "../../../config/config";
2
+ import { DesignerConfig } from "../../../designer/designerConfig";
3
+ export interface BaseConfigReader {
4
+ getValueFields(): MdtChartsField[];
5
+ }
6
+ export declare function getConfigReader(config: MdtChartsConfig, designerConfig: DesignerConfig): BaseConfigReader;
@@ -0,0 +1,9 @@
1
+ import { PolarConfigReader } from "./polarConfigReader/polarConfigReader";
2
+ import { TwoDimConfigReader } from "./twoDimConfigReader.ts/twoDimConfigReader";
3
+ export function getConfigReader(config, designerConfig) {
4
+ if (config.options.type === "2d")
5
+ return new TwoDimConfigReader(config, designerConfig);
6
+ if (config.options.type === "polar")
7
+ return new PolarConfigReader(config);
8
+ throw new Error(`Config reader for type "${config.options.type}" not exists`);
9
+ }
@@ -0,0 +1,7 @@
1
+ import { MdtChartsConfig, MdtChartsField } from "../../../../config/config";
2
+ import { BaseConfigReader } from "../baseConfigReader";
3
+ export declare class PolarConfigReader implements BaseConfigReader {
4
+ private options;
5
+ constructor(config: MdtChartsConfig);
6
+ getValueFields(): MdtChartsField[];
7
+ }
@@ -0,0 +1,8 @@
1
+ export class PolarConfigReader {
2
+ constructor(config) {
3
+ this.options = config.options;
4
+ }
5
+ getValueFields() {
6
+ return [this.options.chart.data.valueField];
7
+ }
8
+ }
@@ -0,0 +1,29 @@
1
+ import { ChartOrientation, DiscreteAxisOptions, MdtChartsDataRow, MdtChartsField, TwoDimGroupingOptions } from "../../../../../config/config";
2
+ import { DominantBaseline, Orient, TextAnchor } from "../../../../model";
3
+ export declare class GroupingConfigReader {
4
+ private readonly keyAxisOptions;
5
+ private readonly chartOrientation;
6
+ private readonly groupingOptions?;
7
+ private readonly maxLabelSize;
8
+ constructor(keyAxisOptions: DiscreteAxisOptions, chartOrientation: ChartOrientation, groupingOptions?: TwoDimGroupingOptions);
9
+ isEnabled(): boolean;
10
+ getSlicesByOrients(): {
11
+ orient: Orient;
12
+ amount: number;
13
+ }[];
14
+ getSlicesSizesByOrients(dataRows: MdtChartsDataRow[]): {
15
+ orient: Orient;
16
+ size: number;
17
+ }[];
18
+ getPreparedOptions(scopedDatasourceRows: MdtChartsDataRow[]): {
19
+ domain: string[];
20
+ orient: Orient;
21
+ sideIndex: number;
22
+ field: MdtChartsField;
23
+ textAnchor: TextAnchor;
24
+ dominantBaseline: DominantBaseline;
25
+ }[];
26
+ private getLabelValuesForItem;
27
+ private getLabelOrient;
28
+ private getLabelPosition;
29
+ }