mdt-charts 1.20.0 → 1.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/lib/config/config.d.ts +25 -0
  2. package/lib/engine/block/blockSvg.d.ts +1 -1
  3. package/lib/engine/block/blockSvg.js +1 -1
  4. package/lib/engine/block/defs/LinearGradientDef.d.ts +6 -0
  5. package/lib/engine/block/defs/LinearGradientDef.js +28 -0
  6. package/lib/engine/elementHighlighter/elementHighlighter.d.ts +0 -1
  7. package/lib/engine/elementHighlighter/elementHighlighter.js +5 -8
  8. package/lib/engine/elementHighlighter/selectHighlighter.js +11 -10
  9. package/lib/engine/features/legend/legendMarkerCreator.js +1 -1
  10. package/lib/engine/features/markDots/markDot.d.ts +11 -3
  11. package/lib/engine/features/markDots/markDot.js +21 -10
  12. package/lib/engine/features/tolltip/tooltip.js +5 -4
  13. package/lib/engine/features/valueLabels/valueLabels.d.ts +45 -0
  14. package/lib/engine/features/valueLabels/valueLabels.js +139 -0
  15. package/lib/engine/features/valueLabels/valueLabelsHelper.d.ts +6 -0
  16. package/lib/engine/features/valueLabels/valueLabelsHelper.js +21 -0
  17. package/lib/engine/features/valueLabelsCollision/valueLabelsCollision.d.ts +23 -0
  18. package/lib/engine/features/valueLabelsCollision/valueLabelsCollision.js +24 -0
  19. package/lib/engine/features/valueLabelsCollision/valueLabelsCollisionHelper.d.ts +5 -0
  20. package/lib/engine/features/valueLabelsCollision/valueLabelsCollisionHelper.js +47 -0
  21. package/lib/engine/helpers/domHelper.d.ts +1 -0
  22. package/lib/engine/helpers/domHelper.js +4 -0
  23. package/lib/engine/twoDimensionalNotation/area/area.d.ts +26 -11
  24. package/lib/engine/twoDimensionalNotation/area/area.js +100 -34
  25. package/lib/engine/twoDimensionalNotation/area/areaGenerator.d.ts +14 -0
  26. package/lib/engine/twoDimensionalNotation/area/areaGenerator.js +22 -0
  27. package/lib/engine/twoDimensionalNotation/area/areaHelper.d.ts +7 -7
  28. package/lib/engine/twoDimensionalNotation/area/areaHelper.js +30 -31
  29. package/lib/engine/twoDimensionalNotation/bar/barHelper.js +1 -1
  30. package/lib/engine/twoDimensionalNotation/bar/stackedData/dataStacker.d.ts +4 -2
  31. package/lib/engine/twoDimensionalNotation/bar/stackedData/dataStacker.js +2 -5
  32. package/lib/engine/twoDimensionalNotation/line/line.d.ts +2 -7
  33. package/lib/engine/twoDimensionalNotation/line/line.js +6 -6
  34. package/lib/engine/twoDimensionalNotation/line/lineGenerator.d.ts +4 -7
  35. package/lib/engine/twoDimensionalNotation/line/lineGenerator.js +2 -16
  36. package/lib/engine/twoDimensionalNotation/line/lineHelper.d.ts +4 -13
  37. package/lib/engine/twoDimensionalNotation/line/lineHelper.js +22 -10
  38. package/lib/engine/twoDimensionalNotation/lineLike/generatorFactory/lineLikeGeneratorFactory.d.ts +12 -0
  39. package/lib/engine/twoDimensionalNotation/lineLike/generatorFactory/lineLikeGeneratorFactory.js +1 -0
  40. package/lib/engine/twoDimensionalNotation/lineLike/generatorMiddleware/lineLikeGeneratorCurveMiddleware.d.ts +14 -0
  41. package/lib/engine/twoDimensionalNotation/lineLike/generatorMiddleware/lineLikeGeneratorCurveMiddleware.js +21 -0
  42. package/lib/engine/twoDimensionalNotation/lineLike/generatorMiddleware/lineLikeGeneratorDefineMiddleware.d.ts +20 -0
  43. package/lib/engine/twoDimensionalNotation/lineLike/generatorMiddleware/lineLikeGeneratorDefineMiddleware.js +9 -0
  44. package/lib/engine/twoDimensionalNotation/lineLike/generatorMiddleware/lineLikeGeneratorMiddleware.d.ts +5 -0
  45. package/lib/engine/twoDimensionalNotation/lineLike/generatorMiddleware/lineLikeGeneratorMiddleware.js +1 -0
  46. package/lib/engine/twoDimensionalNotation/twoDimensionalManager.d.ts +2 -0
  47. package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +26 -3
  48. package/lib/model/chartStyleModel/twoDimensionalChartStyleModel.js +5 -1
  49. package/lib/model/featuresModel/axisModel.js +3 -1
  50. package/lib/model/featuresModel/valueLabelsModel/valueLabelsModel.d.ts +9 -0
  51. package/lib/model/featuresModel/valueLabelsModel/valueLabelsModel.js +33 -0
  52. package/lib/model/helpers/modelHelper.d.ts +1 -0
  53. package/lib/model/helpers/modelHelper.js +3 -2
  54. package/lib/model/helpers/twoDimensionalModelHelper.d.ts +8 -0
  55. package/lib/model/helpers/twoDimensionalModelHelper.js +56 -0
  56. package/lib/model/model.d.ts +66 -6
  57. package/lib/model/modelInstance/configReader.d.ts +2 -1
  58. package/lib/model/modelInstance/configReader.js +17 -0
  59. package/lib/model/notations/polar/polarModel.js +2 -1
  60. package/lib/model/notations/twoDimensional/styles.d.ts +3 -1
  61. package/lib/model/notations/twoDimensional/styles.js +20 -0
  62. package/lib/model/notations/twoDimensionalModel.js +30 -25
  63. package/lib/style/charts-main.css +17 -2
  64. package/lib/style/charts-main.less +17 -2
  65. package/package.json +2 -2
  66. package/lib/style/css-vars.css +0 -3
  67. /package/lib/engine/block/{defs.d.ts → defs/hatchPattern.d.ts} +0 -0
  68. /package/lib/engine/block/{defs.js → defs/hatchPattern.js} +0 -0
