mdt-charts 1.12.12 → 1.12.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/lib/config/config.d.ts +2 -2
  2. package/lib/engine/contentManager/contentManager.d.ts +9 -0
  3. package/lib/engine/contentManager/contentManager.js +15 -0
  4. package/lib/engine/contentManager/contentManagerFactory.d.ts +14 -0
  5. package/lib/engine/contentManager/contentManagerFactory.js +20 -0
  6. package/lib/engine/engine.js +4 -4
  7. package/lib/engine/features/tolltip/newTooltip/newTooltip.js +1 -1
  8. package/lib/engine/features/tolltip/tooltip.d.ts +4 -4
  9. package/lib/engine/features/tolltip/tooltip.js +4 -4
  10. package/lib/engine/polarNotation/polarManager.d.ts +6 -5
  11. package/lib/engine/polarNotation/polarManager.js +4 -4
  12. package/lib/engine/twoDimensionalNotation/twoDimensionalManager.d.ts +7 -6
  13. package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +5 -5
  14. package/lib/model/dataManagerModel/dataManagerModel.js +2 -0
  15. package/lib/model/featuresModel/legendModel/legendModel.d.ts +2 -1
  16. package/lib/model/featuresModel/legendModel/legendModel.js +9 -2
  17. package/lib/model/featuresModel/legendModel/polarMarginCalculator.js +2 -3
  18. package/lib/model/featuresModel/legendModel/twoDimLegendModel.d.ts +2 -1
  19. package/lib/model/featuresModel/legendModel/twoDimLegendModel.js +7 -6
  20. package/lib/model/featuresModel/scaleModel/scaleAxisRecalcer.js +3 -1
  21. package/lib/model/featuresModel/scaleModel/scaleDomainService.d.ts +6 -0
  22. package/lib/model/featuresModel/scaleModel/scaleDomainService.js +53 -0
  23. package/lib/model/featuresModel/scaleModel/scaleModel.d.ts +5 -12
  24. package/lib/model/featuresModel/scaleModel/scaleModel.js +11 -94
  25. package/lib/model/featuresModel/scaleModel/scaleModelServices.d.ts +5 -0
  26. package/lib/model/featuresModel/scaleModel/scaleModelServices.js +22 -0
  27. package/lib/model/margin/marginModel.d.ts +5 -6
  28. package/lib/model/margin/marginModel.js +10 -16
  29. package/lib/model/margin/twoDim/twoDimMarginModel.js +1 -1
  30. package/lib/model/modelBuilder.js +3 -2
  31. package/lib/model/modelInstance/canvasModel/canvasModel.d.ts +4 -3
  32. package/lib/model/modelInstance/canvasModel/canvasModel.js +1 -1
  33. package/lib/model/modelInstance/canvasModel/canvasSizesModel/canvasMarginModel.d.ts +11 -0
  34. package/lib/{engine/features/tolltip/newTooltip/newTooltip.test.d.ts → model/modelInstance/canvasModel/canvasSizesModel/canvasMarginModel.js} +0 -0
  35. package/lib/model/modelInstance/canvasModel/canvasSizesModel/canvasSizeModel.d.ts +4 -0
  36. package/lib/{engine/twoDimensionalNotation/bar/stackedData/dataStacker.test.d.ts → model/modelInstance/canvasModel/canvasSizesModel/canvasSizeModel.js} +0 -0
  37. package/lib/model/modelInstance/canvasModel/canvasSizesModel/marginModelService.d.ts +11 -0
  38. package/lib/model/modelInstance/canvasModel/canvasSizesModel/marginModelService.js +26 -0
  39. package/lib/model/modelInstance/canvasModel/titleCanvas.js +1 -1
  40. package/lib/model/notations/intervalModel.js +3 -4
  41. package/lib/model/notations/polar/donut/donutAggregatorService.d.ts +1 -0
  42. package/lib/model/notations/polar/donut/donutAggregatorService.js +19 -4
  43. package/lib/model/notations/twoDimensionalModel.js +3 -2
  44. package/lib/style/charts-main.css +9 -9
  45. package/lib/style/charts-main.less +9 -9
  46. package/package.json +1 -1
  47. package/tsconfig.production.json +2 -1
  48. package/lib/engine/features/tolltip/newTooltip/newTooltip.test.js +0 -186
  49. package/lib/engine/twoDimensionalNotation/bar/stackedData/dataStacker.test.js +0 -199
  50. package/lib/model/featuresModel/scaleModel.d.ts +0 -19
  51. package/lib/model/featuresModel/scaleModel.js +0 -115
  52. package/lib/model/marginModel.d.ts +0 -17
  53. package/lib/model/marginModel.js +0 -80
  54. package/lib/model/modelHelper.d.ts +0 -7
  55. package/lib/model/modelHelper.js +0 -41
  56. package/lib/model/modelInstance/dataModel.d.ts +0 -11
  57. package/lib/model/modelInstance/dataModel.js +0 -23
  58. package/lib/model/notations/polarModel.d.ts +0 -15
  59. package/lib/model/notations/polarModel.js +0 -59
