mdt-charts 1.10.3 → 1.11.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 (51) hide show
  1. package/lib/config/config.d.ts +9 -2
  2. package/lib/designer/designerConfig.d.ts +8 -2
  3. package/lib/engine/features/aggregator/aggregator.d.ts +4 -3
  4. package/lib/engine/features/aggregator/aggregator.js +14 -11
  5. package/lib/engine/features/title/title.js +2 -0
  6. package/lib/engine/features/tolltip/tooltip.js +1 -1
  7. package/lib/engine/filterManager/filterEventManager.d.ts +3 -3
  8. package/lib/engine/filterManager/filterEventManager.js +4 -4
  9. package/lib/engine/intervalNotation/intervalManager.js +2 -2
  10. package/lib/engine/polarNotation/donut/DonutHelper.d.ts +2 -0
  11. package/lib/engine/polarNotation/donut/DonutHelper.js +20 -3
  12. package/lib/engine/polarNotation/donut/donut.js +1 -1
  13. package/lib/engine/polarNotation/polarManager.js +6 -7
  14. package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +4 -4
  15. package/lib/model/chartStyleModel/TwoDimensionalChartStyleModel.d.ts +19 -0
  16. package/lib/model/chartStyleModel/TwoDimensionalChartStyleModel.js +61 -0
  17. package/lib/model/chartStyleModel/chartStyleModel.d.ts +9 -0
  18. package/lib/model/chartStyleModel/chartStyleModel.js +27 -0
  19. package/lib/model/dataManagerModel.d.ts +3 -2
  20. package/lib/model/dataManagerModel.js +12 -10
  21. package/lib/model/featuresModel/axisModel.d.ts +9 -8
  22. package/lib/model/featuresModel/axisModel.js +20 -20
  23. package/lib/model/featuresModel/legendModel/legendModel.d.ts +4 -3
  24. package/lib/model/featuresModel/legendModel/legendModel.js +5 -7
  25. package/lib/model/featuresModel/otherComponents.d.ts +9 -2
  26. package/lib/model/featuresModel/otherComponents.js +6 -4
  27. package/lib/model/featuresModel/scaleModel.d.ts +6 -5
  28. package/lib/model/featuresModel/scaleModel.js +9 -9
  29. package/lib/model/featuresModel/titleModel.d.ts +1 -1
  30. package/lib/model/featuresModel/titleModel.js +7 -5
  31. package/lib/model/marginModel.d.ts +5 -5
  32. package/lib/model/marginModel.js +37 -35
  33. package/lib/model/model.d.ts +24 -18
  34. package/lib/model/modelBuilder.js +23 -34
  35. package/lib/model/modelInstance/canvasModel/canvasModel.d.ts +22 -0
  36. package/lib/model/modelInstance/canvasModel/canvasModel.js +42 -0
  37. package/lib/model/modelInstance/canvasModel/titleCanvas.d.ts +9 -0
  38. package/lib/model/modelInstance/canvasModel/titleCanvas.js +11 -0
  39. package/lib/model/modelInstance/modelInstance.d.ts +7 -0
  40. package/lib/model/modelInstance/modelInstance.js +11 -0
  41. package/lib/model/notations/intervalModel.d.ts +2 -1
  42. package/lib/model/notations/intervalModel.js +16 -13
  43. package/lib/model/notations/polarModel.d.ts +5 -3
  44. package/lib/model/notations/polarModel.js +17 -7
  45. package/lib/model/notations/twoDimensionalModel.d.ts +7 -5
  46. package/lib/model/notations/twoDimensionalModel.js +19 -11
  47. package/lib/style/charts-main.css +1 -0
  48. package/lib/style/charts-main.less +1 -0
  49. package/package.json +3 -2
  50. package/lib/model/chartStyleModel.d.ts +0 -16
  51. package/lib/model/chartStyleModel.js +0 -67
@@ -3,32 +3,32 @@ import { AxisType, CLASSES } from "../modelBuilder";
3
3
  import { DataManagerModel } from "../dataManagerModel";
4
4
  import { TwoDimensionalModel } from "../notations/twoDimensionalModel";
