mdt-charts 1.27.1 → 1.27.3

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 (145) hide show
  1. package/.prettierrc +6 -0
  2. package/lib/config/config.d.ts +13 -13
  3. package/lib/designer/designerConfig.d.ts +1 -1
  4. package/lib/engine/block/block.js +14 -14
  5. package/lib/engine/block/blockHelper.js +2 -2
  6. package/lib/engine/block/blockSvg.js +25 -28
  7. package/lib/engine/block/defs/LinearGradientDef.js +9 -8
  8. package/lib/engine/contentManager/contentManagerFactory.js +1 -1
  9. package/lib/engine/elementHighlighter/elementHighlighter.d.ts +3 -3
  10. package/lib/engine/elementHighlighter/elementHighlighter.js +52 -54
  11. package/lib/engine/elementHighlighter/selectHighlighter.js +7 -7
  12. package/lib/engine/engine.d.ts +4 -4
  13. package/lib/engine/engine.js +5 -5
  14. package/lib/engine/features/aggregator/aggregator.d.ts +1 -1
  15. package/lib/engine/features/aggregator/aggregator.js +43 -45
  16. package/lib/engine/features/axis/axis.d.ts +1 -1
  17. package/lib/engine/features/axis/axis.js +53 -48
  18. package/lib/engine/features/axis/axisDomHelper.d.ts +3 -3
  19. package/lib/engine/features/axis/axisDomHelper.js +6 -8
  20. package/lib/engine/features/axis/axisHelper.d.ts +2 -2
  21. package/lib/engine/features/axis/axisHelper.js +14 -21
  22. package/lib/engine/features/axis/axisLabelDomHelper.d.ts +3 -3
  23. package/lib/engine/features/axis/axisLabelDomHelper.js +74 -66
  24. package/lib/engine/features/axis/axisLabelsEventManager.js +11 -11
  25. package/lib/engine/features/embeddedLabels/embeddedLabels.d.ts +3 -3
  26. package/lib/engine/features/embeddedLabels/embeddedLabels.js +44 -44
  27. package/lib/engine/features/embeddedLabels/embeddedLabelsDomHelper.d.ts +1 -1
  28. package/lib/engine/features/embeddedLabels/embeddedLabelsDomHelper.js +3 -6
  29. package/lib/engine/features/embeddedLabels/embeddedLabelsHelper.d.ts +2 -2
  30. package/lib/engine/features/embeddedLabels/embeddedLabelsHelper.js +22 -20
  31. package/lib/engine/features/gridLine/gidLineHelper.d.ts +1 -1
  32. package/lib/engine/features/gridLine/gidLineHelper.js +5 -5
  33. package/lib/engine/features/gridLine/gridLine.js +14 -23
  34. package/lib/engine/features/legend/legend.js +27 -36
  35. package/lib/engine/features/legend/legendDomHelper.js +18 -9
  36. package/lib/engine/features/legend/legendEventsManager.js +18 -13
  37. package/lib/engine/features/legend/legendHelper.js +19 -19
  38. package/lib/engine/features/legend/legendHelperService.js +5 -5
  39. package/lib/engine/features/legend/legendMarkerCreator.js +23 -22
  40. package/lib/engine/features/legend/legendWidthCalculator.js +5 -7
  41. package/lib/engine/features/markDots/markDot.d.ts +2 -2
  42. package/lib/engine/features/markDots/markDot.js +35 -34
  43. package/lib/engine/features/markDots/markDotsHelper.js +6 -6
  44. package/lib/engine/features/recordOverflowAlert/recordOverflowAlertCore.js +11 -11
  45. package/lib/engine/features/scale/scale.d.ts +4 -5
  46. package/lib/engine/features/scale/scale.js +16 -25
  47. package/lib/engine/features/tipBox/tipBox.d.ts +2 -2
  48. package/lib/engine/features/tipBox/tipBox.js +13 -17
  49. package/lib/engine/features/tipBox/tipBoxHelper.js +5 -5
  50. package/lib/engine/features/title/title.d.ts +1 -1
  51. package/lib/engine/features/title/title.js +8 -11
  52. package/lib/engine/features/tolltip/newTooltip/newTooltip.d.ts +1 -1
  53. package/lib/engine/features/tolltip/newTooltip/newTooltip.js +6 -8
  54. package/lib/engine/features/tolltip/tooltip.d.ts +2 -2
  55. package/lib/engine/features/tolltip/tooltip.js +47 -42
  56. package/lib/engine/features/tolltip/tooltipComponentsManager.d.ts +2 -2
  57. package/lib/engine/features/tolltip/tooltipComponentsManager.js +49 -52
  58. package/lib/engine/features/tolltip/tooltipDomHelper.d.ts +1 -1
  59. package/lib/engine/features/tolltip/tooltipDomHelper.js +41 -33
  60. package/lib/engine/features/tolltip/tooltipHelper.js +15 -11
  61. package/lib/engine/features/valueLabels/valueLabels.d.ts +3 -2
  62. package/lib/engine/features/valueLabels/valueLabels.js +33 -44
  63. package/lib/engine/features/valueLabels/valueLabelsHelper.js +6 -6
  64. package/lib/engine/features/valueLabelsCollision/valueLabelsCollision.js +9 -10
  65. package/lib/engine/features/valueLabelsCollision/valueLabelsCollisionHelper.js +4 -4
  66. package/lib/engine/filterManager/filterEventManager.js +18 -15
  67. package/lib/engine/helpers/domHelper.d.ts +3 -4
  68. package/lib/engine/helpers/domHelper.js +9 -13
  69. package/lib/engine/helpers/fontResizer/fontResizer.js +2 -2
  70. package/lib/engine/helpers/helper.js +14 -9
  71. package/lib/engine/helpers/namesHelper.js +2 -2
  72. package/lib/engine/polarNotation/donut/DonutHelper.js +6 -8
  73. package/lib/engine/polarNotation/donut/donut.d.ts +3 -3
  74. package/lib/engine/polarNotation/donut/donut.js +47 -58
  75. package/lib/engine/polarNotation/extenders/polarRecordOverflowAlert.js +11 -11
  76. package/lib/engine/polarNotation/polarManager.js +3 -5
  77. package/lib/engine/transitionManager.js +4 -7
  78. package/lib/engine/twoDimensionalNotation/area/area.d.ts +1 -1
  79. package/lib/engine/twoDimensionalNotation/area/area.js +77 -62
  80. package/lib/engine/twoDimensionalNotation/area/areaGenerator.js +4 -10
  81. package/lib/engine/twoDimensionalNotation/area/areaHelper.d.ts +3 -3
  82. package/lib/engine/twoDimensionalNotation/area/areaHelper.js +21 -13
  83. package/lib/engine/twoDimensionalNotation/bar/bar.d.ts +2 -2
  84. package/lib/engine/twoDimensionalNotation/bar/bar.js +70 -67
  85. package/lib/engine/twoDimensionalNotation/bar/barHelper.js +40 -35
  86. package/lib/engine/twoDimensionalNotation/dot/dotChart.js +60 -42
  87. package/lib/engine/twoDimensionalNotation/extenders/twoDimRecordOverflowAlert.js +7 -7
  88. package/lib/engine/twoDimensionalNotation/line/line.d.ts +4 -4
  89. package/lib/engine/twoDimensionalNotation/line/line.js +45 -28
  90. package/lib/engine/twoDimensionalNotation/line/lineBuilder.js +18 -16
  91. package/lib/engine/twoDimensionalNotation/line/lineGenerator.js +2 -4
  92. package/lib/engine/twoDimensionalNotation/line/lineHelper.d.ts +6 -6
  93. package/lib/engine/twoDimensionalNotation/line/lineHelper.js +26 -17
  94. package/lib/engine/twoDimensionalNotation/lineLike/generatorMiddleware/lineLikeGeneratorDefineMiddleware.js +1 -1
  95. package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +25 -21
  96. package/lib/engine/valueFormatter.d.ts +1 -1
  97. package/lib/main.d.ts +1 -0
  98. package/lib/main.js +8 -7
  99. package/lib/model/chartStyleModel/chartStyleModel.js +5 -3
  100. package/lib/model/chartStyleModel/colorRange.js +1 -3
  101. package/lib/model/chartStyleModel/twoDimensionalChartStyleModel.js +9 -7
  102. package/lib/model/dataManagerModel/dataManagerModel.js +28 -16
  103. package/lib/model/featuresModel/axisModel.d.ts +6 -3
  104. package/lib/model/featuresModel/axisModel.js +59 -32
  105. package/lib/model/featuresModel/axisModelService.js +2 -2
  106. package/lib/model/featuresModel/legendModel/legendCanvasModel.d.ts +1 -1
  107. package/lib/model/featuresModel/legendModel/legendCanvasModel.js +12 -12
  108. package/lib/model/featuresModel/legendModel/legendModel.js +2 -2
  109. package/lib/model/featuresModel/legendModel/polarMarginCalculator.js +1 -1
  110. package/lib/model/featuresModel/legendModel/twoDimLegendModel.js +4 -5
  111. package/lib/model/featuresModel/scaleModel/scaleAxisRecalcer.d.ts +4 -5
  112. package/lib/model/featuresModel/scaleModel/scaleAxisRecalcer.js +3 -5
  113. package/lib/model/featuresModel/scaleModel/scaleDomainService.js +10 -12
  114. package/lib/model/featuresModel/scaleModel/scaleModel.d.ts +8 -4
  115. package/lib/model/featuresModel/scaleModel/scaleModel.js +20 -12
  116. package/lib/model/featuresModel/scaleModel/scaleModelServices.js +5 -5
  117. package/lib/model/featuresModel/tooltipModel.js +1 -1
  118. package/lib/model/featuresModel/valueLabelsModel/valueLabelsModel.js +5 -5
  119. package/lib/model/helpers/modelHelper.js +6 -4
  120. package/lib/model/helpers/twoDimensionalModelHelper.d.ts +1 -1
  121. package/lib/model/helpers/twoDimensionalModelHelper.js +23 -23
  122. package/lib/model/helpers/unitsReader.js +1 -1
  123. package/lib/model/margin/marginModel.js +1 -1
  124. package/lib/model/margin/twoDim/twoDimMarginModel.d.ts +1 -0
  125. package/lib/model/margin/twoDim/twoDimMarginModel.js +38 -28
  126. package/lib/model/model.d.ts +17 -4
  127. package/lib/model/modelBuilder.d.ts +4 -4
  128. package/lib/model/modelBuilder.js +19 -18
  129. package/lib/model/modelInstance/canvasModel/canvasSizesModel/marginModelService.js +1 -1
  130. package/lib/model/modelInstance/chartBlockVersion/chartBlockVersion.d.ts +5 -0
  131. package/lib/model/modelInstance/chartBlockVersion/chartBlockVersion.js +8 -0
  132. package/lib/model/modelInstance/configReader.js +11 -10
  133. package/lib/model/modelInstance/dataModel/dataRepository.js +5 -5
  134. package/lib/model/modelInstance/modelInstance.d.ts +4 -2
  135. package/lib/model/modelInstance/modelInstance.js +5 -3
  136. package/lib/model/modelInstance/titleConfigReader.js +5 -5
  137. package/lib/model/notations/polar/donut/donutModel.js +1 -1
  138. package/lib/model/notations/polar/polarModel.js +6 -6
  139. package/lib/model/notations/twoDimensional/styles.d.ts +2 -2
  140. package/lib/model/notations/twoDimensional/styles.js +8 -8
  141. package/lib/model/notations/twoDimensionalModel.d.ts +0 -1
  142. package/lib/model/notations/twoDimensionalModel.js +32 -29
  143. package/package.json +59 -59
  144. package/tsconfig.production.json +14 -24
  145. package/README.md +0 -2