@@ -1,11 +1,10 @@
1
1
  import { MdtChartsConfig, MdtChartsDataSource, MdtChartsTwoDimensionalOptions } from "../../config/config";
2
2
  import { DesignerConfig } from "../../designer/designerConfig";
3
- import { LegendBlockModel, Orient, OtherCommonComponents } from "../model";
3
+ import { OtherCommonComponents } from "../model";
4
4
  import { ModelInstance } from "../modelInstance/modelInstance";
5
- import { CanvasModel } from "../modelInstance/canvasModel/canvasModel";
6
5
  export declare class MarginModel {
7
- static initMargin(designerConfig: DesignerConfig, config: MdtChartsConfig, otherComponents: OtherCommonComponents, data: MdtChartsDataSource, modelInstance: ModelInstance): void;
8
- static recalcMarginByVerticalAxisLabel(modelInstance: ModelInstance, options: MdtChartsTwoDimensionalOptions, designerConfig: DesignerConfig): void;
9
- static appendToGlobalMarginValuesLegendMargin(canvasModel: CanvasModel, position: Orient, legendBlockModel: LegendBlockModel): void;
10
- private static recalcMarginByTitle;
6
+ private twoDimModel;
7
+ initMargin(designerConfig: DesignerConfig, config: MdtChartsConfig, otherComponents: OtherCommonComponents, data: MdtChartsDataSource, modelInstance: ModelInstance): void;
8
+ recalcMarginByVerticalAxisLabel(modelInstance: ModelInstance, options: MdtChartsTwoDimensionalOptions, designerConfig: DesignerConfig): void;
9
+ private recalcMarginByTitle;
11
10
  }
@@ -1,26 +1,20 @@
1
1
  import { TwoDimMarginModel } from "./twoDim/twoDimMarginModel";
