mdt-charts 1.27.0 → 1.27.2

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.js +24 -37
  62. package/lib/engine/features/valueLabels/valueLabelsHelper.js +6 -6
  63. package/lib/engine/features/valueLabelsCollision/valueLabelsCollision.js +9 -10
  64. package/lib/engine/features/valueLabelsCollision/valueLabelsCollisionHelper.js +4 -4
  65. package/lib/engine/filterManager/filterEventManager.js +18 -15
  66. package/lib/engine/helpers/domHelper.d.ts +3 -4
  67. package/lib/engine/helpers/domHelper.js +9 -13
  68. package/lib/engine/helpers/fontResizer/fontResizer.js +2 -2
  69. package/lib/engine/helpers/helper.js +14 -9
  70. package/lib/engine/helpers/namesHelper.js +2 -2
  71. package/lib/engine/polarNotation/donut/DonutHelper.js +6 -8
  72. package/lib/engine/polarNotation/donut/donut.d.ts +3 -3
  73. package/lib/engine/polarNotation/donut/donut.js +47 -58
  74. package/lib/engine/polarNotation/extenders/polarRecordOverflowAlert.js +11 -11
  75. package/lib/engine/polarNotation/polarManager.js +3 -5
  76. package/lib/engine/transitionManager.js +4 -7
  77. package/lib/engine/twoDimensionalNotation/area/area.d.ts +1 -1
  78. package/lib/engine/twoDimensionalNotation/area/area.js +77 -62
  79. package/lib/engine/twoDimensionalNotation/area/areaGenerator.js +4 -10
  80. package/lib/engine/twoDimensionalNotation/area/areaHelper.d.ts +3 -3
  81. package/lib/engine/twoDimensionalNotation/area/areaHelper.js +21 -13
  82. package/lib/engine/twoDimensionalNotation/bar/bar.d.ts +2 -2
  83. package/lib/engine/twoDimensionalNotation/bar/bar.js +70 -67
  84. package/lib/engine/twoDimensionalNotation/bar/barHelper.js +40 -35
  85. package/lib/engine/twoDimensionalNotation/dot/dotChart.js +60 -42
  86. package/lib/engine/twoDimensionalNotation/extenders/twoDimRecordOverflowAlert.js +7 -7
  87. package/lib/engine/twoDimensionalNotation/line/line.d.ts +4 -4
  88. package/lib/engine/twoDimensionalNotation/line/line.js +45 -28
  89. package/lib/engine/twoDimensionalNotation/line/lineBuilder.js +18 -16
  90. package/lib/engine/twoDimensionalNotation/line/lineGenerator.js +2 -4
  91. package/lib/engine/twoDimensionalNotation/line/lineHelper.d.ts +6 -6
  92. package/lib/engine/twoDimensionalNotation/line/lineHelper.js +26 -17
  93. package/lib/engine/twoDimensionalNotation/lineLike/generatorMiddleware/lineLikeGeneratorDefineMiddleware.js +1 -1
  94. package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +25 -21
  95. package/lib/engine/valueFormatter.d.ts +1 -1
  96. package/lib/main.d.ts +1 -0
  97. package/lib/main.js +8 -7
  98. package/lib/model/chartStyleModel/chartStyleModel.js +5 -3
  99. package/lib/model/chartStyleModel/colorRange.js +1 -3
  100. package/lib/model/chartStyleModel/twoDimensionalChartStyleModel.js +9 -7
  101. package/lib/model/dataManagerModel/dataManagerModel.js +28 -16
  102. package/lib/model/featuresModel/axisModel.d.ts +6 -3
  103. package/lib/model/featuresModel/axisModel.js +59 -32
  104. package/lib/model/featuresModel/axisModelService.js +2 -2
  105. package/lib/model/featuresModel/legendModel/legendCanvasModel.d.ts +1 -1
  106. package/lib/model/featuresModel/legendModel/legendCanvasModel.js +12 -12
  107. package/lib/model/featuresModel/legendModel/legendModel.js +2 -2
  108. package/lib/model/featuresModel/legendModel/polarMarginCalculator.js +1 -1
  109. package/lib/model/featuresModel/legendModel/twoDimLegendModel.js +4 -5
  110. package/lib/model/featuresModel/scaleModel/scaleAxisRecalcer.d.ts +4 -5
  111. package/lib/model/featuresModel/scaleModel/scaleAxisRecalcer.js +3 -5
  112. package/lib/model/featuresModel/scaleModel/scaleDomainService.js +10 -12
  113. package/lib/model/featuresModel/scaleModel/scaleModel.d.ts +8 -4
  114. package/lib/model/featuresModel/scaleModel/scaleModel.js +20 -12
  115. package/lib/model/featuresModel/scaleModel/scaleModelServices.js +5 -5
  116. package/lib/model/featuresModel/tooltipModel.js +1 -1
  117. package/lib/model/featuresModel/valueLabelsModel/valueLabelsModel.js +5 -5
  118. package/lib/model/helpers/modelHelper.js +6 -4
  119. package/lib/model/helpers/twoDimensionalModelHelper.d.ts +1 -1
  120. package/lib/model/helpers/twoDimensionalModelHelper.js +23 -23
  121. package/lib/model/helpers/unitsReader.js +1 -1
  122. package/lib/model/margin/marginModel.js +1 -1
  123. package/lib/model/margin/twoDim/twoDimMarginModel.d.ts +1 -0
  124. package/lib/model/margin/twoDim/twoDimMarginModel.js +38 -28
  125. package/lib/model/model.d.ts +17 -4
  126. package/lib/model/modelBuilder.d.ts +4 -4
  127. package/lib/model/modelBuilder.js +19 -18
  128. package/lib/model/modelInstance/canvasModel/canvasSizesModel/marginModelService.js +1 -1
  129. package/lib/model/modelInstance/chartBlockVersion/chartBlockVersion.d.ts +5 -0
  130. package/lib/model/modelInstance/chartBlockVersion/chartBlockVersion.js +8 -0
  131. package/lib/model/modelInstance/configReader.d.ts +2 -1
  132. package/lib/model/modelInstance/configReader.js +14 -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