@@ -6,44 +6,52 @@ export var ScaleType;
6
6
  ScaleType[ScaleType["Value"] = 1] = "Value";
7
7
  })(ScaleType || (ScaleType = {}));
8
8
  export class ScaleModel {
9
- getScaleKey(allowableKeys, orient, canvasModel, charts, bandLikeCharts) {
9
+ constructor(options, canvasModel) {
10
+ this.options = options;
11
+ this.canvasModel = canvasModel;
12
+ }
13
+ getScaleKey(allowableKeys) {
14
+ const bandLikeCharts = this.getChartsByTypes(this.options.charts, ["bar", "dot"]);
10
15
  return {
11
16
  domain: allowableKeys,
12
17
  range: {
13
18
  start: 0,
14
- end: getScaleKeyRangePeek(orient, canvasModel)
19
+ end: getScaleKeyRangePeek(this.options.orientation, this.canvasModel)
15
20
  },
16
- type: this.getScaleKeyType(charts),
21
+ type: this.getScaleKeyType(this.options.charts),
17
22
  elementsAmount: getElementsAmountForScale(bandLikeCharts)
18
23
  };
19
24
  }
20
- getScaleLinear(options, dataRows, canvasModel, configReader) {
25
+ getScaleLinear(dataRows, configReader) {
21
26
  var _a;
22
27
  return {
23
- domain: getScaleLinearDomain(options.axis.value.domain, dataRows, options),
28
+ domain: getScaleLinearDomain(this.options.axis.value.domain, dataRows, this.options),
24
29
  range: {
25
30
  start: 0,
26
- end: getScaleValueRangePeek(options.orientation, canvasModel)
31
+ end: getScaleValueRangePeek(this.options.orientation, this.canvasModel)
27
32
  },
28
33
  type: "linear",
29
34
  formatter: (_a = configReader === null || configReader === void 0 ? void 0 : configReader.getAxisLabelFormatter()) !== null && _a !== void 0 ? _a : null
30
35
  };
31
36
  }
32
- getScaleSecondaryLinear(options, dataRows, canvasModel, configReader) {
37
+ getScaleSecondaryLinear(dataRows, configReader) {
33
38
  var _a;
34
39
  return {
35
- domain: getScaleLinearDomain(options.axis.value.domain, dataRows, options, 'secondary'),
40
+ domain: getScaleLinearDomain(this.options.axis.value.domain, dataRows, this.options, "secondary"),
36
41
  range: {
37
42
  start: 0,
38
- end: getScaleValueRangePeek(options.orientation, canvasModel)
43
+ end: getScaleValueRangePeek(this.options.orientation, this.canvasModel)
39
44
  },
40
45
  type: "linear",
41
46
  formatter: (_a = configReader === null || configReader === void 0 ? void 0 : configReader.getSecondaryAxisLabelFormatter()) !== null && _a !== void 0 ? _a : null
42
47
  };
43
48
  }
49
+ getChartsByTypes(charts, types) {
50
+ return charts.filter((chart) => types.includes(chart.type));
51
+ }
44
52
  getScaleKeyType(charts) {
45
- if (charts.some((chart) => chart.type === 'bar' || chart.type === 'dot'))
46
- return 'band';
47
- return 'point';
53
+ if (charts.some((chart) => chart.type === "bar" || chart.type === "dot"))
54
+ return "band";
55
+ return "point";
48
56
  }
49
57
  }
@@ -1,10 +1,10 @@
1
1
  export function getScaleKeyRangePeek(chartOrientation, canvasModel) {
2
- if (chartOrientation === 'vertical')
2
+ if (chartOrientation === "vertical")
3
3
  return canvasModel.getChartBlockWidth();
4
4
  return canvasModel.getChartBlockHeight();
5
5
  }
6
6
  export function getScaleValueRangePeek(chartOrientation, canvasModel) {
7
- if (chartOrientation === 'vertical')
7
+ if (chartOrientation === "vertical")
8
8
  return canvasModel.getChartBlockHeight();
9
9
  return canvasModel.getChartBlockWidth();
10
10
  }
@@ -12,12 +12,12 @@ export function getElementsAmountForScale(bandLikeCharts) {
12
12
  if (bandLikeCharts.length === 0)
13
13
  return 1;
14
14
  let barAmounts = {};
15
- bandLikeCharts.forEach(chart => {
15
+ bandLikeCharts.forEach((chart) => {
16
16
  if (!barAmounts[chart.type])
17
17
  barAmounts[chart.type] = 0;
18
- if (chart.type === 'dot')
18
+ if (chart.type === "dot")
19
19
  barAmounts[chart.type] = 1;
20
- if (chart.type === 'bar') {
20
+ if (chart.type === "bar") {
21
21
  if (chart.isSegmented)
22
22
  barAmounts[chart.type] += 1;
23
23
  else
@@ -1,7 +1,7 @@
1
1
  export class TooltipModel {
2
2
  static getTooltipModel(options) {
3
3
  return {
4
- position: (options === null || options === void 0 ? void 0 : options.position) || 'followCursor'
4
+ position: (options === null || options === void 0 ? void 0 : options.position) || "followCursor"
5
5
  };
6
6
  }
7
7
  }
@@ -8,9 +8,9 @@ export class ValueLabelCoordinateCalculator {
8
8
  }
9
9
  getValueLabelY(scaledValue) {
10
10
  switch (this.keyAxisOrient) {
11
- case 'bottom':
11
+ case "bottom":
12
12
  return scaledValue - this.offsetSizePx + this.margin.top;
13
- case 'top':
13
+ case "top":
14
14
  return scaledValue + this.offsetSizePx + this.margin.top;
15
15
  default:
16
16
  return scaledValue + this.margin.top;
@@ -18,9 +18,9 @@ export class ValueLabelCoordinateCalculator {
18
18
  }
19
19
  getValueLabelX(scaledValue) {
20
20
  switch (this.keyAxisOrient) {
21
- case 'right':
21
+ case "right":
22
22
  return scaledValue - this.offsetSizePx + this.margin.left;
23
- case 'left':
23
+ case "left":
24
24
  return scaledValue + this.offsetSizePx + this.margin.left;
25
25
  default:
26
26
  return scaledValue + this.margin.left;
@@ -30,7 +30,7 @@ export class ValueLabelCoordinateCalculator {
30
30
  export function calculateValueLabelAlignment(keyAxisOrient, positionMode) {
31
31
  if (!positionMode || positionMode === "after") {
32
32
  switch (keyAxisOrient) {
33
- case 'top':
33
+ case "top":
34
34
  return { dominantBaseline: "hanging", textAnchor: "middle" };
35
35
  case "bottom":
36
36
  return { dominantBaseline: "auto", textAnchor: "middle" };
@@ -19,15 +19,17 @@ export class ModelHelper {
19
19
  static getStringScore(word) {
20
20
  // lower case letter width ~ 0.8 from upper case width.
21
21
  // Number width == lower case letter width
22
- const fontSize = this.getBaseFontSize('--chart-base-font-size');
22
+ const fontSize = this.getBaseFontSize("--chart-base-font-size");
23
23
  let score = 0;
24
- const upperLetterScore = fontSize / 10;
25
- const lowerLetterScore = fontSize / 14;
24
+ const upperLetterScore = fontSize / 9;
25
+ const lowerLetterScore = fontSize / 13;
26
26
  const digitScore = fontSize / 15;
27
27
  const otherSymbolScore = fontSize / 23;
28
28
  const specialSmallSymbols = [",", ".", " "];
29
29
  for (let i = 0; i < word.length; i++) {
30
- if (parseFloat(word[i]).toString() !== word[i] && !specialSmallSymbols.includes(word[i]) && word[i].trim().length > 0) {
30
+ if (parseFloat(word[i]).toString() !== word[i] &&
31
+ !specialSmallSymbols.includes(word[i]) &&
32
+ word[i].trim().length > 0) {
31
33
  if (word[i].toUpperCase() === word[i])
32
34
  score += upperLetterScore;
33
35
  else
@@ -3,7 +3,7 @@ import { GradientDef, MarkDotDatumItem, Orient, TwoDimensionalChartModel, TwoDim
3
3
  import { CanvasModel } from "../modelInstance/canvasModel/canvasModel";
4
4
  export declare class TwoDimensionalModelHelper {
5
5
  static shouldMarkerShow(chart: MdtChartsTwoDimensionalChart, dataRows: MdtChartsDataRow[], valueFieldName: string, currentRow: MarkDotDatumItem, keyFieldName: string): boolean;
6
- static getGradientDefs(charts: TwoDimensionalChartModel[], keyAxisOrient: Orient, chartOrient: ChartOrientation): GradientDef[];
6
+ static getGradientDefs(charts: TwoDimensionalChartModel[], keyAxisOrient: Orient, chartOrient: ChartOrientation, chartBlockId: number): GradientDef[];
7
7
  private static getGradientItems;
8
8
  private static calculateOpacityItem;
9
9
  private static getGradientItemColor;
@@ -4,33 +4,34 @@ export class TwoDimensionalModelHelper {
4
4
  static shouldMarkerShow(chart, dataRows, valueFieldName, currentRow, keyFieldName) {
5
5
  if (chart.markers.show || dataRows.length === 1)
6
6
  return true;
7
- const rowIndex = dataRows.findIndex(row => row[keyFieldName] === currentRow[keyFieldName]);
7
+ const rowIndex = dataRows.findIndex((row) => row[keyFieldName] === currentRow[keyFieldName]);
8
8
  if (rowIndex === -1)
9
9
  return false;
10
10
  const isFirst = rowIndex === 0;
11
11
  const isLast = rowIndex === dataRows.length - 1;
12
12
  const previousRow = dataRows[rowIndex - 1];
13
13
  const nextRow = dataRows[rowIndex + 1];
14
- const hasNullNeighborsRows = !isFirst && !isLast &&
15
- (previousRow === null || previousRow === void 0 ? void 0 : previousRow[valueFieldName]) === null && (nextRow === null || nextRow === void 0 ? void 0 : nextRow[valueFieldName]) === null;
16
- return (isFirst && (nextRow === null || nextRow === void 0 ? void 0 : nextRow[valueFieldName]) === null) || (isLast && (previousRow === null || previousRow === void 0 ? void 0 : previousRow[valueFieldName]) === null) || hasNullNeighborsRows;
14
+ const hasNullNeighborsRows = !isFirst && !isLast && (previousRow === null || previousRow === void 0 ? void 0 : previousRow[valueFieldName]) === null && (nextRow === null || nextRow === void 0 ? void 0 : nextRow[valueFieldName]) === null;
15
+ return ((isFirst && (nextRow === null || nextRow === void 0 ? void 0 : nextRow[valueFieldName]) === null) ||
16
+ (isLast && (previousRow === null || previousRow === void 0 ? void 0 : previousRow[valueFieldName]) === null) ||
17
+ hasNullNeighborsRows);
17
18
  }
18
- static getGradientDefs(charts, keyAxisOrient, chartOrient) {
19
+ static getGradientDefs(charts, keyAxisOrient, chartOrient, chartBlockId) {
19
20
  let gradients = [];
20
21
  charts.forEach((chart) => {
21
22
  var _a;
22
- if (chart.type === 'area' && chart.areaViewOptions.fill.type === 'gradient') {
23
+ if (chart.type === "area" && chart.areaViewOptions.fill.type === "gradient") {
23
24
  (_a = chart.style.elementColors) === null || _a === void 0 ? void 0 : _a.forEach((elementColor, subIndex) => {
24
- const gradientId = getGradientId(chart.index, subIndex);
25
+ const gradientId = getGradientId(chart.index, subIndex, chartBlockId);
25
26
  gradients.push({
26
27
  id: gradientId,
27
28
  position: {
28
29
  x1: 0,
29
30
  y1: 0,
30
- x2: chartOrient === 'horizontal' ? 1 : 0,
31
- y2: chartOrient === 'horizontal' ? 0 : 1,
31
+ x2: chartOrient === "horizontal" ? 1 : 0,
32
+ y2: chartOrient === "horizontal" ? 0 : 1
32
33
  },
33
- items: this.getGradientItems(gradientId, elementColor, keyAxisOrient),
34
+ items: this.getGradientItems(gradientId, elementColor, keyAxisOrient)
34
35
  });
35
36
  });
36
37
  }
@@ -38,7 +39,7 @@ export class TwoDimensionalModelHelper {
38
39
  return gradients;
39
40
  }
40
41
  static getGradientItems(gradientId, elementColor, keyAxisOrient) {
41
- return [0, 1].map(itemIndex => ({
42
+ return [0, 1].map((itemIndex) => ({
42
43
  id: gradientId + `-item-${itemIndex}`,
43
44
  color: this.getGradientItemColor(itemIndex, keyAxisOrient, elementColor),
44
45
  offset: itemIndex,
@@ -48,16 +49,15 @@ export class TwoDimensionalModelHelper {
48
49
  static calculateOpacityItem(itemIndex, orientation) {
49
50
  const maxOpacity = 0.3;
50
51
  const minOpacity = 0;
51
- if (orientation === 'bottom' || orientation === 'right')
52
+ if (orientation === "bottom" || orientation === "right")
52
53
  return itemIndex === 0 ? maxOpacity : minOpacity;
53
54
  else
54
55
  return itemIndex === 0 ? minOpacity : maxOpacity;
55
56
  }
56
- ;
57
57
  static getGradientItemColor(itemIndex, orientation, elementColor) {
58
58
  const maxColor = elementColor;
59
59
  const minColor = "white";
60
- if (orientation === 'bottom' || orientation === 'right')
60
+ if (orientation === "bottom" || orientation === "right")
61
61
  return itemIndex === 0 ? maxColor : minColor;
62
62
  else
63
63
  return itemIndex === 0 ? minColor : maxColor;
@@ -68,36 +68,36 @@ export class TwoDimensionalModelHelper {
68
68
  const chartBlockConfig = {
69
69
  vertical: {
70
70
  left: {
71
- mode: 'shift',
71
+ mode: "shift",
72
72
  hasCollision: blockSidesOptions.hasCollisionLeft,
73
73
  shiftCoordinate: blockSidesOptions.shiftRight
74
74
  },
75
75
  right: {
76
- mode: 'shift',
76
+ mode: "shift",
77
77
  hasCollision: blockSidesOptions.hasCollisionRight,
78
78
  shiftCoordinate: blockSidesOptions.shiftLeft
79
79
  },
80
80
  top: {
81
- mode: 'none'
81
+ mode: "none"
82
82
  },
83
83
  bottom: {
84
- mode: 'none'
84
+ mode: "none"
85
85
  }
86
86
  },
87
87
  horizontal: {
88
88
  left: {
89
- mode: 'none'
89
+ mode: "none"
90
90
  },
91
91
  right: {
92
- mode: 'none'
92
+ mode: "none"
93
93
  },
94
94
  top: {
95
- mode: 'shift',
95
+ mode: "shift",
96
96
  hasCollision: blockSidesOptions.hasCollisionTop,
97
97
  shiftCoordinate: blockSidesOptions.shiftBottom
98
98
  },
99
99
  bottom: {
100
- mode: 'shift',
100
+ mode: "shift",
101
101
  hasCollision: blockSidesOptions.hasCollisionBottom,
102
102
  shiftCoordinate: blockSidesOptions.shiftTop
103
103
  }
@@ -106,7 +106,7 @@ export class TwoDimensionalModelHelper {
106
106
  return {
107
107
  collision: {
108
108
  otherValueLables: (_b = (_a = valueLabels === null || valueLabels === void 0 ? void 0 : valueLabels.collision) === null || _a === void 0 ? void 0 : _a.otherValueLabels) !== null && _b !== void 0 ? _b : {
109
- mode: 'none'
109
+ mode: "none"
110
110
  },
111
111
  chartBlock: chartBlockConfig[chartOrientation]
112
112
  },
@@ -6,7 +6,7 @@ export class UnitsReader {
6
6
  }
7
7
  getLastUnitFromString(value, units) {
8
8
  let resultUnit = null;
9
- units.forEach(unit => {
9
+ units.forEach((unit) => {
10
10
  if (value.endsWith(unit))
11
11
  resultUnit = unit;
12
12
  });
@@ -11,7 +11,7 @@ export class MarginModel {
11
11
  const canvasModel = modelInstance.canvasModel;
12
12
  canvasModel.initMargin(Object.assign({}, this.designerConfig.canvas.chartBlockMargin));
13
13
  this.recalcMarginByTitle(canvasModel);
14
- if (this.config.options.type === '2d') {
14
+ if (this.config.options.type === "2d") {
15
15
  this.twoDimModel.recalcMargin(otherComponents, modelInstance);
16
16
  }
17
17
  }
@@ -17,4 +17,5 @@ export declare class TwoDimMarginModel {
17
17
  private recalcHorizontalMarginByAxisLabelWidth;
18
18
  private recalcMarginBySecondaryAxisLabelSize;
19
19
  private recalcVerticalMarginWithValueLabelsOn;
20
+ private getValueAxisLabels;
20
21
  }
@@ -1,9 +1,11 @@
1
- import { AxisModel } from "../../featuresModel/axisModel";
1
+ import { AxisModel, LABEL_ELEMENT_HEIGHT_PX } from "../../featuresModel/axisModel";
2
2
  import { TwoDimLegendModel } from "../../featuresModel/legendModel/twoDimLegendModel";
3
3
  import { keyAxisLabelHorizontalLog, keyAxisLabelVerticalLog } from "../../featuresModel/scaleModel/scaleAxisRecalcer";
4
4
  import { AxisType } from "../../modelBuilder";
5
5
  import { TwoDimensionalModel } from "../../notations/twoDimensionalModel";
6
6
  import { OFFSET_SIZE_PX } from "../../featuresModel/valueLabelsModel/valueLabelsModel";
7
+ import { ScaleModel } from "../../featuresModel/scaleModel/scaleModel";
8
+ import { Scale } from "../../../engine/features/scale/scale";
7
9
  export const AXIS_HORIZONTAL_LABEL_PADDING = 12;
8
10
  export const AXIS_VERTICAL_LABEL_PADDING = 8;
9
11
  export class TwoDimMarginModel {
@@ -15,12 +17,12 @@ export class TwoDimMarginModel {
15
17
  recalcMargin(otherComponents, modelInstance) {
16
18
  const canvasModel = modelInstance.canvasModel;
17
19
  this.twoDimLegendModel.recalcMarginWith2DLegend(modelInstance, otherComponents.legendBlock, this.configReader.options.legend);
20
+ this.recalcVerticalMarginByAxisLabelHeight(LABEL_ELEMENT_HEIGHT_PX, canvasModel);
18
21
  const labelSize = this.getMaxLabelSize(modelInstance);
19
- this.recalcVerticalMarginByAxisLabelHeight(labelSize, canvasModel);
20
22
  // Если встроенный лейбл показывает ключи, то лейблы оси ключей не показываются
21
23
  // При этом все графики должны иметь: embeddedLabels = 'key'
22
- // И все графики должны быть типа bar.
23
- const showingFlag = this.configReader.options.type === '2d'
24
+ // И все графики должны быть типа bar.
25
+ const showingFlag = this.configReader.options.type === "2d"
24
26
  ? !TwoDimensionalModel.getChartsEmbeddedLabelsFlag(this.configReader.options.charts, this.configReader.options.orientation)
25
27
  : true;
26
28
  this.recalcHorizontalMarginByAxisLabelWidth(labelSize, canvasModel, showingFlag);
@@ -28,17 +30,19 @@ export class TwoDimMarginModel {
28
30
  const secondaryLabelSize = this.getMaxLabelSizeSecondary(modelInstance);
29
31
  this.recalcMarginBySecondaryAxisLabelSize(secondaryLabelSize, canvasModel);
30
32
  }
31
- if (this.configReader.areValueLabelsOn() && this.configReader.areValueLabelsNeedIncreaseMargin() && this.configReader.options.orientation === 'vertical') {
33
+ if (this.configReader.areValueLabelsOn() &&
34
+ this.configReader.areValueLabelsNeedIncreaseMargin() &&
35
+ this.configReader.options.orientation === "vertical") {
32
36
  this.recalcVerticalMarginWithValueLabelsOn(canvasModel);
33
37
  }
34
38
  }
35
39
  recalcMarginByVerticalAxisLabel(modelInstance) {
36
- if (this.configReader.options.orientation === 'vertical') {
40
+ if (this.configReader.options.orientation === "vertical") {
37
41
  const dataModel = modelInstance.dataModel;
38
42
  const axisLabelSize = AxisModel.getLabelSize(this.designerConfig.canvas.axisLabel.maxSize.main, dataModel.getAllowableKeys());
39
43
  const axisConfig = AxisModel.getKeyAxisLabelPosition(modelInstance.canvasModel, dataModel.getAllowableKeys().length, this.configReader.options.axis.key);
40
- const marginOrient = this.configReader.options.axis.key.position === 'end' ? 'bottom' : 'top';
41
- if (axisConfig === 'rotated') {
44
+ const marginOrient = this.configReader.options.axis.key.position === "end" ? "bottom" : "top";
45
+ if (axisConfig === "rotated") {
42
46
  modelInstance.canvasModel.decreaseMarginSide(marginOrient, axisLabelSize.height);
43
47
  modelInstance.canvasModel.increaseMarginSide(marginOrient, axisLabelSize.width, keyAxisLabelVerticalLog);
44
48
  }
@@ -47,44 +51,38 @@ export class TwoDimMarginModel {
47
51
  getMaxLabelSize(modelInstance) {
48
52
  const keyAxisOrient = AxisModel.getAxisOrient(AxisType.Key, this.configReader.options.orientation, this.configReader.options.axis.key.position);
49
53
  let labelsTexts;
50
- if (keyAxisOrient === 'left' || keyAxisOrient === 'right') {
54
+ if (keyAxisOrient === "left" || keyAxisOrient === "right") {
51
55
  labelsTexts = modelInstance.dataModel.repository.getValuesByKeyField();
52
56
  }
53
57
  else {
54
- labelsTexts = this.configReader.getBiggestValueAndDecremented(modelInstance.dataModel.repository)
55
- .map(v => this.configReader.getAxisLabelFormatter()(v).toString());
58
+ const scaleModel = new ScaleModel(this.configReader.options, modelInstance.canvasModel).getScaleLinear(modelInstance.dataModel.repository.getRawRows(), this.configReader);
59
+ labelsTexts = this.getValueAxisLabels(scaleModel, modelInstance).map((v) => this.configReader.getAxisLabelFormatter()(v).toString());
56
60
  }
57
61
  return AxisModel.getLabelSize(this.designerConfig.canvas.axisLabel.maxSize.main, labelsTexts);
58
62
  }
59
63
  getMaxLabelSizeSecondary(modelInstance) {
60
- const keyAxisOrient = AxisModel.getAxisOrient(AxisType.Key, this.configReader.options.orientation, this.configReader.options.axis.key.position);
61
- let labelsTexts;
62
- if (keyAxisOrient === 'left' || keyAxisOrient === 'right') {
63
- labelsTexts = modelInstance.dataModel.repository.getValuesByKeyField();
64
- }
65
- else {
66
- labelsTexts = this.configReader.getBiggestValueAndDecrementedSecondary(modelInstance.dataModel.repository)
67
- .map(v => this.configReader.getSecondaryAxisLabelFormatter()(v).toString());
68
- }
64
+ const scaleModel = new ScaleModel(this.configReader.options, modelInstance.canvasModel).getScaleSecondaryLinear(modelInstance.dataModel.repository.getRawRows(), this.configReader);
65
+ const labelsTexts = this.getValueAxisLabels(scaleModel, modelInstance).map((v) => this.configReader.getSecondaryAxisLabelFormatter()(v).toString());
69
66
  return AxisModel.getLabelSize(this.designerConfig.canvas.axisLabel.maxSize.main, labelsTexts);
70
67
  }
71
- recalcVerticalMarginByAxisLabelHeight(labelSize, canvasModel) {
68
+ recalcVerticalMarginByAxisLabelHeight(labelHeight, canvasModel) {
72
69
  const keyAxisOrient = AxisModel.getAxisOrient(AxisType.Key, this.configReader.options.orientation, this.configReader.options.axis.key.position);
73
70
  const valueAxisOrient = AxisModel.getAxisOrient(AxisType.Value, this.configReader.options.orientation, this.configReader.options.axis.value.position);
74
- if ((keyAxisOrient === 'bottom' || keyAxisOrient === 'top')) {
75
- if (this.configReader.options.axis.key.visibility)
76
- canvasModel.increaseMarginSide(keyAxisOrient, labelSize.height + AXIS_HORIZONTAL_LABEL_PADDING, keyAxisLabelVerticalLog);
77
- }
71
+ if ((keyAxisOrient === "bottom" || keyAxisOrient === "top") && this.configReader.options.axis.key.visibility)
72
+ canvasModel.increaseMarginSide(keyAxisOrient, labelHeight + AXIS_HORIZONTAL_LABEL_PADDING, keyAxisLabelVerticalLog);
78
73
  else if (this.configReader.options.axis.value.visibility)
79
- canvasModel.increaseMarginSide(valueAxisOrient, labelSize.height + AXIS_HORIZONTAL_LABEL_PADDING);
74
+ canvasModel.increaseMarginSide(valueAxisOrient, labelHeight + AXIS_HORIZONTAL_LABEL_PADDING);
80
75
  }
81
76
  recalcHorizontalMarginByAxisLabelWidth(labelSize, canvasModel, isShow) {
82
77
  const keyAxisOrient = AxisModel.getAxisOrient(AxisType.Key, this.configReader.options.orientation, this.configReader.options.axis.key.position);
83
78
  const valueAxisOrient = AxisModel.getAxisOrient(AxisType.Value, this.configReader.options.orientation, this.configReader.options.axis.value.position);
84
- if ((keyAxisOrient === 'left' || keyAxisOrient === 'right') && isShow && this.configReader.options.axis.key.visibility) {
79
+ if ((keyAxisOrient === "left" || keyAxisOrient === "right") &&
80
+ isShow &&
81
+ this.configReader.options.axis.key.visibility) {
85
82
  canvasModel.increaseMarginSide(keyAxisOrient, labelSize.width + AXIS_VERTICAL_LABEL_PADDING, keyAxisLabelHorizontalLog);
86
83
  }
87
- else if ((valueAxisOrient === 'left' || valueAxisOrient === 'right') && this.configReader.options.axis.value.visibility) {
84
+ else if ((valueAxisOrient === "left" || valueAxisOrient === "right") &&
85
+ this.configReader.options.axis.value.visibility) {
88
86
  canvasModel.increaseMarginSide(valueAxisOrient, labelSize.width + AXIS_VERTICAL_LABEL_PADDING);
89
87
  }
90
88
  }
@@ -114,4 +112,16 @@ export class TwoDimMarginModel {
114
112
  };
115
113
  canvasModel.increaseMarginSide(axisMarginMapping[keyAxisOrient], valueLabelFontSize + OFFSET_SIZE_PX);
116
114
  }
115
+ getValueAxisLabels(scaleModel, modelInstance) {
116
+ const scale = Scale.getScaleValue(scaleModel);
117
+ const ticksPolicy = AxisModel.getTickAmountPolicy(this.configReader.options.orientation, this.configReader.options.axis.value, scaleModel);
118
+ let outputValues;
119
+ if (ticksPolicy.type === "constant")
120
+ outputValues = ticksPolicy.values;
121
+ else if (ticksPolicy.type === "amount")
122
+ outputValues = scale.ticks(ticksPolicy.amount);
123
+ else
124
+ outputValues = this.configReader.getBiggestValueAndDecremented(modelInstance.dataModel.repository);
125
+ return outputValues;
126
+ }
117
127
  }
@@ -4,7 +4,7 @@ import { BoundingRect } from "../engine/features/valueLabelsCollision/valueLabel
4
4
  declare type AxisType = "key" | "value";
5
5
  export declare type Orient = "top" | "bottom" | "left" | "right";
6
6
  export declare type ScaleKeyType = "band" | "point";
7
- export declare type ScaleValueType = "linear" | "datetime";
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";
10
10
  export declare type DataOptions = {
@@ -162,7 +162,20 @@ export interface AxisLabelModel {
162
162
  defaultTooltip: boolean;
163
163
  showTick: ShowTickFn;
164
164
  linearTickStep: number;
165
+ tickAmountSettings: TickAmountModel;
165
166
  }
167
+ interface TickAmountModel {
168
+ policy: TickAmountPolicy;
169
+ }
170
+ export declare type TickAmountPolicy = {
171
+ type: "auto";
172
+ } | {
173
+ type: "amount";
174
+ amount: number;
175
+ } | {
176
+ type: "constant";
177
+ values: number[];
178
+ };
166
179
  export interface AdditionalElementsOptions {
167
180
  gridLine: GridLineOptions;
168
181
  }
@@ -298,7 +311,7 @@ export interface TwoDimensionalChartLegendBarModel {
298
311
  borderRadius: BarBorderRadius;
299
312
  width: number;
300
313
  }
301
- export interface TwoDimensionalChartLegendLineModel extends Omit<TwoDimensionalLineLikeChartViewModel, 'renderForKey'> {
314
+ export interface TwoDimensionalChartLegendLineModel extends Omit<TwoDimensionalLineLikeChartViewModel, "renderForKey"> {
302
315
  length: number;
303
316
  }
304
317
  interface TwoDimensionalLineLikeChartModel {
@@ -387,9 +400,9 @@ export interface MarkersOptions {
387
400
  show: MarkersOptionsShow;
388
401
  styles: MarkersStyleOptions;
389
402
  }
390
- export declare type MarkDotDatumItem = MdtChartsDataRow | {
403
+ export declare type MarkDotDatumItem = MdtChartsDataRow | ({
391
404
  "1": any;
392
- } & Array<number>;
405
+ } & Array<number>);
393
406
  export declare type MarkersOptionsShow = (options: {
394
407
  row: MarkDotDatumItem;
395
408
  valueFieldName: string;
@@ -1,6 +1,6 @@
1
- import { MdtChartsConfig, MdtChartsDataSource } from '../config/config';
2
- import { Model } from './model';
3
- import { DesignerConfig } from '../designer/designerConfig';
1
+ import { MdtChartsConfig, MdtChartsDataSource } from "../config/config";
2
+ import { Model } from "./model";
3
+ import { DesignerConfig } from "../designer/designerConfig";
4
4
  export declare enum AxisType {
5
5
  Key = 0,
6
6
  Value = 1
@@ -23,5 +23,5 @@ export declare const styledElementValues: {
23
23
  inlineDynamicItemWrapperMarginRightPx: number;
24
24
  };
25
25
  };
26
- export declare function assembleModel(config: MdtChartsConfig, data: MdtChartsDataSource, designerConfig: DesignerConfig): Model;
26
+ export declare function assembleModel(config: MdtChartsConfig, data: MdtChartsDataSource, designerConfig: DesignerConfig, chartBlockVersion: number): Model;
27
27
  export declare function getPreparedData(model: Model, data: MdtChartsDataSource, config: MdtChartsConfig): MdtChartsDataSource;
@@ -1,11 +1,11 @@
1
- import { MarginModel } from './margin/marginModel';
2
- import { TwoDimensionalModel } from './notations/twoDimensionalModel';
3
- import { PolarModel } from './notations/polar/polarModel';
4
- import { DataManagerModel } from './dataManagerModel/dataManagerModel';
5
- import { OtherComponentsModel } from './featuresModel/otherComponents';
6
- import { ConfigValidator } from './configsValidator/configValidator';
7
- import { ModelInstance } from './modelInstance/modelInstance';
8
- import { TwoDimConfigReader } from './modelInstance/configReader';
1
+ import { MarginModel } from "./margin/marginModel";
2
+ import { TwoDimensionalModel } from "./notations/twoDimensionalModel";
3
+ import { PolarModel } from "./notations/polar/polarModel";
4
+ import { DataManagerModel } from "./dataManagerModel/dataManagerModel";
5
+ import { OtherComponentsModel } from "./featuresModel/otherComponents";
6
+ import { ConfigValidator } from "./configsValidator/configValidator";
7
+ import { ModelInstance } from "./modelInstance/modelInstance";
8
+ import { TwoDimConfigReader } from "./modelInstance/configReader";
9
9
  import { TitleConfigReader } from "./modelInstance/titleConfigReader";
10
10
  export var AxisType;
11
11
  (function (AxisType) {
@@ -13,10 +13,10 @@ export var AxisType;
13
13
  AxisType[AxisType["Value"] = 1] = "Value";
14
14
  })(AxisType || (AxisType = {}));
15
15
  export const CLASSES = {
16
- dataLabel: 'data-label',
17
- legendLabel: 'legend-label',
18
- legendColor: 'legend-circle',
19
- legendItem: 'legend-item',
16
+ dataLabel: "data-label",
17
+ legendLabel: "legend-label",
18
+ legendColor: "legend-circle",
19
+ legendItem: "legend-item"
20
20
  };
21
21
  export const styledElementValues = {
22
22
  defaultLegendMarkerSizes: {
@@ -32,7 +32,8 @@ export const styledElementValues = {
32
32
  };
33
33
  function getBlockCanvas(config, modelInstance) {
34
34
  const emptyBlockParams = { width: 0, height: 0 };
35
- const size = ConfigValidator.validateCanvasSize(modelInstance.canvasModel.getBlockSize()) ? Object.assign({}, modelInstance.canvasModel.getBlockSize()) : emptyBlockParams;
35
+ const size = ConfigValidator.validateCanvasSize(modelInstance.canvasModel.getBlockSize())
36
+ ? Object.assign({}, modelInstance.canvasModel.getBlockSize()) : emptyBlockParams;
36
37
  return {
37
38
  size,
38
39
  cssClass: config.canvas.class
@@ -45,10 +46,10 @@ function getChartBlockModel(modelInstance) {
45
46
  }
46
47
  function getOptions(config, designerConfig, modelInstance) {
47
48
  //TODO: migrate to polymorphism
48
- if (config.options.type === '2d') {
49
+ if (config.options.type === "2d") {
49
50
  return TwoDimensionalModel.getOptions(new TwoDimConfigReader(config, designerConfig), designerConfig, modelInstance);
50
51
  }
51
- else if (config.options.type === 'polar') {
52
+ else if (config.options.type === "polar") {
52
53
  return PolarModel.getOptions(config.options, designerConfig, modelInstance);
53
54
  }
54
55
  }
@@ -66,8 +67,8 @@ function getDataFormat(designerConfig) {
66
67
  function getTransitions(designerConfig) {
67
68
  return designerConfig.transitions;
68
69
  }
69
- export function assembleModel(config, data, designerConfig) {
70
- const modelInstance = ModelInstance.create(config, data, designerConfig);
70
+ export function assembleModel(config, data, designerConfig, chartBlockVersion) {
71
+ const modelInstance = ModelInstance.create(config, data, designerConfig, chartBlockVersion);
71
72
  if (!data || Object.keys(data).length === 0)
72
73
  return {
73
74
  blockCanvas: getBlockCanvas(config, modelInstance),
@@ -84,7 +85,7 @@ export function assembleModel(config, data, designerConfig) {
84
85
  const marginModel = new MarginModel(designerConfig, config);
85
86
  marginModel.initMargin(otherComponents, modelInstance);
86
87
  DataManagerModel.initDataScope(config, data, designerConfig, otherComponents.legendBlock, modelInstance);
87
- if (config.options.type === '2d' && config.options.axis.key.visibility)
88
+ if (config.options.type === "2d" && config.options.axis.key.visibility)
88
89
  marginModel.recalcMarginByVerticalAxisLabel(modelInstance);
89
90
  const blockCanvas = getBlockCanvas(config, modelInstance);
90
91
  const chartBlock = getChartBlockModel(modelInstance);
@@ -21,6 +21,6 @@ export class MarginModelService {
21
21
  return (_a = this.findLogByKey(key)) === null || _a === void 0 ? void 0 : _a.data;
22
22
  }
23
23
  findLogByKey(key) {
24
- return this.log.find(l => l.key === key);
24
+ return this.log.find((l) => l.key === key);
25
25
  }
26
26
  }
@@ -0,0 +1,5 @@
1
+ export declare class ChartBlockVersion {
2
+ private readonly versionNumber;
3
+ constructor(versionNumber: number);
4
+ getVersionNumber(): number;
5
+ }
@@ -0,0 +1,8 @@
1
+ export class ChartBlockVersion {
2
+ constructor(versionNumber) {
3
+ this.versionNumber = versionNumber;
4
+ }
5
+ getVersionNumber() {
6
+ return this.versionNumber;
7
+ }
8
+ }