2
2
  export class MarginModel {
3
- static initMargin(designerConfig, config, otherComponents, data, modelInstance) {
3
+ constructor() {
4
+ this.twoDimModel = new TwoDimMarginModel();
5
+ }
6
+ initMargin(designerConfig, config, otherComponents, data, modelInstance) {
4
7
  const canvasModel = modelInstance.canvasModel;
5
8
  canvasModel.initMargin(Object.assign({}, designerConfig.canvas.chartBlockMargin));
6
- this.recalcMarginByTitle(canvasModel, otherComponents.titleBlock);
9
+ this.recalcMarginByTitle(canvasModel);
7
10
  if (config.options.type === '2d') {
8
- const twoDimModel = new TwoDimMarginModel();
9
- twoDimModel.recalcMargin(designerConfig, config.options, otherComponents, data, modelInstance);
11
+ this.twoDimModel.recalcMargin(designerConfig, config.options, otherComponents, data, modelInstance);
10
12
  }
11
13
  }
12
- static recalcMarginByVerticalAxisLabel(modelInstance, options, designerConfig) {
13
- const twoDimModel = new TwoDimMarginModel();
14
- twoDimModel.recalcMarginByVerticalAxisLabel(modelInstance, options, designerConfig);
15
- }
16
- static appendToGlobalMarginValuesLegendMargin(canvasModel, position, legendBlockModel) {
17
- const legendCoordinate = legendBlockModel.coordinate;
18
- if (position === 'left' || position === 'right')
19
- canvasModel.increaseMarginSide(position, legendCoordinate[position].margin.left + legendCoordinate[position].margin.right);
20
- else
21
- canvasModel.increaseMarginSide(position, legendCoordinate[position].margin.top + legendCoordinate[position].margin.bottom);
14
+ recalcMarginByVerticalAxisLabel(modelInstance, options, designerConfig) {
15
+ this.twoDimModel.recalcMarginByVerticalAxisLabel(modelInstance, options, designerConfig);
22
16
  }
23
- static recalcMarginByTitle(canvasModel, titleBlockModel) {
24
- canvasModel.increaseMarginSide("top", titleBlockModel.margin.top + titleBlockModel.size + titleBlockModel.margin.bottom);
17
+ recalcMarginByTitle(canvasModel) {
18
+ canvasModel.increaseMarginSide("top", canvasModel.titleCanvas.getAllNeededSpace());
25
19
  }
26
20
  }
@@ -12,7 +12,7 @@ export class TwoDimMarginModel {
12
12
  }
13
13
  recalcMargin(designerConfig, options, otherComponents, data, modelInstance) {
14
14
  const canvasModel = modelInstance.canvasModel;
15
- this.twoDimLegendModel.recalcMarginWith2DLegend(modelInstance, otherComponents.legendBlock);
15
+ this.twoDimLegendModel.recalcMarginWith2DLegend(modelInstance, otherComponents.legendBlock, options.legend);
16
16
  const labelSize = this.getHorizontalMarginByAxisLabels(designerConfig.canvas.axisLabel.maxSize.main, options.axis, data, options);
17
17
  this.recalcVerticalMarginByAxisLabelHeight(labelSize, canvasModel, options.orientation, options.axis);
18
18
  // Если встроенный лейбл показывает ключи, то лейблы оси ключей не показываются
@@ -68,10 +68,11 @@ export function assembleModel(config, data, designerConfig) {
68
68
  };
69
69
  resetFalsyValues(data, config.options.data.keyField.name);
70
70
  const otherComponents = OtherComponentsModel.getOtherComponentsModel({ elementsOptions: designerConfig.elementsOptions, title: config.options.title }, modelInstance);
71
- MarginModel.initMargin(designerConfig, config, otherComponents, data, modelInstance);
71
+ const marginModel = new MarginModel();
72
+ marginModel.initMargin(designerConfig, config, otherComponents, data, modelInstance);
72
73
  DataManagerModel.initDataScope(config, data, designerConfig, otherComponents.legendBlock, modelInstance);
73
74
  if (config.options.type === '2d' && config.options.axis.key.visibility)
74
- MarginModel.recalcMarginByVerticalAxisLabel(modelInstance, config.options, designerConfig);
75
+ marginModel.recalcMarginByVerticalAxisLabel(modelInstance, config.options, designerConfig);
75
76
  const blockCanvas = getBlockCanvas(config, modelInstance);
76
77
  const chartBlock = getChartBlockModel(modelInstance);
77
78
  const options = getOptions(config, designerConfig, modelInstance);
@@ -1,10 +1,11 @@
1
1
  import { Size } from "../../../config/config";
2
2
  import { BlockMargin } from "../../model";
3
3
  import { LegendCanvasModelInstance } from "./legendCanvasModel";
4
- import { MarginModelService } from "./marginModelService";
4
+ import { CanvasMarginModel, MarginSide } from "./canvasSizesModel/canvasMarginModel";
5
+ import { MarginModelService } from "./canvasSizesModel/marginModelService";
5
6
  import { TitleCanvasModel } from "./titleCanvas";
6
- export declare type MarginSide = keyof BlockMargin;
7
- export declare class CanvasModel {
7
+ import { CanvasSizesModel } from "./canvasSizesModel/canvasSizeModel";
8
+ export declare class CanvasModel implements CanvasMarginModel, CanvasSizesModel {
8
9
  titleCanvas: TitleCanvasModel;
9
10
  legendCanvas: LegendCanvasModelInstance;
10
11
  marginService: MarginModelService;
@@ -1,5 +1,5 @@
1
1
  import { LegendCanvasModelInstance } from "./legendCanvasModel";
2
- import { MarginModelService } from "./marginModelService";
2
+ import { MarginModelService } from "./canvasSizesModel/marginModelService";
3
3
  import { TitleCanvasModel } from "./titleCanvas";
4
4
  export class CanvasModel {
5
5
  constructor() {
@@ -0,0 +1,11 @@
1
+ import { BlockMargin } from "../../../model";
2
+ export declare type MarginSide = keyof BlockMargin;
3
+ export interface CanvasMarginModel {
4
+ initMargin(margin: BlockMargin): void;
5
+ getMargin(): BlockMargin;
6
+ getMarginSide(side: MarginSide): number;
7
+ setMarginSide(side: MarginSide, size: number): void;
8
+ increaseMarginSide(side: MarginSide, byValue: number, key?: string): void;
9
+ decreaseMarginSide(side: MarginSide, byValue: number): void;
10
+ roundMargin(): void;
11
+ }
@@ -0,0 +1,4 @@
1
+ export interface CanvasSizesModel {
2
+ getChartBlockWidth(): number;
3
+ getChartBlockHeight(): number;
4
+ }
@@ -0,0 +1,11 @@
1
+ import { MarginSide } from "./canvasMarginModel";
2
+ export interface MarginLogData {
3
+ side: MarginSide;
4
+ byValue: number;
5
+ }
6
+ export declare class MarginModelService {
7
+ private log;
8
+ appendLog(key: string, side: MarginSide, byValue: number): void;
9
+ getDataByKey(key: string): MarginLogData;
10
+ private findLogByKey;
11
+ }
@@ -0,0 +1,26 @@
1
+ export class MarginModelService {
2
+ constructor() {
3
+ this.log = [];
4
+ }
5
+ appendLog(key, side, byValue) {
6
+ const log = this.findLogByKey(key);
7
+ if (log) {
8
+ log.data = { side, byValue };
9
+ return;
10
+ }
11
+ this.log.push({
12
+ key,
13
+ data: {
14
+ side,
15
+ byValue
16
+ }
17
+ });
18
+ }
19
+ getDataByKey(key) {
20
+ var _a;
21
+ return (_a = this.findLogByKey(key)) === null || _a === void 0 ? void 0 : _a.data;
22
+ }
23
+ findLogByKey(key) {
24
+ return this.log.find(l => l.key === key);
25
+ }
26
+ }
@@ -6,6 +6,6 @@ export class TitleCanvasModel {
6
6
  return this.model;
7
7
  }
8
8
  getAllNeededSpace() {
9
- return this.model.pad + this.model.size + this.model.margin.top;
9
+ return this.model.pad + this.model.size + this.model.margin.top + this.model.margin.bottom;
10
10
  }
11
11
  }
@@ -2,7 +2,6 @@ import { AxisModel } from "../featuresModel/axisModel";
2
2
  import { ChartStyleModelService } from "../chartStyleModel/chartStyleModel";
3
3
  import { DataManagerModel } from "../dataManagerModel/dataManagerModel";
4
4
  import { AxisType } from "../modelBuilder";
5
- import { ScaleModel, ScaleType } from "../featuresModel/scaleModel/scaleModel";
6
5
  import { TwoDimensionalModel } from "./twoDimensionalModel";
7
6
  export class IntervalModel {
8
7
  static getOptions(options, designerConfig, modelInstance) {
@@ -18,16 +17,16 @@ export class IntervalModel {
18
17
  domain: modelInstance.dataModel.getAllowableKeys(),
19
18
  range: {
20
19
  start: 0,
21
- end: ScaleModel.getRangePeek(ScaleType.Key, options.orientation, canvasModel)
20
+ end: 0
22
21
  },
23
22
  type: 'band',
24
23
  elementsAmount: 1
25
24
  },
26
25
  value: {
27
- domain: ScaleModel.getDateValueDomain(dataModelRep.getScopedFullSource(), options.chart, options.axis.key.position, options.data.dataSource),
26
+ domain: [],
28
27
  range: {
29
28
  start: 0,
30
- end: ScaleModel.getRangePeek(ScaleType.Value, options.orientation, canvasModel)
29
+ end: 0
31
30
  },
32
31
  type: 'datetime'
33
32
  }
@@ -9,4 +9,5 @@ export declare class DonutAggregatorService {
9
9
  getContent(aggregatorOptions: MdtChartsDonutAggregator, dataOptions: AggregatorServiceDataOptions): DonutAggregatorContent;
10
10
  private doesValueExist;
11
11
  private generateDefaultContent;
12
+ private getDefaultValue;
12
13
  }
@@ -4,14 +4,25 @@ export class DonutAggregatorService {
4
4
  if (!(aggregatorOptions === null || aggregatorOptions === void 0 ? void 0 : aggregatorOptions.content) || !dataOptions.rows)
5
5
  return this.generateDefaultContent(dataOptions);
6
6
  const content = aggregatorOptions.content({ data: dataOptions.rows });
7
- if (this.doesValueExist(content.value) && content.title)
8
- return content;
7
+ if (!content || (!this.doesValueExist(content.value) && !content.title))
8
+ return this.generateDefaultContent(dataOptions);
9
+ if (this.doesValueExist(content.value) && content.title) {
10
+ return {
11
+ title: content.title,
12
+ value: content.value
13
+ };
14
+ }
9
15
  if (!content.title && this.doesValueExist(content.value))
10
16
  return {
11
17
  value: content.value,
12
18
  title: AGGREGATOR_DEFAULT_TITLE
13
19
  };
14
- return this.generateDefaultContent(dataOptions);
20
+ if (!this.doesValueExist(content.value) && content.title) {
21
+ return {
22
+ value: this.getDefaultValue(dataOptions),
23
+ title: content.title
24
+ };
25
+ }
15
26
  }
16
27
  doesValueExist(content) {
17
28
  return content != null;
@@ -19,7 +30,11 @@ export class DonutAggregatorService {
19
30
  generateDefaultContent(dataOptions) {
20
31
  return {
21
32
  title: AGGREGATOR_DEFAULT_TITLE,
22
- value: dataOptions.rows ? dataOptions.rows.reduce((acc, row) => acc + row[dataOptions.valueFieldName], 0) : 0
33
+ value: dataOptions.rows ? this.getDefaultValue(dataOptions) : 0
23
34
  };
24
35
  }
36
+ getDefaultValue(dataOptions) {
37
+ const totalSumOfValues = dataOptions.rows.reduce((acc, row) => acc + row[dataOptions.valueFieldName], 0);
38
+ return totalSumOfValues;
39
+ }
25
40
  }
@@ -7,7 +7,8 @@ export class TwoDimensionalModel {
7
7
  static getOptions(options, designerConfig, modelInstance) {
8
8
  const canvasModel = modelInstance.canvasModel;
9
9
  const dataModelRep = modelInstance.dataModel.repository;
10
- const scaleMarginRecalcer = new ScaleAxisRecalcer(() => ScaleModel.getScaleLinear(options, dataModelRep.getScopedRows(), canvasModel));
10
+ const scaleModel = new ScaleModel();
11
+ const scaleMarginRecalcer = new ScaleAxisRecalcer(() => scaleModel.getScaleLinear(options, dataModelRep.getScopedRows(), canvasModel));
11
12
  scaleMarginRecalcer.recalculateMargin(canvasModel, options.orientation, options.axis.key);
12
13
  const scaleValueInfo = scaleMarginRecalcer.getScaleValue();
13
14
  return {
@@ -16,7 +17,7 @@ export class TwoDimensionalModel {
16
17
  selectable: !!options.selectable,
17
18
  orient: options.orientation,
18
19
  scale: {
19
- key: ScaleModel.getScaleKey(modelInstance.dataModel.getAllowableKeys(), options.orientation, canvasModel, options.charts, this.getChartsByType(options.charts, 'bar')),
20
+ key: scaleModel.getScaleKey(modelInstance.dataModel.getAllowableKeys(), options.orientation, canvasModel, options.charts, this.getChartsByType(options.charts, 'bar')),
20
21
  value: scaleValueInfo.scale
21
22
  },
22
23
  axis: {
@@ -109,14 +109,14 @@
109
109
 
110
110
 
111
111
  /*========================================================================= Tooltip */
112
- .tooltip-block {
112
+ .mdt-charts-tooltip-block {
113
113
  pointer-events: none;
114
114
  z-index: 100;
115
115
  filter: drop-shadow(0px 4px 10px rgba(0, 0, 0, 0.1));
116
116
  width: max-content;
117
117
  max-width: 500px;
118
118
  }
119
- .tooltip-content {
119
+ .mdt-charts-tooltip-content {
120
120
  position: relative;
121
121
  pointer-events: none;
122
122
  font-family: "Roboto", sans-serif;
@@ -128,7 +128,7 @@
128
128
  background: rgba(0, 0, 0, 0.82);
129
129
  font-size: 11px;
130
130
  }
131
- .tooltip-arrow {
131
+ .mdt-charts-tooltip-arrow {
132
132
  width: 0;
133
133
  height: 0;
134
134
  border-style: solid;
@@ -159,26 +159,26 @@
159
159
  font-weight: 400;
160
160
  }
161
161
 
162
- .tooltip-line {
162
+ .mdt-charts-tooltip-line {
163
163
  stroke: #AAA;
164
164
  stroke-width: 1px;
165
165
  stroke-linecap: round;
166
166
  }
167
- .tooltip-content .tooltip-head {
167
+ .mdt-charts-tooltip-content .tooltip-head {
168
168
  font-size: 12px;
169
169
  margin-bottom: 10px;
170
170
  }
171
- .tooltip-content .tooltip-texts {
171
+ .mdt-charts-tooltip-content .tooltip-texts {
172
172
  width: 100%;
173
173
  }
174
174
 
175
- .tooltip-content .tooltip-text-item > span {
175
+ .mdt-charts-tooltip-content .tooltip-text-item > span {
176
176
  display: block;
177
177
  }
178
- .tooltip-content .tooltip-text-item > span:first-of-type {
178
+ .mdt-charts-tooltip-content .tooltip-text-item > span:first-of-type {
179
179
  flex: 1;
180
180
  }
181
- .tooltip-content .tooltip-text-item > span:last-of-type {
181
+ .mdt-charts-tooltip-content .tooltip-text-item > span:last-of-type {
182
182
  flex: 0;
183
183
  }
184
184
  .tooltip-field-value {
@@ -109,14 +109,14 @@
109
109
 
110
110
 
111
111
  /*========================================================================= Tooltip */
112
- .tooltip-block {
112
+ .mdt-charts-tooltip-block {
113
113
  pointer-events: none;
114
114
  z-index: 100;
115
115
  filter: drop-shadow(0px 4px 10px rgba(0, 0, 0, 0.1));
116
116
  width: max-content;
117
117
  max-width: 500px;
118
118
  }
119
- .tooltip-content {
119
+ .mdt-charts-tooltip-content {
120
120
  position: relative;
121
121
  pointer-events: none;
122
122
  font-family: "Roboto", sans-serif;
@@ -128,7 +128,7 @@
128
128
  background: rgba(0, 0, 0, 0.82);
129
129
  font-size: 11px;
130
130
  }
131
- .tooltip-arrow {
131
+ .mdt-charts-tooltip-arrow {
132
132
  width: 0;
133
133
  height: 0;
134
134
  border-style: solid;
@@ -159,26 +159,26 @@
159
159
  font-weight: 400;
160
160
  }
161
161
 
162
- .tooltip-line {
162
+ .mdt-charts-tooltip-line {
163
163
  stroke: #AAA;
164
164
  stroke-width: 1px;
165
165
  stroke-linecap: round;
166
166
  }
167
- .tooltip-content .tooltip-head {
167
+ .mdt-charts-tooltip-content .tooltip-head {
168
168
  font-size: 12px;
169
169
  margin-bottom: 10px;
170
170
  }
171
- .tooltip-content .tooltip-texts {
171
+ .mdt-charts-tooltip-content .tooltip-texts {
172
172
  width: 100%;
173
173
  }
174
174
 
175
- .tooltip-content .tooltip-text-item > span {
175
+ .mdt-charts-tooltip-content .tooltip-text-item > span {
176
176
  display: block;
177
177
  }
178
- .tooltip-content .tooltip-text-item > span:first-of-type {
178
+ .mdt-charts-tooltip-content .tooltip-text-item > span:first-of-type {
179
179
  flex: 1;
180
180
  }
181
- .tooltip-content .tooltip-text-item > span:last-of-type {
181
+ .mdt-charts-tooltip-content .tooltip-text-item > span:last-of-type {
182
182
  flex: 0;
183
183
  }
184
184
  .tooltip-field-value {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mdt-charts",
3
- "version": "1.12.12",
3
+ "version": "1.12.16",
4
4
  "description": "",
5
5
  "main": "lib/main.js",
6
6
  "scripts": {
@@ -18,6 +18,7 @@
18
18
  "node_modules",
19
19
  "**/__tests__/*",
20
20
  "src/playground/*",
21
- "**/*Example.ts"
21
+ "**/*Example.ts",
22
+ "**/*.test.ts"
22
23
  ]
23
24
  }
@@ -1,186 +0,0 @@
1
- import { NewTooltipServiceClass } from "./newTooltipService";
2
- const ignoredValue = 0;
3
- const ignoredBigvalue = 1000000;
4
- describe('newTooltipService', () => {
5
- const getIgnoredSize = (big) => {
6
- return {
7
- height: big ? ignoredBigvalue : ignoredValue,
8
- width: big ? ignoredBigvalue : ignoredValue
9
- };
10
- };
11
- const getSizeWithOne = (key, value) => {
12
- const size = getIgnoredSize();
13
- size[key] = value;
14
- return size;
15
- };
16
- const getPosWithOne = (key, value) => {
17
- const coordinate = {
18
- left: ignoredValue,
19
- top: ignoredValue
20
- };
21
- coordinate[key] = value;
22
- return coordinate;
23
- };
24
- const getBoundingWithOne = (key, value) => {
25
- const blockBounding = {
26
- left: ignoredValue,
27
- bottom: ignoredValue,
28
- height: ignoredValue,
29
- top: ignoredValue,
30
- width: ignoredValue
31
- };
32
- blockBounding[key] = value;
33
- return blockBounding;
34
- };
35
- const service = new NewTooltipServiceClass();
36
- describe('getTooltipByWindow with parentBlock', () => {
37
- test('should return left point equal to `-(left of parent block)` if left of tooltip is less', () => {
38
- const tooltipBounding = getIgnoredSize();
39
- const preCoordinate = getPosWithOne("left", -50);
40
- const windowSize = getIgnoredSize(true);
41
- const blockBounding = getBoundingWithOne("left", 10);
42
- const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
43
- expect(res.left).toBe(-blockBounding.left);
44
- });
45
- test('should return left point equal to left of preCoordinate if left of tooltip is less', () => {
46
- const tooltipBounding = getIgnoredSize();
47
- const preCoordinate = getPosWithOne("left", 20);
48
- const windowSize = getIgnoredSize(true);
49
- const blockBounding = getBoundingWithOne("left", 10);
50
- const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
51
- expect(res.left).toBe(preCoordinate.left);
52
- });
53
- test('should return left point equal to `(window width - tooltip width)` if right of tooltip is bigger', () => {
54
- const tooltipBounding = getSizeWithOne("width", 50);
55
- const preCoordinate = getPosWithOne("left", 20);
56
- const windowSize = getSizeWithOne("width", 90);
57
- const blockBounding = getBoundingWithOne("left", 30);
58
- const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
59
- expect(res.left).toBe(-8); // 50 + 20 + 30 > 90 => 90 - 30 - 50 - scrollPad(18)
60
- });
61
- test('should return left point equal to left of preCoordinate if right of tooltip is less than window width', () => {
62
- const tooltipBounding = getSizeWithOne("width", 50);
63
- const preCoordinate = getPosWithOne("left", 20);
64
- const windowSize = getSizeWithOne("width", 200);
65
- const blockBounding = getBoundingWithOne("left", 30);
66
- const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
67
- expect(res.left).toBe(preCoordinate.left); // 50 + 20 + 30 < 200
68
- });
69
- test('should return top point equal to `-(top of parent block)` if top of tooltip is less', () => {
70
- const tooltipBounding = getIgnoredSize();
71
- const preCoordinate = getPosWithOne("top", -40);
72
- const windowSize = getIgnoredSize(true);
73
- const blockBounding = getBoundingWithOne("top", -20);
74
- let res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
75
- expect(res.top).toBe(-blockBounding.top);
76
- blockBounding.top = -60;
77
- res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
78
- expect(res.top).toBe(-blockBounding.top); // 60 by blockBounding = 0 by window
79
- blockBounding.top = -100;
80
- preCoordinate.top = 20;
81
- res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
82
- expect(res.top).toBe(-blockBounding.top);
83
- blockBounding.top = -10;
84
- preCoordinate.top = 5;
85
- res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
86
- expect(res.top).toBe(-blockBounding.top);
87
- });
88
- test('should return top point equal top of preCoordinate if top of tooltip is bigger', () => {
89
- const tooltipBounding = getIgnoredSize();
90
- const preCoordinate = getPosWithOne("top", 20);
91
- const windowSize = getIgnoredSize(true);
92
- const blockBounding = getBoundingWithOne("top", 100);
93
- let res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
94
- expect(res.top).toBe(preCoordinate.top);
95
- preCoordinate.top = -99;
96
- res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
97
- expect(res.top).toBe(preCoordinate.top);
98
- });
99
- test('should return top point equal to `(winHeight - tooltipHeight)` if bottom of tooltip is bigger than window height', () => {
100
- const tooltipBounding = getSizeWithOne("height", 50);
101
- const preCoordinate = getPosWithOne("top", 90);
102
- const windowSize = getSizeWithOne("height", 200);
103
- const blockBounding = {
104
- left: ignoredValue,
105
- bottom: 210,
106
- height: 110,
107
- top: 100,
108
- width: ignoredValue
109
- };
110
- const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
111
- expect(res.top).toBe(50); // 110 - 50 - (210 - 200)
112
- });
113
- test('should return top point equal to top of preCoordinate if bottom of tooltip is less than height of window', () => {
114
- const tooltipBounding = getSizeWithOne("height", 50);
115
- const preCoordinate = getPosWithOne("top", 90);
116
- const windowSize = getSizeWithOne("height", 300);
117
- const blockBounding = {
118
- left: ignoredValue,
119
- bottom: 210,
120
- height: 110,
121
- top: 100,
122
- width: ignoredValue
123
- };
124
- const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
125
- expect(res.top).toBe(preCoordinate.top); // 90 + 50 + 100 < 300
126
- });
127
- });
128
- describe('getTooltipByWindow without parentBlock', () => {
129
- test('should return left point equal to 0 if left of tooltip is less', () => {
130
- const tooltipBounding = getIgnoredSize();
131
- const preCoordinate = getPosWithOne("left", -50);
132
- const windowSize = getIgnoredSize(true);
133
- const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize);
134
- expect(res.left === 0).toBe(true); // negative zero jest not matching with simple zero
135
- });
136
- test('should return left point equal to left of preCoordinate if left of tooltip is bigger than 0', () => {
137
- const tooltipBounding = getIgnoredSize();
138
- const preCoordinate = getPosWithOne("left", 20);
139
- const windowSize = getIgnoredSize(true);
140
- const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize);
141
- expect(res.left).toBe(preCoordinate.left);
142
- });
143
- test('should return left point equal to `(window width - tooltip width)` if right of tooltip is bigger', () => {
144
- const tooltipBounding = getSizeWithOne("width", 50);
145
- const preCoordinate = getPosWithOne("left", 60);
146
- const windowSize = getSizeWithOne("width", 100);
147
- const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize);
148
- expect(res.left).toBe(32); // 60 + 50 > 100 => 100 - 50 - scrollPad(18)
149
- });
150
- test('should return left point equal to left of preCoordinate if right of tooltip is less than window width', () => {
151
- const tooltipBounding = getSizeWithOne("width", 50);
152
- const preCoordinate = getPosWithOne("left", 20);
153
- const windowSize = getSizeWithOne("width", 200);
154
- const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize);
155
- expect(res.left).toBe(preCoordinate.left); // 50 + 20 < 200
156
- });
157
- test('should return top point equal to 0 if top of tooltip is less than 0', () => {
158
- const tooltipBounding = getIgnoredSize();
159
- const preCoordinate = getPosWithOne("top", -40);
160
- const windowSize = getIgnoredSize(true);
161
- const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize);
162
- expect(res.top === 0).toBe(true);
163
- });
164
- test('should return top point equal top of preCoordinate if top of tooltip is bigger than 0', () => {
165
- const tooltipBounding = getIgnoredSize();
166
- const preCoordinate = getPosWithOne("top", 20);
167
- const windowSize = getIgnoredSize(true);
168
- const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize);
169
- expect(res.top).toBe(preCoordinate.top);
170
- });
171
- test('should return top point equal to `(winHeight - tooltipHeight)` if bottom of tooltip is bigger than window height', () => {
172
- const tooltipBounding = getSizeWithOne("height", 50);
173
- const preCoordinate = getPosWithOne("top", 90);
174
- const windowSize = getSizeWithOne("height", 100);
175
- const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize);
176
- expect(res.top).toBe(50); // 90 + 50 > 100 => 100 - 50
177
- });
178
- test('should return top point equal to top of preCoordinate if bottom of tooltip is less than height of window', () => {
179
- const tooltipBounding = getSizeWithOne("height", 50);
180
- const preCoordinate = getPosWithOne("top", 90);
181
- const windowSize = getSizeWithOne("height", 300);
182
- const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize);
183
- expect(res.top).toBe(preCoordinate.top); // 90 + 50 < 300
184
- });
185
- });
186
- });