@@ -1,7 +1,9 @@
1
- import { ChartLegendModel, LineLikeChartDashOptions, LineLikeChartShapeOptions } from "../../model";
1
+ import { AreaChartViewOptions, ChartLegendModel, ChartStyle, GradientId, LineLikeChartDashOptions, LineLikeChartShapeOptions } from "../../model";
2
2
  import { ChartOrientation, MdtChartsLineLikeChartDashedStyles, MdtChartsTwoDimensionalChart, TwoDimensionalChartType } from "../../../config/config";
3
3
  import { MdtChartsLineLikeChartShape } from "../../../designer/designerConfig";
4
4
  export declare function parseShape(chartOrientation: ChartOrientation, configOptions?: MdtChartsLineLikeChartShape): LineLikeChartShapeOptions;
5
5
  export declare function parseDashStyles(configOptions?: MdtChartsLineLikeChartDashedStyles): LineLikeChartDashOptions;
6
6
  export declare function getLegendMarkerOptions(chart: MdtChartsTwoDimensionalChart): ChartLegendModel;
7
7
  export declare function getWidthOfLegendMarkerByType(chartType: TwoDimensionalChartType): number;
8
+ export declare function getAreaViewOptions(chart: MdtChartsTwoDimensionalChart, chartIndex: number, style: ChartStyle): AreaChartViewOptions;
9
+ export declare function getGradientId(chartIndex: number, subIndex: number): GradientId;
@@ -48,3 +48,23 @@ export function getWidthOfLegendMarkerByType(chartType) {
48
48
  if (chartType === "area")
49
49
  return styledElementValues.defaultLegendMarkerSizes.widthPx;
50
50
  }
51
+ export function getAreaViewOptions(chart, chartIndex, style) {
52
+ var _a, _b, _c, _d, _e;
53
+ let gradientIds = [];
54
+ for (let index = 0; index < style.elementColors.length; index++) {
55
+ gradientIds.push(getGradientId(chartIndex, index));
56
+ }
57
+ 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 }
58
+ : { type: "paletteColor" };
59
+ const borderLine = {
60
+ on: (_e = (_d = (_c = chart.areaStyles) === null || _c === void 0 ? void 0 : _c.borderLine) === null || _d === void 0 ? void 0 : _d.on) !== null && _e !== void 0 ? _e : false,
61
+ colorStyle: {
62
+ elementColors: style.elementColors,
63
+ opacity: 1
64
+ }
65
+ };
66
+ return { fill, borderLine };
67
+ }
68
+ export function getGradientId(chartIndex, subIndex) {
69
+ return `gradient-chart-${chartIndex}-sub-${subIndex}`;
70
+ }
@@ -3,14 +3,16 @@ import { TwoDimensionalChartStyleModel } from "../chartStyleModel/twoDimensional
3
3
  import { AxisModel } from "../featuresModel/axisModel";