5
5
  export class AxisModel {
6
- static getKeyAxis(charts, data, dataOptions, orient, axisConfig, labelConfig, margin, blockSize, tooltipSettings) {
6
+ static getKeyAxis(charts, data, dataOptions, orient, axisConfig, labelConfig, canvasModel, tooltipSettings) {
7
7
  return {
8
8
  type: 'key',
9
9
  orient: AxisModel.getAxisOrient(AxisType.Key, orient, axisConfig.position),
10
10
  translate: {
11
- translateX: AxisModel.getAxisTranslateX(AxisType.Key, orient, axisConfig.position, margin, blockSize.width),
12
- translateY: AxisModel.getAxisTranslateY(AxisType.Key, orient, axisConfig.position, margin, blockSize.height)
11
+ translateX: AxisModel.getAxisTranslateX(AxisType.Key, orient, axisConfig.position, canvasModel),
12
+ translateY: AxisModel.getAxisTranslateY(AxisType.Key, orient, axisConfig.position, canvasModel)
13
13
  },
14
14
  cssClass: 'key-axis',
15
15
  ticks: axisConfig.ticks,
16
16
  labels: {
17
17
  maxSize: AxisModel.getLabelSize(labelConfig.maxSize.main, data[dataOptions.dataSource].map(d => d[dataOptions.keyField.name])).width,
18
- position: AxisModel.getKeyAxisLabelPosition(margin, blockSize, DataManagerModel.getDataValuesByKeyField(data, dataOptions.dataSource, dataOptions.keyField.name).length),
18
+ position: AxisModel.getKeyAxisLabelPosition(canvasModel, DataManagerModel.getDataValuesByKeyField(data, dataOptions.dataSource, dataOptions.keyField.name).length),
19
19
  visible: !TwoDimensionalModel.getChartsEmbeddedLabelsFlag(charts, orient),
20
20
  defaultTooltip: tooltipSettings.position === 'fixed'
21
21
  },
22
22
  visibility: axisConfig.visibility
23
23
  };
24
24
  }
25
- static getValueAxis(orient, axisConfig, labelConfig, margin, blockSize) {
25
+ static getValueAxis(orient, axisConfig, labelConfig, canvasModel) {
26
26
  return {
27
27
  type: 'value',
28
28
  orient: AxisModel.getAxisOrient(AxisType.Value, orient, axisConfig.position),
29
29
  translate: {
30
- translateX: AxisModel.getAxisTranslateX(AxisType.Value, orient, axisConfig.position, margin, blockSize.width),
31
- translateY: AxisModel.getAxisTranslateY(AxisType.Value, orient, axisConfig.position, margin, blockSize.height)
30
+ translateX: AxisModel.getAxisTranslateX(AxisType.Value, orient, axisConfig.position, canvasModel),
31
+ translateY: AxisModel.getAxisTranslateY(AxisType.Value, orient, axisConfig.position, canvasModel)
32
32
  },
33
33
  cssClass: 'value-axis',
34
34
  ticks: axisConfig.ticks,
@@ -41,12 +41,12 @@ export class AxisModel {
41
41
  visibility: axisConfig.visibility
42
42
  };
43
43
  }
44
- static getAxisLength(chartOrientation, margin, blockSize) {
44
+ static getAxisLength(chartOrientation, canvasModel) {
45
45
  if (chartOrientation === 'horizontal') {
46
- return blockSize.height - margin.top - margin.bottom;
46
+ return canvasModel.getChartBlockHeight();
47
47
  }
48
48
  else {
49
- return blockSize.width - margin.left - margin.right;
49
+ return canvasModel.getChartBlockWidth();
50
50
  }
51
51
  }
52
52
  static getAxisOrient(axisType, chartOrientation, axisPosition) {
@@ -59,25 +59,25 @@ export class AxisModel {
59
59
  return axisType === AxisType.Key ? 'left' : 'top';
60
60
  return axisType === AxisType.Key ? 'right' : 'bottom';
61
61
  }
62
- static getAxisTranslateX(axisType, chartOrientation, axisPosition, margin, blockWidth) {
62
+ static getAxisTranslateX(axisType, chartOrientation, axisPosition, canvasModel) {
63
63
  const orient = AxisModel.getAxisOrient(axisType, chartOrientation, axisPosition);
64
64
  if (orient === 'top' || orient === 'left')
65
- return margin.left;
65
+ return canvasModel.getMarginSide("left");
66
66
  else if (orient === 'bottom')
67
- return margin.left;
68
- return blockWidth - margin.right;
67
+ return canvasModel.getMarginSide("left");
68
+ return canvasModel.getBlockSize().width - canvasModel.getMarginSide("right");
69
69
  }
70
- static getAxisTranslateY(axisType, chartOrientation, axisPosition, margin, blockHeight) {
70
+ static getAxisTranslateY(axisType, chartOrientation, axisPosition, canvasModel) {
71
71
  const orient = AxisModel.getAxisOrient(axisType, chartOrientation, axisPosition);
72
72
  if (orient === 'top' || orient === 'left')
73
- return margin.top;
73
+ return canvasModel.getMarginSide("top");
74
74
  else if (orient === 'bottom')
75
- return blockHeight - margin.bottom;
76
- return margin.top;
75
+ return canvasModel.getBlockSize().height - canvasModel.getMarginSide("bottom");
76
+ return canvasModel.getMarginSide("top");
77
77
  }
78
- static getKeyAxisLabelPosition(margin, blockSize, scopedDataLength) {
78
+ static getKeyAxisLabelPosition(canvasModel, scopedDataLength) {
79
79
  const minBandSize = 50;
80
- if ((blockSize.width - margin.left - margin.right) / scopedDataLength < minBandSize)
80
+ if (canvasModel.getChartBlockWidth() / scopedDataLength < minBandSize)
81
81
  return 'rotated';
82
82
  return 'straight';
83
83
  }
@@ -1,12 +1,13 @@
1
1
  import { ChartNotation, Size } from "../../../config/config";
2
- import { BlockMargin, ILegendModel, LegendBlockModel, LegendPosition, Orient } from "../../model";
2
+ import { ILegendModel, LegendBlockModel, LegendPosition, Orient } from "../../model";
3
+ import { CanvasModel } from "../../modelInstance/canvasModel/canvasModel";
3
4
  import { LegendItemsDirection } from "./legendCanvasModel";
4
5
  /** If donut block has width less than this const, legend change postion from "right" to "bottom" */
5
6
  export declare const MIN_DONUT_BLOCK_SIZE = 260;
6
7
  export declare class LegendModel {
7
8
  static getLegendSize(chartNotation: ChartNotation, position: Orient, texts: string[], legendMaxWidth: number, blockSize: Size, legendBlockModel: LegendBlockModel): number;
8
- static getBaseLegendBlockModel(notation: ChartNotation): LegendBlockModel;
9
- static getLegendModel(chartNotation: ChartNotation, legendShow: boolean, blockSize: Size, margin: BlockMargin): ILegendModel;
9
+ static getBaseLegendBlockModel(notation: ChartNotation, canvasModel: CanvasModel): LegendBlockModel;
10
+ static getLegendModel(chartNotation: ChartNotation, legendShow: boolean, canvasModel: CanvasModel): ILegendModel;
10
11
  static getLegendItemClass(itemsPosition: LegendItemsDirection): string;
11
12
  static getMarginClass(legendPosition: LegendPosition): string;
12
13
  private static getLegendWidth;
@@ -1,5 +1,4 @@
1
1
  import { ModelHelper } from "../../modelHelper";
2
- import { TitleModel } from "../titleModel";
3
2
  import { LegendCanvasModel } from "./legendCanvasModel";
4
3
  /** If donut block has width less than this const, legend change postion from "right" to "bottom" */
5
4
  export const MIN_DONUT_BLOCK_SIZE = 260;
@@ -15,9 +14,8 @@ export class LegendModel {
15
14
  return size;
16
15
  }
17
16
  }
18
- static getBaseLegendBlockModel(notation) {
17
+ static getBaseLegendBlockModel(notation, canvasModel) {
19
18
  const mt = 20, mb = 20, ml = 20, mr = 20;
20
- const titleModelTemplate = TitleModel.getTitleModel();
21
19
  return {
22
20
  coordinate: {
23
21
  left: {
@@ -32,25 +30,25 @@ export class LegendModel {
32
30
  },
33
31
  right: {
34
32
  size: 0,
35
- margin: { top: titleModelTemplate.pad + titleModelTemplate.margin.top + titleModelTemplate.size, bottom: mb, left: 0, right: mr },
33
+ margin: { top: canvasModel.titleCanvas.getAllNeededSpace(), bottom: mb, left: 0, right: mr },
36
34
  pad: 0
37
35
  },
38
36
  top: {
39
37
  size: 0,
40
38
  margin: { top: 20, bottom: 0, left: 20, right: 20 },
41
- pad: titleModelTemplate.pad + titleModelTemplate.margin.top + titleModelTemplate.size
39
+ pad: canvasModel.titleCanvas.getAllNeededSpace()
42
40
  }
43
41
  },
44
42
  standartTooltip: notation === 'polar' ? false : true
45
43
  };
46
44
  }
47
- static getLegendModel(chartNotation, legendShow, blockSize, margin) {
45
+ static getLegendModel(chartNotation, legendShow, canvasModel) {
48
46
  let legendPosition = 'off';
49
47
  if (legendShow) {
50
48
  if (chartNotation === '2d' || chartNotation === 'interval')
51
49
  legendPosition = 'top';
52
50
  else if (chartNotation === 'polar') {
53
- legendPosition = blockSize.width - margin.left - margin.right < MIN_DONUT_BLOCK_SIZE ? 'bottom' : 'right';
51
+ legendPosition = canvasModel.getChartBlockWidth() < MIN_DONUT_BLOCK_SIZE ? 'bottom' : 'right';
54
52
  }
55
53
  }
56
54
  return {
@@ -1,6 +1,13 @@
1
- import { OtherComponents } from "../model";
1
+ import { OtherCommonComponents } from "../model";
2
2
  import { ElementsOptions } from "../../designer/designerConfig";
3
3
  import { ChartNotation } from "../../config/config";
4
+ import { ModelInstance } from "../modelInstance/modelInstance";
5
+ interface OtherComponentsModelDependencies {
6
+ elementsOptions: ElementsOptions;
7
+ title: string;
8
+ notation: ChartNotation;
9
+ }
4
10
  export declare class OtherComponentsModel {
5
- static getOtherComponentsModel(elementsOptions: ElementsOptions, notation: ChartNotation): OtherComponents;
11
+ static getOtherComponentsModel(dependencies: OtherComponentsModelDependencies, modelInstance: ModelInstance): OtherCommonComponents;
6
12
  }
13
+ export {};
@@ -2,11 +2,13 @@ import { LegendModel } from "./legendModel/legendModel";
2
2
  import { TitleModel } from "./titleModel";
3
3
  import { TooltipModel } from "./tooltipModel";
4
4
  export class OtherComponentsModel {
5
- static getOtherComponentsModel(elementsOptions, notation) {
5
+ static getOtherComponentsModel(dependencies, modelInstance) {
6
+ const canvasModel = modelInstance.canvasModel;
7
+ canvasModel.titleCanvas.init(TitleModel.getTitleModel(dependencies.title));
6
8
  return {
7
- legendBlock: LegendModel.getBaseLegendBlockModel(notation),
8
- titleBlock: TitleModel.getTitleModel(),
9
- tooltipBlock: TooltipModel.getTooltipModel(elementsOptions.tooltip)
9
+ legendBlock: LegendModel.getBaseLegendBlockModel(dependencies.notation, canvasModel),
10
+ titleBlock: canvasModel.titleCanvas.getModel(),
11
+ tooltipBlock: TooltipModel.getTooltipModel(dependencies.elementsOptions.tooltip)
10
12
  };
11
13
  }
12
14
  }
@@ -1,13 +1,14 @@
1
- import { BlockMargin, ScaleKeyModel, ScaleKeyType, ScaleValueModel, ScaleValueType } from "../model";
2
- import { AxisPosition, NumberDomain, IntervalChart, TwoDimensionalChart, TwoDimensionalOptions, Size, ChartOrientation, MdtChartsDataSource } from "../../config/config";
1
+ import { ScaleKeyModel, ScaleKeyType, ScaleValueModel, ScaleValueType } from "../model";
2
+ import { AxisPosition, NumberDomain, IntervalChart, TwoDimensionalChart, TwoDimensionalOptions, ChartOrientation, MdtChartsDataSource } from "../../config/config";
3
+ import { CanvasModel } from "../modelInstance/canvasModel/canvasModel";
3
4
  export declare enum ScaleType {
4
5
  Key = 0,
5
6
  Value = 1
6
7
  }
7
8
  export declare class ScaleModel {
8
- static getScaleKey(allowableKeys: string[], orient: ChartOrientation, margin: BlockMargin, blockSize: Size, charts: TwoDimensionalChart[], barCharts: TwoDimensionalChart[]): ScaleKeyModel;
9
- static getScaleLinear(options: TwoDimensionalOptions, data: MdtChartsDataSource, margin: BlockMargin, blockSize: Size): ScaleValueModel;
10
- static getRangePeek(scaleType: ScaleType, chartOrientation: string, margin: BlockMargin, blockSize: Size): number;
9
+ static getScaleKey(allowableKeys: string[], orient: ChartOrientation, canvasModel: CanvasModel, charts: TwoDimensionalChart[], barCharts: TwoDimensionalChart[]): ScaleKeyModel;
10
+ static getScaleLinear(options: TwoDimensionalOptions, data: MdtChartsDataSource, canvasModel: CanvasModel): ScaleValueModel;
11
+ static getRangePeek(scaleType: ScaleType, chartOrientation: string, canvasModel: CanvasModel): number;
11
12
  static getDateValueDomain(data: MdtChartsDataSource, chart: IntervalChart, keyAxisPosition: AxisPosition, dataSource: string): [Date, Date];
12
13
  static getLinearDomain(configDomain: NumberDomain, data: MdtChartsDataSource, configOptions: TwoDimensionalOptions): [number, number];
13
14
  static getScaleKeyType(charts: TwoDimensionalChart[]): ScaleKeyType;
@@ -5,35 +5,35 @@ export var ScaleType;
5
5
  ScaleType[ScaleType["Value"] = 1] = "Value";
6
6
  })(ScaleType || (ScaleType = {}));
7
7
  export class ScaleModel {
8
- static getScaleKey(allowableKeys, orient, margin, blockSize, charts, barCharts) {
8
+ static getScaleKey(allowableKeys, orient, canvasModel, charts, barCharts) {
9
9
  return {
10
10
  domain: allowableKeys,
11
11
  range: {
12
12
  start: 0,
13
- end: ScaleModel.getRangePeek(ScaleType.Key, orient, margin, blockSize)
13
+ end: ScaleModel.getRangePeek(ScaleType.Key, orient, canvasModel)
14
14
  },
15
15
  type: ScaleModel.getScaleKeyType(charts),
16
16
  elementsAmount: this.getElementsAmount(barCharts)
17
17
  };
18
18
  }
19
- static getScaleLinear(options, data, margin, blockSize) {
19
+ static getScaleLinear(options, data, canvasModel) {
20
20
  return {
21
21
  domain: ScaleModel.getLinearDomain(options.axis.value.domain, data, options),
22
22
  range: {
23
23
  start: 0,
24
- end: ScaleModel.getRangePeek(ScaleType.Value, options.orientation, margin, blockSize)
24
+ end: ScaleModel.getRangePeek(ScaleType.Value, options.orientation, canvasModel)
25
25
  },
26
26
  type: ScaleModel.getScaleValueType(options.charts)
27
27
  };
28
28
  }
29
- static getRangePeek(scaleType, chartOrientation, margin, blockSize) {
29
+ static getRangePeek(scaleType, chartOrientation, canvasModel) {
30
30
  if (chartOrientation === 'vertical')
31
31
  return scaleType === ScaleType.Key
32
- ? blockSize.width - margin.left - margin.right
33
- : blockSize.height - margin.top - margin.bottom;
32
+ ? canvasModel.getChartBlockWidth()
33
+ : canvasModel.getChartBlockHeight();
34
34
  return scaleType === ScaleType.Key
35
- ? blockSize.height - margin.top - margin.bottom
36
- : blockSize.width - margin.left - margin.right;
35
+ ? canvasModel.getChartBlockHeight()
36
+ : canvasModel.getChartBlockWidth();
37
37
  }
38
38
  static getDateValueDomain(data, chart, keyAxisPosition, dataSource) {
39
39
  const minMax = ModelHelper.getMinAndMaxOfIntervalData(data, dataSource, chart);
@@ -1,4 +1,4 @@
1
1
  import { TitleBlockModel } from "../model";
2
2
  export declare class TitleModel {
3
- static getTitleModel(): TitleBlockModel;
3
+ static getTitleModel(titleText: string): TitleBlockModel;
4
4
  }
@@ -1,13 +1,15 @@
1
1
  export class TitleModel {
2
- static getTitleModel() {
2
+ static getTitleModel(titleText) {
3
+ const defaultPads = 20;
4
+ const pad = titleText ? defaultPads : 0;
3
5
  return {
4
6
  margin: {
5
7
  bottom: 0,
6
- left: 20,
7
- right: 20,
8
- top: 20
8
+ left: pad,
9
+ right: pad,
10
+ top: pad
9
11
  },
10
- size: 20,
12
+ size: pad,
11
13
  pad: 0
12
14
  };
13
15
  }
@@ -1,13 +1,13 @@
1
1
  import { MdtChartsConfig, MdtChartsDataSource } from "../config/config";
2
2
  import { DesignerConfig } from "../designer/designerConfig";
3
- import { BlockMargin, DataScope, LegendBlockModel, OtherComponents, PolarOptionsModel } from "./model";
4
- import { Size } from "../config/config";
3
+ import { DataScope, LegendBlockModel, OtherCommonComponents, PolarOptionsModel } from "./model";
4
+ import { ModelInstance } from "./modelInstance/modelInstance";
5
5
  export declare const AXIS_HORIZONTAL_LABEL_PADDING = 15;
6
6
  export declare const AXIS_VERTICAL_LABEL_PADDING = 10;
7
7
  export declare class MarginModel {
8
- static getMargin(designerConfig: DesignerConfig, config: MdtChartsConfig, otherComponents: OtherComponents, data: MdtChartsDataSource): BlockMargin;
9
- static recalcPolarMarginWithScopedData(margin: BlockMargin, blockSize: Size, designerConfig: DesignerConfig, config: MdtChartsConfig, legendBlockModel: LegendBlockModel, dataScope: DataScope, options: PolarOptionsModel): void;
10
- static recalcMarginByVerticalAxisLabel(margin: BlockMargin, config: MdtChartsConfig, designerConfig: DesignerConfig, dataScope: DataScope): void;
8
+ static initMargin(designerConfig: DesignerConfig, config: MdtChartsConfig, otherComponents: OtherCommonComponents, data: MdtChartsDataSource, modelInstance: ModelInstance): void;
9
+ static recalcPolarMarginWithScopedData(modelInstance: ModelInstance, designerConfig: DesignerConfig, config: MdtChartsConfig, legendBlockModel: LegendBlockModel, dataScope: DataScope, options: PolarOptionsModel): void;
10
+ static recalcMarginByVerticalAxisLabel(modelInstance: ModelInstance, config: MdtChartsConfig, designerConfig: DesignerConfig, dataScope: DataScope): void;
11
11
  private static getHorizontalMarginByAxisLabels;
12
12
  private static recalcVerticalMarginByAxisLabelHeight;
13
13
  private static recalcHorizontalMarginByAxisLabelWidth;
@@ -6,45 +6,46 @@ import { TwoDimensionalModel } from "./notations/twoDimensionalModel";
6
6
  export const AXIS_HORIZONTAL_LABEL_PADDING = 15;
7
7
  export const AXIS_VERTICAL_LABEL_PADDING = 10;
8
8
  export class MarginModel {
9
- static getMargin(designerConfig, config, otherComponents, data) {
10
- const margin = Object.assign({}, designerConfig.canvas.chartBlockMargin);
11
- this.recalcMarginWithLegend(margin, config, designerConfig.canvas.legendBlock.maxWidth, otherComponents.legendBlock, data);
12
- this.recalcMarginByTitle(margin, otherComponents.titleBlock);
9
+ static initMargin(designerConfig, config, otherComponents, data, modelInstance) {
10
+ const canvasModel = modelInstance.canvasModel;
11
+ canvasModel.initMargin(Object.assign({}, designerConfig.canvas.chartBlockMargin));
12
+ this.recalcMarginWithLegend(modelInstance, config, designerConfig.canvas.legendBlock.maxWidth, otherComponents.legendBlock, data);
13
+ this.recalcMarginByTitle(canvasModel, otherComponents.titleBlock);
13
14
  if (config.options.type === '2d' || config.options.type === 'interval') {
14
15
  const labelSize = this.getHorizontalMarginByAxisLabels(designerConfig.canvas.axisLabel.maxSize.main, config.options.axis, data, config.options);
15
- this.recalcVerticalMarginByAxisLabelHeight(labelSize, margin, config.options.orientation, config.options.axis);
16
+ this.recalcVerticalMarginByAxisLabelHeight(labelSize, canvasModel, config.options.orientation, config.options.axis);
16
17
  // Если встроенный лейбл показывает ключи, то лейблы оси ключей не показываются
17
18
  // При этом все графики должны иметь: embeddedLabels = 'key'
18
19
  // И все графики должны быть типа bar.
19
20
  const showingFlag = config.options.type === '2d'
20
21
  ? !TwoDimensionalModel.getChartsEmbeddedLabelsFlag(config.options.charts, config.options.orientation)
21
22
  : true;
22
- this.recalcHorizontalMarginByAxisLabelWidth(labelSize, margin, config.options.orientation, config.options.axis, showingFlag);
23
+ this.recalcHorizontalMarginByAxisLabelWidth(labelSize, canvasModel, config.options.orientation, config.options.axis, showingFlag);
23
24
  }
24
- return margin;
25
25
  }
26
- static recalcPolarMarginWithScopedData(margin, blockSize, designerConfig, config, legendBlockModel, dataScope, options) {
27
- let position = LegendModel.getLegendModel(config.options.type, config.options.legend.show, config.canvas.size, margin).position;
26
+ static recalcPolarMarginWithScopedData(modelInstance, designerConfig, config, legendBlockModel, dataScope, options) {
27
+ const canvasModel = modelInstance.canvasModel;
28
+ let position = LegendModel.getLegendModel(config.options.type, config.options.legend.show, modelInstance.canvasModel).position;
28
29
  if (position !== 'off') {
29
- if (position === 'right' && blockSize.width - margin.left - margin.right < MIN_DONUT_BLOCK_SIZE)
30
+ if (position === 'right' && canvasModel.getChartBlockWidth() < MIN_DONUT_BLOCK_SIZE)
30
31
  position = 'bottom';
31
- this.clearMarginByLegendBlockPosition(margin, legendBlockModel);
32
+ this.clearMarginByLegendBlockPosition(canvasModel, legendBlockModel);
32
33
  let allowableKeys = [...dataScope.allowableKeys];
33
34
  if (dataScope.hidedRecordsAmount !== 0 && position === 'bottom')
34
35
  allowableKeys.push('1'); // Если есть спрятанные записи, то в массив добавляется объект, чтобы выделить место в легенде для индикатора переполнения
35
36
  const legendSize = LegendModel.getLegendSize(config.options.type, position, allowableKeys, designerConfig.canvas.legendBlock.maxWidth, config.canvas.size, legendBlockModel);
36
- margin[position] += legendSize + legendBlockModel.coordinate[position].margin[position];
37
+ canvasModel.increaseMarginSide(position, legendSize + legendBlockModel.coordinate[position].margin[position]);
37
38
  legendBlockModel.coordinate[position].size = legendSize;
38
39
  options.legend.position = position;
39
40
  }
40
41
  }
41
- static recalcMarginByVerticalAxisLabel(margin, config, designerConfig, dataScope) {
42
+ static recalcMarginByVerticalAxisLabel(modelInstance, config, designerConfig, dataScope) {
42
43
  if ((config.options.type === '2d' || config.options.type === 'interval') && config.options.orientation === 'vertical') {
43
44
  const axisLabelSize = AxisModel.getLabelSize(designerConfig.canvas.axisLabel.maxSize.main, dataScope.allowableKeys);
44
- const axisConfig = AxisModel.getKeyAxisLabelPosition(margin, config.canvas.size, dataScope.allowableKeys.length);
45
+ const axisConfig = AxisModel.getKeyAxisLabelPosition(modelInstance.canvasModel, dataScope.allowableKeys.length);
45
46
  const marginOrient = config.options.axis.key.position === 'end' ? 'bottom' : 'top';
46
47
  if (axisConfig === 'rotated')
47
- margin[marginOrient] += (axisLabelSize.width - axisLabelSize.height);
48
+ modelInstance.canvasModel.setMarginSide(marginOrient, modelInstance.canvasModel.getMarginSide(marginOrient) + (axisLabelSize.width - axisLabelSize.height));
48
49
  }
49
50
  }
50
51
  static getHorizontalMarginByAxisLabels(labelsMaxWidth, axis, data, options) {
@@ -58,35 +59,35 @@ export class MarginModel {
58
59
  }
59
60
  return AxisModel.getLabelSize(labelsMaxWidth, labelsTexts);
60
61
  }
61
- static recalcVerticalMarginByAxisLabelHeight(labelSize, margin, orientation, axis) {
62
+ static recalcVerticalMarginByAxisLabelHeight(labelSize, canvasModel, orientation, axis) {
62
63
  const keyAxisOrient = AxisModel.getAxisOrient(AxisType.Key, orientation, axis.key.position);
63
64
  const valueAxisOrient = AxisModel.getAxisOrient(AxisType.Value, orientation, axis.value.position);
64
65
  if ((keyAxisOrient === 'bottom' || keyAxisOrient === 'top')) {
65
66
  if (axis.key.visibility)
66
- margin[keyAxisOrient] += labelSize.height + AXIS_HORIZONTAL_LABEL_PADDING;
67
- }
68
- else if (axis.value.visibility) {
69
- margin[valueAxisOrient] += labelSize.height + AXIS_HORIZONTAL_LABEL_PADDING;
67
+ canvasModel.increaseMarginSide(keyAxisOrient, labelSize.height + AXIS_HORIZONTAL_LABEL_PADDING);
70
68
  }
69
+ else if (axis.value.visibility)
70
+ canvasModel.increaseMarginSide(valueAxisOrient, labelSize.height + AXIS_HORIZONTAL_LABEL_PADDING);
71
71
  }
72
- static recalcHorizontalMarginByAxisLabelWidth(labelSize, margin, orientation, axis, isShow) {
72
+ static recalcHorizontalMarginByAxisLabelWidth(labelSize, canvasModel, orientation, axis, isShow) {
73
73
  const keyAxisOrient = AxisModel.getAxisOrient(AxisType.Key, orientation, axis.key.position);
74
74
  const valueAxisOrient = AxisModel.getAxisOrient(AxisType.Value, orientation, axis.value.position);
75
75
  if ((keyAxisOrient === 'left' || keyAxisOrient === 'right') && isShow && axis.key.visibility) {
76
- margin[keyAxisOrient] += labelSize.width + AXIS_VERTICAL_LABEL_PADDING;
76
+ canvasModel.increaseMarginSide(keyAxisOrient, labelSize.width + AXIS_VERTICAL_LABEL_PADDING);
77
77
  }
78
78
  else if ((valueAxisOrient === 'left' || valueAxisOrient === 'right') && axis.value.visibility) {
79
- margin[valueAxisOrient] += labelSize.width + AXIS_VERTICAL_LABEL_PADDING;
79
+ canvasModel.increaseMarginSide(valueAxisOrient, labelSize.width + AXIS_VERTICAL_LABEL_PADDING);
80
80
  }
81
81
  }
82
- static recalcMarginWithLegend(margin, config, legendMaxWidth, legendBlockModel, data) {
83
- const legendPosition = LegendModel.getLegendModel(config.options.type, config.options.legend.show, config.canvas.size, margin).position;
82
+ static recalcMarginWithLegend(modelInstance, config, legendMaxWidth, legendBlockModel, data) {
83
+ const canvasModel = modelInstance.canvasModel;
84
+ const legendPosition = LegendModel.getLegendModel(config.options.type, config.options.legend.show, modelInstance.canvasModel).position;
84
85
  if (legendPosition !== 'off') {
85
86
  const legendItemsContent = this.getLegendItemsContent(config.options, data);
86
- const legendSize = LegendModel.getLegendSize(config.options.type, legendPosition, legendItemsContent, legendMaxWidth, config.canvas.size, legendBlockModel);
87
- margin[legendPosition] += legendSize;
87
+ const legendSize = LegendModel.getLegendSize(config.options.type, legendPosition, legendItemsContent, legendMaxWidth, canvasModel.getBlockSize(), legendBlockModel);
88
+ canvasModel.increaseMarginSide(legendPosition, legendSize);
88
89
  if (legendSize !== 0)
89
- this.appendToGlobalMarginValuesLegendMargin(margin, legendPosition, legendBlockModel);
90
+ this.appendToGlobalMarginValuesLegendMargin(canvasModel, legendPosition, legendBlockModel);
90
91
  legendBlockModel.coordinate[legendPosition].size = legendSize;
91
92
  }
92
93
  }
@@ -105,22 +106,23 @@ export class MarginModel {
105
106
  return [options.chart.data.valueField1.name];
106
107
  }
107
108
  }
108
- static appendToGlobalMarginValuesLegendMargin(margin, position, legendBlockModel) {
109
+ static appendToGlobalMarginValuesLegendMargin(canvasModel, position, legendBlockModel) {
109
110
  const legendCoordinate = legendBlockModel.coordinate;
110
111
  if (position === 'left' || position === 'right')
111
- margin[position] += legendCoordinate[position].margin.left + legendCoordinate[position].margin.right;
112
+ canvasModel.increaseMarginSide(position, legendCoordinate[position].margin.left + legendCoordinate[position].margin.right);
112
113
  else
113
- margin[position] += legendCoordinate[position].margin.top + legendCoordinate[position].margin.bottom;
114
+ canvasModel.increaseMarginSide(position, legendCoordinate[position].margin.top + legendCoordinate[position].margin.bottom);
114
115
  }
115
- static clearMarginByLegendBlockPosition(margin, legendBlockModel) {
116
+ static clearMarginByLegendBlockPosition(canvasModel, legendBlockModel) {
116
117
  const legendCoordinate = legendBlockModel.coordinate;
117
118
  ['left', 'right', 'top', 'bottom'].forEach((position) => {
118
- margin[position] -= legendCoordinate[position].size === 0
119
+ const decreaseByValue = legendCoordinate[position].size === 0
119
120
  ? 0
120
121
  : legendCoordinate[position].size + legendCoordinate[position].margin[position];
122
+ canvasModel.descreaseMarginSide(position, decreaseByValue);
121
123
  });
122
124
  }
123
- static recalcMarginByTitle(margin, titleBlockModel) {
124
- margin.top += titleBlockModel.margin.top + titleBlockModel.size;
125
+ static recalcMarginByTitle(canvasModel, titleBlockModel) {
126
+ canvasModel.increaseMarginSide("top", titleBlockModel.margin.top + titleBlockModel.size);
125
127
  }
126
128
  }
@@ -12,18 +12,17 @@ export declare type DataOptions = {
12
12
  };
13
13
  export interface Model {
14
14
  blockCanvas: BlockCanvas;
15
- chartBlock: ChartBlock;
15
+ chartBlock: ChartBlockModel;
16
16
  options: TwoDimensionalOptionsModel | PolarOptionsModel | IntervalOptionsModel;
17
- otherComponents: OtherComponents;
17
+ otherComponents: OtherCommonComponents;
18
18
  dataSettings: DataSettings;
19
- chartSettings: ChartElementsSettings;
20
19
  transitions?: Transitions;
21
20
  }
22
21
  export interface BlockCanvas {
23
22
  size: Size;
24
23
  cssClass: string;
25
24
  }
26
- export interface ChartBlock {
25
+ export interface ChartBlockModel {
27
26
  margin: BlockMargin;
28
27
  }
29
28
  export interface BlockMargin {
@@ -46,10 +45,12 @@ export interface TwoDimensionalOptionsModel extends OptionsModel {
46
45
  charts: TwoDimensionalChartModel[];
47
46
  additionalElements: AdditionalElementsOptions;
48
47
  orient: ChartOrientation;
48
+ chartSettings: TwoDimChartElementsSettings;
49
49
  }
50
50
  export interface PolarOptionsModel extends OptionsModel {
51
51
  type: "polar";
52
52
  charts: PolarChartModel[];
53
+ chartCanvas: DonutChartSettings;
53
54
  }
54
55
  export interface IntervalOptionsModel extends OptionsModel {
55
56
  type: "interval";
@@ -58,6 +59,7 @@ export interface IntervalOptionsModel extends OptionsModel {
58
59
  charts: IntervalChartModel[];
59
60
  additionalElements: AdditionalElementsOptions;
60
61
  orient: ChartOrientation;
62
+ chartSettings: TwoDimChartElementsSettings;
61
63
  }
62
64
  export interface ILegendModel {
63
65
  position: LegendPosition;
@@ -125,6 +127,23 @@ export interface GridLineFlag {
125
127
  key: boolean;
126
128
  value: boolean;
127
129
  }
130
+ export interface TwoDimChartElementsSettings {
131
+ bar: BarChartSettings;
132
+ }
133
+ export interface BarChartSettings {
134
+ groupMaxDistance: number;
135
+ groupMinDistance: number;
136
+ barDistance: number;
137
+ maxBarWidth: number;
138
+ minBarWidth: number;
139
+ }
140
+ export interface DonutChartSettings extends Omit<DonutOptionsCanvas, "aggregatorPad"> {
141
+ aggregator: DonutChartAggreagorModel;
142
+ }
143
+ export interface DonutChartAggreagorModel {
144
+ margin: number;
145
+ text: string;
146
+ }
128
147
  interface ChartModel {
129
148
  tooltip: TooltipModel;
130
149
  cssClasses: string[];
@@ -181,20 +200,7 @@ export interface DataScope {
181
200
  export interface DataFormat {
182
201
  formatters: Formatter;
183
202
  }
184
- export interface ChartElementsSettings {
185
- bar: BarChartSettings;
186
- donut: DonutChartSettings;
187
- }
188
- export interface BarChartSettings {
189
- groupMaxDistance: number;
190
- groupMinDistance: number;
191
- barDistance: number;
192
- maxBarWidth: number;
193
- minBarWidth: number;
194
- }
195
- export interface DonutChartSettings extends DonutOptionsCanvas {
196
- }
197
- export interface OtherComponents {
203
+ export interface OtherCommonComponents {
198
204
  legendBlock: LegendBlockModel;
199
205
  titleBlock: TitleBlockModel;
200
206
  tooltipBlock: TooltipSettings;