@@ -23,7 +23,8 @@ export declare class TwoDimConfigReader implements BaseConfigReader {
23
23
  containsSecondaryAxis(): boolean;
24
24
  getValueLabelFormatterForChart(chartIndex: number): ValueLabelsFormatter;
25
25
  calculateDefaultAxisLabelFormatter(): AxisLabelFormatter;
26
- isValueLabelsOn(): boolean;
26
+ areValueLabelsOn(): boolean;
27
+ areValueLabelsNeedIncreaseMargin(): boolean;
27
28
  getValueLabelsStyleModel(): ValueLabelsStyleModel;
28
29
  private calculateBiggestValueAndDecremented;
29
30
  private calculateAxisLabelFormatter;
@@ -13,7 +13,7 @@ export class TwoDimConfigReader {
13
13
  }
14
14
  getValueFields() {
15
15
  const fields = [];
16
- this.options.charts.forEach(chart => {
16
+ this.options.charts.forEach((chart) => {
17
17
  fields.push(...chart.data.valueFields);
18
18
  });
19
19
  return fields;
@@ -26,12 +26,12 @@ export class TwoDimConfigReader {
26
26
  }
27
27
  getFieldsBySegments(valueGroup) {
28
28
  const segments = [];
29
- const valueGroupCharts = this.options.charts.filter(chart => { var _a; return ((_a = chart.data.valueGroup) !== null && _a !== void 0 ? _a : "main") === valueGroup; });
30
- valueGroupCharts.forEach(chart => {
29
+ const valueGroupCharts = this.options.charts.filter((chart) => { var _a; return ((_a = chart.data.valueGroup) !== null && _a !== void 0 ? _a : "main") === valueGroup; });
30
+ valueGroupCharts.forEach((chart) => {
31
31
  if (!chart.isSegmented)
32
- segments.push(...chart.data.valueFields.map(vf => [vf.name]));
32
+ segments.push(...chart.data.valueFields.map((vf) => [vf.name]));
33
33
  else
34
- segments.push(...[chart.data.valueFields.map(vf => vf.name)]);
34
+ segments.push(...[chart.data.valueFields.map((vf) => vf.name)]);
35
35
  });
36
36
  return segments;
37
37
  }
@@ -43,8 +43,8 @@ export class TwoDimConfigReader {
43
43
  }
44
44
  getLegendItemInfo() {
45
45
  const info = [];
46
- this.options.charts.forEach(c => {
47
- c.data.valueFields.forEach(vf => {
46
+ this.options.charts.forEach((c) => {
47
+ c.data.valueFields.forEach((vf) => {
48
48
  var _a;
49
49
  info.push({ text: (_a = vf.title) !== null && _a !== void 0 ? _a : vf.name, chartType: c.type });
50
50
  });
@@ -52,7 +52,8 @@ export class TwoDimConfigReader {
52
52
  return info;
53
53
  }
54
54
  containsSecondaryAxis() {
55
- return !!this.options.axis.valueSecondary && this.options.charts.some(chart => chart.data.valueGroup === 'secondary');
55
+ return (!!this.options.axis.valueSecondary &&
56
+ this.options.charts.some((chart) => chart.data.valueGroup === "secondary"));
56
57
  }
57
58
  getValueLabelFormatterForChart(chartIndex) {
58
59
  var _a, _b, _c, _d;
@@ -75,8 +76,11 @@ export class TwoDimConfigReader {
75
76
  const valueFieldFormat = this.options.charts[0].data.valueFields[0].format;
76
77
  return (v) => this.designerConfig.dataFormat.formatters(v, { type: valueFieldFormat });
77
78
  }
78
- isValueLabelsOn() {
79
- return this.options.charts.some(chart => { var _a; return (_a = chart.valueLabels) === null || _a === void 0 ? void 0 : _a.on; });
79
+ areValueLabelsOn() {
80
+ return this.options.charts.some((chart) => { var _a; return (_a = chart.valueLabels) === null || _a === void 0 ? void 0 : _a.on; });
81
+ }
82
+ areValueLabelsNeedIncreaseMargin() {
83
+ return !this.options.charts.every((chart) => { var _a, _b; return ((_b = (_a = chart.valueLabels) === null || _a === void 0 ? void 0 : _a.position) === null || _b === void 0 ? void 0 : _b.mode) === "center"; });
80
84
  }
81
85
  getValueLabelsStyleModel() {
82
86
  var _a, _b, _c, _d, _e, _f, _g, _h;
@@ -5,22 +5,22 @@ export class DataRepositoryModel {
5
5
  this.valueFields = valueFields;
6
6
  }
7
7
  getValuesByKeyField() {
8
- return this.getRawRows().map(dataRow => dataRow[this.keyField.name]);
8
+ return this.getRawRows().map((dataRow) => dataRow[this.keyField.name]);
9
9
  }
10
10
  getBiggestValueAndDecremented(segmentedFields) {
11
11
  const values = [];
12
- this.getRawRows().forEach(row => {
12
+ this.getRawRows().forEach((row) => {
13
13
  if (!segmentedFields) {
14
- this.valueFields.forEach(vf => values.push(row[vf.name]));
14
+ this.valueFields.forEach((vf) => values.push(row[vf.name]));
15
15
  return;
16
16
  }
17
- segmentedFields.forEach(fields => {
17
+ segmentedFields.forEach((fields) => {
18
18
  const valuesBySegment = fields.reduce((acc, f) => acc + row[f], 0);
19
19
  values.push(valuesBySegment);
20
20
  });
21
21
  });
22
22
  const biggest = Math.max(...values);
23
- const biggestDecremented = Math.abs(biggest) > 1 ? (biggest - 1) : (biggest - 0.1);
23
+ const biggestDecremented = Math.abs(biggest) > 1 ? biggest - 1 : biggest - 0.1;
24
24
  return [biggest, biggestDecremented];
25
25
  }
26
26
  initRawFullSource(rawSource) {
@@ -1,11 +1,13 @@
1
1
  import { MdtChartsConfig, MdtChartsDataSource } from "../../config/config";
2
2
  import { DesignerConfig } from "../../designer/designerConfig";
3
3
  import { CanvasModel } from "./canvasModel/canvasModel";
4
+ import { ChartBlockVersion } from "./chartBlockVersion/chartBlockVersion";
4
5
  import { DataModelInstance } from "./dataModel/dataModel";
5
6
  export declare class ModelInstance {
6
- static create(config: MdtChartsConfig, data: MdtChartsDataSource, designerConfig: DesignerConfig): ModelInstance;
7
+ static create(config: MdtChartsConfig, data: MdtChartsDataSource, designerConfig: DesignerConfig, chartBlockVersion: number): ModelInstance;
7
8
  private static initInitialParams;
8
9
  canvasModel: CanvasModel;
9
10
  dataModel: DataModelInstance;
10
- constructor();
11
+ version: ChartBlockVersion;
12
+ constructor(chartVersionNumber: number);
11
13
  }
@@ -1,13 +1,15 @@
1
1
  import { CanvasModel } from "./canvasModel/canvasModel";
2
+ import { ChartBlockVersion } from "./chartBlockVersion/chartBlockVersion";
2
3
  import { getConfigReader } from "./configReader";
3
4
  import { DataModelInstance } from "./dataModel/dataModel";
4
5
  export class ModelInstance {
5
- constructor() {
6
+ constructor(chartVersionNumber) {
6
7
  this.canvasModel = new CanvasModel();
7
8
  this.dataModel = new DataModelInstance();
9
+ this.version = new ChartBlockVersion(chartVersionNumber);
8
10
  }
9
- static create(config, data, designerConfig) {
10
- const modelInstance = new ModelInstance();
11
+ static create(config, data, designerConfig, chartBlockVersion) {
12
+ const modelInstance = new ModelInstance(chartBlockVersion);
11
13
  this.initInitialParams(modelInstance, config, data, designerConfig);
12
14
  return modelInstance;
13
15
  }
@@ -6,28 +6,28 @@ export class TitleConfigReader {
6
6
  this.defaultCssUnitReader = defaultCssUnitReader;
7
7
  }
8
8
  static create(config, modelInstance) {
9
- return new TitleConfigReader(config, () => modelInstance.dataModel.repository.getRawRows(), () => ModelHelper.getFontSizeCssValue('--chart-title-font-size', 16));
9
+ return new TitleConfigReader(config, () => modelInstance.dataModel.repository.getRawRows(), () => ModelHelper.getFontSizeCssValue("--chart-title-font-size", 16));
10
10
  }
11
11
  getTextContent() {
12
12
  return this.getResolvedTitle();
13
13
  }
14
14
  getFontSize() {
15
15
  var _a;
16
- return typeof this.config === 'object'
16
+ return typeof this.config === "object"
17
17
  ? (_a = this.config.fontSize) !== null && _a !== void 0 ? _a : this.defaultCssUnitReader() : this.defaultCssUnitReader();
18
18
  }
19
19
  getResolvedTitle() {
20
20
  switch (typeof this.config) {
21
- case 'string':
21
+ case "string":
22
22
  return this.config;
23
23
  case "function":
24
24
  return this.config({ data: this.dataGetter() });
25
25
  case "object":
26
- return typeof this.config.text === 'function'
26
+ return typeof this.config.text === "function"
27
27
  ? this.config.text({ data: this.dataGetter() })
28
28
  : this.config.text;
29
29
  default:
30
- return '';
30
+ return "";
31
31
  }
32
32
  }
33
33
  }
@@ -17,7 +17,7 @@ export class DonutModel {
17
17
  unit: this.thicknessService.getUnit(settingsFromConfig),
18
18
  max: this.thicknessService.valueToNumber(settingsFromConfig.max),
19
19
  min: this.thicknessService.valueToNumber(settingsFromConfig.min),
20
- value: this.thicknessService.valueToNumber(settingsFromConfig.value),
20
+ value: this.thicknessService.valueToNumber(settingsFromConfig.value)
21
21
  };
22
22
  }
23
23
  getAggregatorOptions(settingsFromConfig, chartOptions, rawDataRows) {
@@ -10,14 +10,14 @@ export class PolarModel {
10
10
  selectable: !!options.selectable,
11
11
  title: {
12
12
  textContent: titleConfig.getTextContent(),
13
- fontSize: titleConfig.getFontSize(),
13
+ fontSize: titleConfig.getFontSize()
14
14
  },
15
15
  data: Object.assign({}, options.data),
16
16
  charts: this.getChartsModel(options.chart, modelInstance.dataModel.repository.getScopedRows().length, designerConfig.chartStyle),
17
17
  legend: modelInstance.canvasModel.legendCanvas.getModel(),
18
18
  tooltip: options.tooltip,
19
19
  chartCanvas: this.getDonutSettings(designerConfig.canvas.chartOptions.donut, options.chart, modelInstance.dataModel.repository.getRawRows()),
20
- defs: { gradients: [] },
20
+ defs: { gradients: [] }
21
21
  };
22
22
  }
23
23
  //TODO: type for returned value
@@ -26,10 +26,10 @@ export class PolarModel {
26
26
  const avgLegendWidth = 100;
27
27
  const blockWidth = canvasModel.getBlockSize().width;
28
28
  const blockHeight = canvasModel.getBlockSize().height;
29
- return canvasModel.getChartBlockWidth() < MIN_DONUT_BLOCK_SIZE + avgLegendWidth
30
- && blockWidth * widthCoefficientWhenLegendShouldInBottom < blockHeight
31
- ? 'bottom'
32
- : 'right';
29
+ return canvasModel.getChartBlockWidth() < MIN_DONUT_BLOCK_SIZE + avgLegendWidth &&
30
+ blockWidth * widthCoefficientWhenLegendShouldInBottom < blockHeight
31
+ ? "bottom"
32
+ : "right";
33
33
  }
34
34
  static doesChartBlockHasEnoughWidthForContainsLegend(chartBlockWidth, legendWidth, legendCoordinate) {
35
35
  const rightLegendMargin = legendCoordinate.right.margin;
@@ -10,5 +10,5 @@ export declare function getSegmentedRadiusValues(segmentsLength: number, segment
10
10
  export declare function getLegendMarkerOptions(chart: MdtChartsTwoDimensionalChart): ChartLegendModel;
11
11
  export declare function getLineViewOptions(chart: MdtChartsTwoDimensionalChart): TwoDimensionalChartLegendLineModel;
12
12
  export declare function getWidthOfLegendMarkerByType(chartType: TwoDimensionalChartType): number;
13
- export declare function getAreaViewOptions(chart: MdtChartsTwoDimensionalChart, chartIndex: number, style: ChartStyle): AreaChartViewOptions;
14
- export declare function getGradientId(chartIndex: number, subIndex: number): GradientId;
13
+ export declare function getAreaViewOptions(chart: MdtChartsTwoDimensionalChart, chartIndex: number, style: ChartStyle, chartBlockId: number): AreaChartViewOptions;
14
+ export declare function getGradientId(chartIndex: number, subIndex: number, chartBlockId: number): GradientId;
@@ -36,13 +36,13 @@ export function getBarViewOptions(chart, keyAxisOrient, barIndexes) {
36
36
  const borderRadius = {
37
37
  grouped: getRadiusValues(defaultRadius),
38
38
  segmented: {
39
- handle: (valueIndex) => getSegmentedRadiusValues(chart.data.valueFields.length, valueIndex, keyAxisOrient, defaultRadius),
39
+ handle: (valueIndex) => getSegmentedRadiusValues(chart.data.valueFields.length, valueIndex, keyAxisOrient, defaultRadius)
40
40
  }
41
41
  };
42
42
  return { hatch, borderRadius, barIndexes };
43
43
  }
44
44
  export function calculateBarIndexes(allCharts, currentChart, currentChartIndex) {
45
- const prevBarCharts = allCharts.slice(0, currentChartIndex).filter(ch => ch.type === "bar");
45
+ const prevBarCharts = allCharts.slice(0, currentChartIndex).filter((ch) => ch.type === "bar");
46
46
  const startBarIndex = prevBarCharts.reduce((acc, ch) => acc + (ch.isSegmented ? 1 : ch.data.valueFields.length), 0);
47
47
  if (currentChart.isSegmented)
48
48
  return [startBarIndex];
@@ -62,13 +62,13 @@ export function getSegmentedRadiusValues(segmentsLength, segmentIndex, keyAxisOr
62
62
  top: { topLeft: defaultRadius, topRight: defaultRadius, bottomLeft: 0, bottomRight: 0 },
63
63
  bottom: { topLeft: 0, topRight: 0, bottomLeft: defaultRadius, bottomRight: defaultRadius },
64
64
  left: { topLeft: defaultRadius, topRight: 0, bottomLeft: defaultRadius, bottomRight: 0 },
65
- right: { topLeft: 0, topRight: defaultRadius, bottomLeft: 0, bottomRight: defaultRadius },
65
+ right: { topLeft: 0, topRight: defaultRadius, bottomLeft: 0, bottomRight: defaultRadius }
66
66
  },
67
67
  last: {
68
68
  top: { topLeft: 0, topRight: 0, bottomLeft: defaultRadius, bottomRight: defaultRadius },
69
69
  bottom: { topLeft: defaultRadius, topRight: defaultRadius, bottomLeft: 0, bottomRight: 0 },
70
70
  left: { topLeft: 0, topRight: defaultRadius, bottomLeft: 0, bottomRight: defaultRadius },
71
- right: { topLeft: defaultRadius, topRight: 0, bottomLeft: defaultRadius, bottomRight: 0 },
71
+ right: { topLeft: defaultRadius, topRight: 0, bottomLeft: defaultRadius, bottomRight: 0 }
72
72
  },
73
73
  middle: { topLeft: 0, topRight: 0, bottomLeft: 0, bottomRight: 0 },
74
74
  default: getRadiusValues(defaultRadius)
@@ -131,11 +131,11 @@ export function getWidthOfLegendMarkerByType(chartType) {
131
131
  if (chartType === "area")
132
132
  return styledElementValues.defaultLegendMarkerSizes.widthPx;
133
133
  }
134
- export function getAreaViewOptions(chart, chartIndex, style) {
134
+ export function getAreaViewOptions(chart, chartIndex, style, chartBlockId) {
135
135
  var _a, _b, _c, _d, _e;
136
136
  let gradientIds = [];
137
137
  for (let index = 0; index < style.elementColors.length; index++) {
138
- gradientIds.push(getGradientId(chartIndex, index));
138
+ gradientIds.push(getGradientId(chartIndex, index, chartBlockId));
139
139
  }
140
140
  const fill = ((_b = (_a = chart.areaStyles) === null || _a === void 0 ? void 0 : _a.gradient) === null || _b === void 0 ? void 0 : _b.on) ? { type: "gradient", ids: gradientIds }
141
141
  : { type: "paletteColor" };
@@ -148,6 +148,6 @@ export function getAreaViewOptions(chart, chartIndex, style) {
148
148
  };
149
149
  return { fill, borderLine };
150
150
  }
151
- export function getGradientId(chartIndex, subIndex) {
152
- return `gradient-chart-${chartIndex}-sub-${subIndex}`;
151
+ export function getGradientId(chartIndex, subIndex, chartBlockId) {
152
+ return `chart-${chartBlockId}-gradient-chart-${chartIndex}-sub-${subIndex}`;
153
153
  }
@@ -17,5 +17,4 @@ export declare class TwoDimensionalModel {
17
17
  private static findChartsWithEmbeddedKeyLabels;
18
18
  private static getEmbeddedLabelType;
19
19
  private static getAdditionalElements;
20
- private static getChartsByTypes;
21
20
  }
@@ -11,30 +11,31 @@ export class TwoDimensionalModel {
11
11
  static getOptions(configReader, designerConfig, modelInstance) {
12
12
  const options = configReader.options;
13
13
  const canvasModel = modelInstance.canvasModel;
14
- const scaleModel = new ScaleModel();
15
- const titleConfig = TitleConfigReader.create(options.title, modelInstance);
16
- const scaleMarginRecalcer = new ScaleAxisRecalcer(() => scaleModel.getScaleLinear(options, modelInstance.dataModel.repository.getScopedRows(), canvasModel, configReader));
14
+ const scaleModel = new ScaleModel(options, canvasModel);
15
+ const scaleMarginRecalcer = new ScaleAxisRecalcer(() => scaleModel.getScaleLinear(modelInstance.dataModel.repository.getScopedRows(), configReader));
17
16
  scaleMarginRecalcer.recalculateMargin(canvasModel, options.orientation, options.axis.key);
18
17
  const scaleValueInfo = scaleMarginRecalcer.getScaleValue();
19
18
  let secondaryScaleValueInfo;
20
19
  if (configReader.containsSecondaryAxis()) {
21
- const secondaryScaleMarginRecalcer = new ScaleAxisRecalcer(() => scaleModel.getScaleSecondaryLinear(options, modelInstance.dataModel.repository.getScopedRows(), canvasModel, configReader));
20
+ const secondaryScaleMarginRecalcer = new ScaleAxisRecalcer(() => scaleModel.getScaleSecondaryLinear(modelInstance.dataModel.repository.getScopedRows(), configReader));
22
21
  secondaryScaleMarginRecalcer.recalculateMargin(canvasModel, options.orientation, options.axis.key);
23
22
  secondaryScaleValueInfo = secondaryScaleMarginRecalcer.getScaleValue();
24
23
  }
25
24
  const keyAxis = AxisModel.getKeyAxis(options, modelInstance.dataModel.repository.getScopedFullSource(), designerConfig.canvas.axisLabel, canvasModel, designerConfig.elementsOptions.tooltip, () => scaleValueInfo.scaleFn(0));
26
- const charts = this.getChartsModel(options.charts, configReader, options.orientation, designerConfig, modelInstance.dataModel.repository, keyAxis.orient, canvasModel, options.data.keyField.name);
27
- const defaultFormatter = configReader.calculateDefaultAxisLabelFormatter();
25
+ const charts = this.getChartsModel(options.charts, configReader, options.orientation, designerConfig, modelInstance.dataModel.repository, keyAxis.orient, canvasModel, options.data.keyField.name, modelInstance);
26
+ const titleConfig = TitleConfigReader.create(options.title, modelInstance);
28
27
  return {
29
28
  legend: canvasModel.legendCanvas.getModel(),
30
29
  title: {
31
30
  textContent: titleConfig.getTextContent(),
32
- fontSize: titleConfig.getFontSize(),
31
+ fontSize: titleConfig.getFontSize()
33
32
  },
34
33
  selectable: !!options.selectable,
35
34
  orient: options.orientation,
36
- scale: Object.assign({ key: scaleModel.getScaleKey(modelInstance.dataModel.getAllowableKeys(), options.orientation, canvasModel, options.charts, this.getChartsByTypes(options.charts, ['bar', 'dot'])), value: scaleValueInfo.scale }, (configReader.containsSecondaryAxis() && { valueSecondary: secondaryScaleValueInfo.scale })),
37
- axis: Object.assign({ key: keyAxis, value: AxisModel.getMainValueAxis(defaultFormatter, options.orientation, options.axis.value.position, options.axis.value, designerConfig.canvas.axisLabel, canvasModel) }, (configReader.containsSecondaryAxis() && { valueSecondary: AxisModel.getSecondaryValueAxis(defaultFormatter, options.orientation, options.axis.value.position, options.axis.valueSecondary, designerConfig.canvas.axisLabel, canvasModel) })),
35
+ scale: Object.assign({ key: scaleModel.getScaleKey(modelInstance.dataModel.getAllowableKeys()), value: scaleValueInfo.scale }, (configReader.containsSecondaryAxis() && { valueSecondary: secondaryScaleValueInfo.scale })),
36
+ axis: Object.assign({ key: keyAxis, value: AxisModel.getMainValueAxis(configReader.calculateDefaultAxisLabelFormatter(), options.orientation, options.axis.value.position, options.axis.value, designerConfig.canvas.axisLabel, canvasModel, scaleValueInfo.scale) }, (configReader.containsSecondaryAxis() && {
37
+ valueSecondary: AxisModel.getSecondaryValueAxis(configReader.calculateDefaultAxisLabelFormatter(), options.orientation, options.axis.value.position, options.axis.valueSecondary, designerConfig.canvas.axisLabel, canvasModel, secondaryScaleValueInfo.scale)
38
+ })),
38
39
  type: options.type,
39
40
  data: Object.assign({}, options.data),
40
41
  charts,
@@ -43,15 +44,15 @@ export class TwoDimensionalModel {
43
44
  chartSettings: this.getChartsSettings(designerConfig.canvas.chartOptions, options.orientation),
44
45
  valueLabels: TwoDimensionalModelHelper.getValueLabels(options.valueLabels, canvasModel, options.orientation, configReader.getValueLabelsStyleModel()),
45
46
  defs: {
46
- gradients: TwoDimensionalModelHelper.getGradientDefs(charts, keyAxis.orient, options.orientation)
47
+ gradients: TwoDimensionalModelHelper.getGradientDefs(charts, keyAxis.orient, options.orientation, modelInstance.version.getVersionNumber())
47
48
  }
48
49
  };
49
50
  }
50
51
  static getChartsEmbeddedLabelsFlag(charts, chartOrientation) {
51
52
  // Если НЕ найден хотя бы один чарт, который сегментированный или хотя бы один НЕ бар чарт, то лейблы можно прятать
52
- return charts.findIndex(chart => chart.isSegmented || chart.type !== 'bar') === -1
53
- && chartOrientation === 'horizontal'
54
- && charts.length === this.findChartsWithEmbeddedKeyLabels(charts).length;
53
+ return (charts.findIndex((chart) => chart.isSegmented || chart.type !== "bar") === -1 &&
54
+ chartOrientation === "horizontal" &&
55
+ charts.length === this.findChartsWithEmbeddedKeyLabels(charts).length);
55
56
  }
56
57
  /**
57
58
  * Сортирует список чартов в порядке: area - bar - line.
@@ -59,7 +60,7 @@ export class TwoDimensionalModel {
59
60
  * @param charts Чарты из конфига
60
61
  */
61
62
  static sortCharts(charts) {
62
- const chartOrder = ['area', 'bar', 'line', 'dot'];
63
+ const chartOrder = ["area", "bar", "line", "dot"];
63
64
  charts.sort((chart1, chart2) => chartOrder.indexOf(chart1.type) - chartOrder.indexOf(chart2.type));
64
65
  }
65
66
  static getChartsSettings(chartOptions, chartOrientation) {
@@ -69,7 +70,7 @@ export class TwoDimensionalModel {
69
70
  lineLike: { shape: parseShape(chartOrientation, (_a = chartOptions.line) === null || _a === void 0 ? void 0 : _a.shape) }
70
71
  };
71
72
  }
72
- static getChartsModel(charts, configReader, chartOrientation, designerConfig, dataModelRep, keyAxisOrient, canvasModel, keyFieldName) {
73
+ static getChartsModel(charts, configReader, chartOrientation, designerConfig, dataModelRep, keyAxisOrient, canvasModel, keyFieldName, modelInstance) {
73
74
  const styleModel = new TwoDimensionalChartStyleModel(charts, designerConfig.chartStyle);
74
75
  const chartsModel = [];
75
76
  charts.forEach((chart, index) => {
@@ -88,7 +89,10 @@ export class TwoDimensionalModel {
88
89
  show: ({ row, valueFieldName }) => TwoDimensionalModelHelper.shouldMarkerShow(chart, dataModelRep.getRawRows(), valueFieldName, row, keyFieldName),
89
90
  styles: {
90
91
  highlighted: {
91
- size: { radius: (_e = (_d = (_c = designerConfig.canvas.markers) === null || _c === void 0 ? void 0 : _c.highlighted) === null || _d === void 0 ? void 0 : _d.radius) !== null && _e !== void 0 ? _e : 4, borderSize: '3.5px' }
92
+ size: {
93
+ radius: (_e = (_d = (_c = designerConfig.canvas.markers) === null || _c === void 0 ? void 0 : _c.highlighted) === null || _d === void 0 ? void 0 : _d.radius) !== null && _e !== void 0 ? _e : 4,
94
+ borderSize: "3.5px"
95
+ }
92
96
  },
93
97
  normal: {
94
98
  size: {
@@ -112,18 +116,20 @@ export class TwoDimensionalModel {
112
116
  handleY: (scaledValue) => valueLabelsCoordinateCalculator.getValueLabelY(scaledValue),
113
117
  handleScaledValue: (dataRow, datumField) => {
114
118
  var _a, _b, _c, _d;
115
- if (!((_b = (_a = chart.valueLabels) === null || _a === void 0 ? void 0 : _a.position) === null || _b === void 0 ? void 0 : _b.mode) || ((_d = (_c = chart.valueLabels) === null || _c === void 0 ? void 0 : _c.position) === null || _d === void 0 ? void 0 : _d.mode) === 'after')
119
+ if (!((_b = (_a = chart.valueLabels) === null || _a === void 0 ? void 0 : _a.position) === null || _b === void 0 ? void 0 : _b.mode) || ((_d = (_c = chart.valueLabels) === null || _c === void 0 ? void 0 : _c.position) === null || _d === void 0 ? void 0 : _d.mode) === "after")
116
120
  return dataRow[datumField];
117
121
  if (chart.isSegmented)
118
- return dataRow[datumField] - (dataRow[datumField] - dataRow['0']) / 2;
122
+ return dataRow[datumField] - (dataRow[datumField] - dataRow["0"]) / 2;
119
123
  else
120
124
  return dataRow[datumField] / 2;
121
125
  },
122
- textAnchor: calculateValueLabelAlignment(keyAxisOrient, (_t = (_s = chart.valueLabels) === null || _s === void 0 ? void 0 : _s.position) === null || _t === void 0 ? void 0 : _t.mode).textAnchor,
123
- dominantBaseline: calculateValueLabelAlignment(keyAxisOrient, (_v = (_u = chart.valueLabels) === null || _u === void 0 ? void 0 : _u.position) === null || _v === void 0 ? void 0 : _v.mode).dominantBaseline,
124
- format: configReader.getValueLabelFormatterForChart(index),
126
+ textAnchor: calculateValueLabelAlignment(keyAxisOrient, (_t = (_s = chart.valueLabels) === null || _s === void 0 ? void 0 : _s.position) === null || _t === void 0 ? void 0 : _t.mode)
127
+ .textAnchor,
128
+ dominantBaseline: calculateValueLabelAlignment(keyAxisOrient, (_v = (_u = chart.valueLabels) === null || _u === void 0 ? void 0 : _u.position) === null || _v === void 0 ? void 0 : _v.mode)
129
+ .dominantBaseline,
130
+ format: configReader.getValueLabelFormatterForChart(index)
125
131
  },
126
- areaViewOptions: getAreaViewOptions(chart, index, style),
132
+ areaViewOptions: getAreaViewOptions(chart, index, style, modelInstance.version.getVersionNumber()),
127
133
  dotViewOptions: {
128
134
  shape: {
129
135
  type: "line",
@@ -138,16 +144,16 @@ export class TwoDimensionalModel {
138
144
  }
139
145
  static findChartsWithEmbeddedKeyLabels(charts) {
140
146
  const chartsWithEmbeddedLabels = [];
141
- charts.forEach(chart => {
142
- if (chart.type === 'bar' && chart.embeddedLabels === 'key')
147
+ charts.forEach((chart) => {
148
+ if (chart.type === "bar" && chart.embeddedLabels === "key")
143
149
  chartsWithEmbeddedLabels.push(chart);
144
150
  });
145
151
  return chartsWithEmbeddedLabels;
146
152
  }
147
153
  static getEmbeddedLabelType(currentChart, chartOrientation) {
148
- if (chartOrientation === 'horizontal' && currentChart.type === 'bar')
154
+ if (chartOrientation === "horizontal" && currentChart.type === "bar")
149
155
  return currentChart.embeddedLabels;
150
- return 'none';
156
+ return "none";
151
157
  }
152
158
  static getAdditionalElements(options) {
153
159
  var _a, _b;
@@ -161,7 +167,4 @@ export class TwoDimensionalModel {
161
167
  }
162
168
  };
163
169
  }
164
- static getChartsByTypes(charts, types) {
165
- return charts.filter(chart => types.includes(chart.type));
166
- }
167
170
  }
package/package.json CHANGED
@@ -1,61 +1,61 @@
1
1
  {
2
- "name": "mdt-charts",
3
- "version": "1.27.0",
4
- "description": "",
5
- "main": "lib/main.js",
6
- "scripts": {
7
- "dev": "npx webpack --mode development",
8
- "build": "npx webpack --mode production",
9
- "watch": "npx webpack --mode development --watch",
10
- "test": "jest",
11
- "build-lib": "shx rm -rf lib && npm run build-ts && npm run build-style",
12
- "build-ts": "npx tsc -p tsconfig.production.json",
13
- "build-style": "shx mkdir lib/style && shx cp src/style/charts-main.css lib/style && shx cp src/style/charts-main.css lib/style/charts-main.less"
14
- },
15
- "homepage": "https://github.com/VishulaKnow/charts",
16
- "author": "",
17
- "license": "ISC",
18
- "devDependencies": {
19
- "@babel/core": "^7.12.10",
20
- "@babel/plugin-proposal-class-properties": "^7.12.1",
21
- "@babel/preset-env": "^7.12.10",
22
- "@babel/preset-typescript": "^7.12.13",
23
- "@types/chroma-js": "^2.1.3",
24
- "@types/d3-array": "^2.9.0",
25
- "@types/d3-axis": "^2.0.0",
26
- "@types/d3-ease": "^2.0.0",
27
- "@types/d3-format": "^2.0.0",
28
- "@types/d3-interpolate": "^2.0.0",
29
- "@types/d3-scale": "^3.2.2",
30
- "@types/d3-selection": "^2.0.0",
31
- "@types/d3-shape": "^2.0.0",
32
- "@types/d3-timer": "^2.0.0",
33
- "@types/d3-transition": "^2.0.0",
34
- "@types/html-webpack-plugin": "^3.2.4",
35
- "@types/jest": "^26.0.20",
36
- "clean-webpack-plugin": "^3.0.0",
37
- "css-loader": "^5.0.1",
38
- "d3-timer": "^2.0.0",
39
- "html-webpack-plugin": "^4.5.0",
40
- "jest": "^26.6.3",
41
- "shx": "^0.3.4",
42
- "style-loader": "^2.0.0",
43
- "ts-loader": "^8.0.12",
44
- "typescript": "^4.1.3",
45
- "webpack": "^5.10.1",
46
- "webpack-bundle-analyzer": "^4.4.0",
47
- "webpack-cli": "^4.2.0"
48
- },
49
- "dependencies": {
50
- "chroma-js": "^2.1.1",
51
- "d3-array": "^2.11.0",
52
- "d3-axis": "^2.0.0",
53
- "d3-ease": "^2.0.0",
54
- "d3-format": "^2.0.0",
55
- "d3-interpolate": "^2.0.1",
56
- "d3-scale": "^3.2.3",
57
- "d3-selection": "^2.0.0",
58
- "d3-shape": "^2.0.0",
59
- "d3-transition": "^2.0.0"
60
- }
2
+ "name": "mdt-charts",
3
+ "version": "1.27.2",
4
+ "description": "",
5
+ "main": "lib/main.js",
6
+ "scripts": {
7
+ "dev": "npx webpack --mode development",
8
+ "build": "npx webpack --mode production",
9
+ "watch": "npx webpack --mode development --watch",
10
+ "test": "jest",
11
+ "build-lib": "shx rm -rf lib && npm run build-ts && npm run build-style",
12
+ "build-ts": "npx tsc -p tsconfig.production.json",
13
+ "build-style": "shx mkdir lib/style && shx cp src/style/charts-main.css lib/style && shx cp src/style/charts-main.css lib/style/charts-main.less"
14
+ },
15
+ "homepage": "https://github.com/VishulaKnow/charts",
16
+ "author": "",
17
+ "license": "ISC",
18
+ "devDependencies": {
19
+ "@babel/core": "^7.12.10",
20
+ "@babel/plugin-proposal-class-properties": "^7.12.1",
21
+ "@babel/preset-env": "^7.12.10",
22
+ "@babel/preset-typescript": "^7.12.13",
23
+ "@types/chroma-js": "^2.1.3",
24
+ "@types/d3-array": "^2.9.0",
25
+ "@types/d3-axis": "^2.0.0",
26
+ "@types/d3-ease": "^2.0.0",
27
+ "@types/d3-format": "^2.0.0",
28
+ "@types/d3-interpolate": "^2.0.0",
29
+ "@types/d3-scale": "^3.2.2",
30
+ "@types/d3-selection": "^2.0.0",
31
+ "@types/d3-shape": "^2.0.0",
32
+ "@types/d3-timer": "^2.0.0",
33
+ "@types/d3-transition": "^2.0.0",
34
+ "@types/html-webpack-plugin": "^3.2.4",
35
+ "@types/jest": "^26.0.20",
36
+ "clean-webpack-plugin": "^3.0.0",
37
+ "css-loader": "^5.0.1",
38
+ "d3-timer": "^2.0.0",
39
+ "html-webpack-plugin": "^4.5.0",
40
+ "jest": "^26.6.3",
41
+ "shx": "^0.3.4",
42
+ "style-loader": "^2.0.0",
43
+ "ts-loader": "^8.0.12",
44
+ "typescript": "^4.1.3",
45
+ "webpack": "^5.10.1",
46
+ "webpack-bundle-analyzer": "^4.4.0",
47
+ "webpack-cli": "^4.2.0"
48
+ },
49
+ "dependencies": {
50
+ "chroma-js": "^2.1.1",
51
+ "d3-array": "^2.11.0",
52
+ "d3-axis": "^2.0.0",
53
+ "d3-ease": "^2.0.0",
54
+ "d3-format": "^2.0.0",
55
+ "d3-interpolate": "^2.0.1",
56
+ "d3-scale": "^3.2.3",
57
+ "d3-selection": "^2.0.0",
58
+ "d3-shape": "^2.0.0",
59
+ "d3-transition": "^2.0.0"
60
+ }
61
61
  }
@@ -1,25 +1,15 @@
1
1
  {
2
- "compilerOptions": {
3
- "outDir": "./lib/",
4
- "noImplicitAny": true,
5
- "target": "es6",
6
- "lib": ["ES2017", "DOM"],
7
- "jsx": "react",
8
- "allowJs": true,
9
- "types": [
10
- "jest"
11
- ],
12
- "declaration": true,
13
- "moduleResolution": "Node"
14
- },
15
- "include": [
16
- "src"
17
- ],
18
- "exclude": [
19
- "node_modules",
20
- "**/__tests__/*",
21
- "src/playground/*",
22
- "**/*Example.ts",
23
- "**/*.test.ts"
24
- ]
25
- }
2
+ "compilerOptions": {
3
+ "outDir": "./lib/",
4
+ "noImplicitAny": true,
5
+ "target": "es6",
6
+ "lib": ["ES2017", "DOM"],
7
+ "jsx": "react",
8
+ "allowJs": true,
9
+ "types": ["jest"],
10
+ "declaration": true,
11
+ "moduleResolution": "Node"
12
+ },
13
+ "include": ["src"],
14
+ "exclude": ["node_modules", "**/__tests__/*", "src/playground/*", "**/*Example.ts", "**/*.test.ts"]
15
+ }
package/README.md DELETED
@@ -1,2 +0,0 @@
1
- # Charts
2
- **Demo**: https://vishulaknow.github.io/charts-demo/