4
4
  import { ScaleAxisRecalcer } from "../featuresModel/scaleModel/scaleAxisRecalcer";
5
5
  import { ScaleModel } from "../featuresModel/scaleModel/scaleModel";
6
- import { getLegendMarkerOptions, parseDashStyles, parseShape } from "./twoDimensional/styles";
6
+ import { getAreaViewOptions, getLegendMarkerOptions, parseDashStyles, parseShape } from "./twoDimensional/styles";
7
7
  import { getResolvedTitle } from "../../model/featuresModel/titleModel";
8
+ import { calculateValueLabelAlignment, getValueLabelX, getValueLabelY } from "../../model/featuresModel/valueLabelsModel/valueLabelsModel";
9
+ import { TwoDimensionalModelHelper } from "../helpers/twoDimensionalModelHelper";
8
10
  export class TwoDimensionalModel {
9
11
  static getOptions(configReader, designerConfig, modelInstance) {
12
+ var _a;
10
13
  let secondaryScaleValueInfo;
11
14
  const options = configReader.options;
12
15
  const canvasModel = modelInstance.canvasModel;
13
- const resolvedTitle = getResolvedTitle(options.title, modelInstance.dataModel.repository.getRawRows());
14
16
  const scaleModel = new ScaleModel();
15
17
  const scaleMarginRecalcer = new ScaleAxisRecalcer(() => scaleModel.getScaleLinear(options, modelInstance.dataModel.repository.getScopedRows(), canvasModel, configReader));
16
18
  scaleMarginRecalcer.recalculateMargin(canvasModel, options.orientation, options.axis.key);
@@ -20,19 +22,25 @@ export class TwoDimensionalModel {
20
22
  secondaryScaleMarginRecalcer.recalculateMargin(canvasModel, options.orientation, options.axis.key);
21
23
  secondaryScaleValueInfo = secondaryScaleMarginRecalcer.getScaleValue();
22
24
  }
25
+ 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);
23
27
  return {
24
28
  legend: canvasModel.legendCanvas.getModel(),
25
- title: resolvedTitle,
29
+ title: getResolvedTitle(options.title, modelInstance.dataModel.repository.getRawRows()),
26
30
  selectable: !!options.selectable,
27
31
  orient: options.orientation,
28
32
  scale: Object.assign({ key: scaleModel.getScaleKey(modelInstance.dataModel.getAllowableKeys(), options.orientation, canvasModel, options.charts, this.getChartsByType(options.charts, 'bar')), value: scaleValueInfo.scale }, (configReader.containsSecondaryAxis() && { valueSecondary: secondaryScaleValueInfo.scale })),
29
- axis: Object.assign({ key: AxisModel.getKeyAxis(options, modelInstance.dataModel.repository.getScopedFullSource(), designerConfig.canvas.axisLabel, canvasModel, designerConfig.elementsOptions.tooltip, () => scaleValueInfo.scaleFn(0)), value: AxisModel.getMainValueAxis(options.orientation, options.axis.value.position, options.axis.value, designerConfig.canvas.axisLabel, canvasModel) }, (configReader.containsSecondaryAxis() && { valueSecondary: AxisModel.getSecondaryValueAxis(options.orientation, options.axis.value.position, options.axis.valueSecondary, designerConfig.canvas.axisLabel, canvasModel) })),
33
+ axis: Object.assign({ key: keyAxis, value: AxisModel.getMainValueAxis(options.orientation, options.axis.value.position, options.axis.value, designerConfig.canvas.axisLabel, canvasModel) }, (configReader.containsSecondaryAxis() && { valueSecondary: AxisModel.getSecondaryValueAxis(options.orientation, options.axis.value.position, options.axis.valueSecondary, designerConfig.canvas.axisLabel, canvasModel) })),
30
34
  type: options.type,
31
35
  data: Object.assign({}, options.data),
32
- charts: this.getChartsModel(options.charts, options.orientation, designerConfig, modelInstance.dataModel.repository),
36
+ charts,
33
37
  additionalElements: this.getAdditionalElements(options),
34
38
  tooltip: options.tooltip,
35
- chartSettings: this.getChartsSettings(designerConfig.canvas.chartOptions, options.orientation)
39
+ chartSettings: this.getChartsSettings(designerConfig.canvas.chartOptions, options.orientation),
40
+ valueLabels: (_a = options.valueLabels) !== null && _a !== void 0 ? _a : { collision: { mode: "none" } },
41
+ defs: {
42
+ gradients: TwoDimensionalModelHelper.getGradientDefs(charts, keyAxis.orient, options.orientation)
43
+ }
36
44
  };
37
45
  }
38
46
  static getChartsEmbeddedLabelsFlag(charts, chartOrientation) {
@@ -57,22 +65,15 @@ export class TwoDimensionalModel {
57
65
  lineLike: { shape: parseShape(chartOrientation, (_a = chartOptions.line) === null || _a === void 0 ? void 0 : _a.shape) }
58
66
  };
59
67
  }
60
- static getChartsModel(charts, chartOrientation, designerConfig, dataModelRep) {
68
+ static getChartsModel(charts, configReader, chartOrientation, designerConfig, dataModelRep, keyAxisOrient, canvasModel, keyFieldName) {
61
69
  const styleModel = new TwoDimensionalChartStyleModel(charts, designerConfig.chartStyle);
62
70
  this.sortCharts(charts);
63
71
  const chartsModel = [];
64
72
  charts.forEach((chart, index) => {
65
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
66
- chartsModel.push({
67
- type: chart.type,
68
- isSegmented: chart.isSegmented,
69
- data: Object.assign({}, chart.data),
70
- tooltip: chart.tooltip,
71
- cssClasses: ChartStyleModelService.getCssClasses(index),
72
- style: styleModel.getChartStyle(chart, index),
73
- embeddedLabels: this.getEmbeddedLabelType(chart, chartOrientation),
74
- markersOptions: {
75
- show: dataModelRep.getScopedRows().length === 1 ? true : chart.markers.show,
73
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
74
+ const style = styleModel.getChartStyle(chart, index);
75
+ chartsModel.push(Object.assign(Object.assign({ type: chart.type, isSegmented: chart.isSegmented, data: Object.assign({}, chart.data), tooltip: chart.tooltip, cssClasses: ChartStyleModelService.getCssClasses(index), style, embeddedLabels: this.getEmbeddedLabelType(chart, chartOrientation), markersOptions: {
76
+ show: ({ row, valueFieldName }) => TwoDimensionalModelHelper.shouldMarkerShow(chart, dataModelRep.getRawRows(), valueFieldName, row, keyFieldName),
76
77
  styles: {
77
78
  highlighted: {
78
79
  size: { radius: (_c = (_b = (_a = designerConfig.canvas.markers) === null || _a === void 0 ? void 0 : _a.highlighted) === null || _b === void 0 ? void 0 : _b.radius) !== null && _c !== void 0 ? _c : 4, borderSize: '3.5px' }
@@ -84,15 +85,19 @@ export class TwoDimensionalModel {
84
85
  }
85
86
  }
86
87
  }
87
- },
88
- lineViewOptions: {
88
+ }, lineLikeViewOptions: {
89
89
  dashedStyles: parseDashStyles((_k = chart.lineStyles) === null || _k === void 0 ? void 0 : _k.dash),
90
90
  renderForKey: (dataRow, valueFieldName) => dataRow[valueFieldName] !== null && dataRow[valueFieldName] !== undefined
91
- },
92
- barViewOptions: { hatch: { on: (_o = (_m = (_l = chart.barStyles) === null || _l === void 0 ? void 0 : _l.hatch) === null || _m === void 0 ? void 0 : _m.on) !== null && _o !== void 0 ? _o : false } },
93
- legend: getLegendMarkerOptions(chart),
94
- index
95
- });
91
+ }, barViewOptions: { hatch: { on: (_o = (_m = (_l = chart.barStyles) === null || _l === void 0 ? void 0 : _l.hatch) === null || _m === void 0 ? void 0 : _m.on) !== null && _o !== void 0 ? _o : false } }, legend: getLegendMarkerOptions(chart), index }, (((_p = chart.valueLabels) === null || _p === void 0 ? void 0 : _p.on) && {
92
+ valueLabels: {
93
+ show: true,
94
+ handleX: (scaledValue) => getValueLabelX(scaledValue, keyAxisOrient, canvasModel.getMargin()),
95
+ handleY: (scaledValue) => getValueLabelY(scaledValue, keyAxisOrient, canvasModel.getMargin()),
96
+ textAnchor: calculateValueLabelAlignment(keyAxisOrient).textAnchor,
97
+ dominantBaseline: calculateValueLabelAlignment(keyAxisOrient).dominantBaseline,
98
+ format: configReader.getValueLabelFormatterForChart(index),
99
+ }
100
+ })), { areaViewOptions: getAreaViewOptions(chart, index, style) }));
96
101
  });
97
102
  return chartsModel;
98
103
  }
@@ -1,4 +1,6 @@
1
- @import './css-vars.css';
1
+ :root {
2
+ --chart-base-font-size: 13px;
3
+ }
2
4
 
3
5
  .wrapper {
4
6
  margin: 0 auto;
@@ -11,6 +13,12 @@
11
13
  fill: none;
12
14
  stroke-width: 4;
13
15
  }
16
+
17
+ .area-border-line {
18
+ fill: none;
19
+ stroke-width: 2;
20
+ }
21
+
14
22
  .donut-block * {
15
23
  transition: filter 0.15s;
16
24
  }
@@ -157,7 +165,7 @@
157
165
  border-radius: 50%;
158
166
  }
159
167
  .tooltip-text-item {
160
- font-family: "Roboto" sans-serif;
168
+ font-family: "Roboto", sans-serif;
161
169
  font-style: normal;
162
170
  width: 100%;
163
171
  flex: 1;
@@ -276,3 +284,10 @@
276
284
  width: 100%;
277
285
  height: 100%;
278
286
  }
287
+
288
+ /* Value Labels */
289
+ .mdt-charts-value-label {
290
+ opacity: 0.5;
291
+ font-size: 10px;
292
+ letter-spacing: -0.4px;
293
+ }
@@ -1,4 +1,6 @@
1
- @import (inline) './css-vars.css';
1
+ :root {
2
+ --chart-base-font-size: 13px;
3
+ }
2
4
 
3
5
  .wrapper {
4
6
  margin: 0 auto;
@@ -11,6 +13,12 @@
11
13
  fill: none;
12
14
  stroke-width: 4;
13
15
  }
16
+
17
+ .area-border-line {
18
+ fill: none;
19
+ stroke-width: 2;
20
+ }
21
+
14
22
  .donut-block * {
15
23
  transition: filter 0.15s;
16
24
  }
@@ -157,7 +165,7 @@
157
165
  border-radius: 50%;
158
166
  }
159
167
  .tooltip-text-item {
160
- font-family: "Roboto" sans-serif;
168
+ font-family: "Roboto", sans-serif;
161
169
  font-style: normal;
162
170
  width: 100%;
163
171
  flex: 1;
@@ -276,3 +284,10 @@
276
284
  width: 100%;
277
285
  height: 100%;
278
286
  }
287
+
288
+ /* Value Labels */
289
+ .mdt-charts-value-label {
290
+ opacity: 0.5;
291
+ font-size: 10px;
292
+ letter-spacing: -0.4px;
293
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mdt-charts",
3
- "version": "1.20.0",
3
+ "version": "1.21.0",
4
4
  "description": "",
5
5
  "main": "lib/main.js",
6
6
  "scripts": {
@@ -10,7 +10,7 @@
10
10
  "test": "jest",
11
11
  "build-lib": "shx rm -rf lib && npm run build-ts && npm run build-style",
12
12
  "build-ts": "npx tsc -p tsconfig.production.json",
13
- "build-style": "shx mkdir lib/style && shx cp src/style/css-vars.css lib/style && shx cp src/style/charts-main.css lib/style && shx cp src/style/charts-main.less lib/style"
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
14
  },
15
15
  "homepage": "https://github.com/VishulaKnow/charts",
16
16
  "author": "",
@@ -1,3 +0,0 @@
1
- :root {
2
- --chart-base-font-size: 13px;
3
- }