mdt-charts 1.30.2 → 1.32.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 (41) hide show
  1. package/lib/config/config.d.ts +30 -5
  2. package/lib/engine/features/legend/legendHelper.d.ts +3 -3
  3. package/lib/engine/features/legend/legendMarkerCreator.d.ts +6 -6
  4. package/lib/engine/features/legend/legendMarkerCreator.js +2 -2
  5. package/lib/engine/features/tolltip/tooltip.d.ts +1 -2
  6. package/lib/engine/features/tolltip/tooltip.js +14 -17
  7. package/lib/engine/features/tolltip/tooltipDomHelper.d.ts +2 -14
  8. package/lib/engine/features/tolltip/tooltipDomHelper.js +30 -107
  9. package/lib/engine/features/valueLabels/valueLabels.js +17 -9
  10. package/lib/engine/polarNotation/polarManager.js +2 -2
  11. package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +2 -2
  12. package/lib/model/dataManagerModel/dataManagerModel.js +1 -1
  13. package/lib/model/featuresModel/{axisModel.d.ts → axis/axisModel.d.ts} +5 -5
  14. package/lib/model/featuresModel/{axisModel.js → axis/axisModel.js} +4 -4
  15. package/lib/model/featuresModel/{axisModelService.d.ts → axis/axisModelService.d.ts} +1 -1
  16. package/lib/model/featuresModel/otherComponents.js +2 -2
  17. package/lib/model/featuresModel/tooltipModel/contentByNotations/polarInitialRowsProvider.d.ts +14 -0
  18. package/lib/model/featuresModel/tooltipModel/contentByNotations/polarInitialRowsProvider.js +16 -0
  19. package/lib/model/featuresModel/tooltipModel/contentByNotations/tooltipContentInitialRowsProvider.d.ts +13 -0
  20. package/lib/model/featuresModel/tooltipModel/contentByNotations/tooltipContentInitialRowsProvider.js +1 -0
  21. package/lib/model/featuresModel/tooltipModel/contentByNotations/twoDimInitialRowsProvider.d.ts +10 -0
  22. package/lib/model/featuresModel/tooltipModel/contentByNotations/twoDimInitialRowsProvider.js +17 -0
  23. package/lib/model/featuresModel/tooltipModel/tooltipCanvasModel.d.ts +4 -0
  24. package/lib/model/featuresModel/{tooltipModel.js → tooltipModel/tooltipCanvasModel.js} +2 -2
  25. package/lib/model/featuresModel/tooltipModel/tooltipContentModel.d.ts +18 -0
  26. package/lib/model/featuresModel/tooltipModel/tooltipContentModel.js +87 -0
  27. package/lib/model/featuresModel/valueLabelsModel/valueLabelsModel.d.ts +4 -3
  28. package/lib/model/featuresModel/valueLabelsModel/valueLabelsModel.js +38 -6
  29. package/lib/model/margin/twoDim/twoDimMarginModel.js +3 -3
  30. package/lib/model/model.d.ts +45 -13
  31. package/lib/model/modelInstance/configReader.js +1 -1
  32. package/lib/model/notations/polar/modelConstants/polarLegendMarker.d.ts +2 -0
  33. package/lib/model/notations/polar/modelConstants/polarLegendMarker.js +3 -0
  34. package/lib/model/notations/polar/polarModel.js +25 -20
  35. package/lib/model/notations/twoDimensional/styles.d.ts +2 -2
  36. package/lib/model/notations/twoDimensionalModel.js +40 -24
  37. package/lib/style/charts-main.css +2 -2
  38. package/lib/style/charts-main.less +2 -2
  39. package/package.json +2 -3
  40. package/lib/model/featuresModel/tooltipModel.d.ts +0 -4
  41. /package/lib/model/featuresModel/{axisModelService.js → axis/axisModelService.js} +0 -0
@@ -1,13 +1,15 @@
1
1
  import { ChartStyleModelService } from "../chartStyleModel/chartStyleModel";
2
2
  import { TwoDimensionalChartStyleModel } from "../chartStyleModel/twoDimensionalChartStyleModel";
3
- import { AxisModel } from "../featuresModel/axisModel";
3
+ import { AxisModel } from "../featuresModel/axis/axisModel";
4
4
  import { ScaleAxisRecalcer } from "../featuresModel/scaleModel/scaleAxisRecalcer";
5
5
  import { ScaleModel } from "../featuresModel/scaleModel/scaleModel";
6
6
  import { calculateBarIndexes, getAreaViewOptions, getBarViewOptions, getLegendMarkerOptions, LINE_CHART_DEFAULT_WIDTH, parseDashStyles, parseShape } from "./twoDimensional/styles";
7
- import { calculateValueLabelAlignment, ValueLabelCoordinateCalculator } from "../../model/featuresModel/valueLabelsModel/valueLabelsModel";
7
+ import { calculateValueLabelAlignment, handleScaledValue, ValueLabelCoordinateCalculator } from "../../model/featuresModel/valueLabelsModel/valueLabelsModel";
8
8
  import { TwoDimensionalModelHelper } from "../helpers/twoDimensionalModelHelper";
9
9
  import { TitleConfigReader } from "../modelInstance/titleConfigReader";
10
10
  import { createRecordOverflowModel } from "../featuresModel/recordOverflowModel/recordOverflowModel";
11
+ import { TwoDimTooltipContentGenerator } from "../featuresModel/tooltipModel/tooltipContentModel";
12
+ import { TwoDimInitialRowsProvider } from "../featuresModel/tooltipModel/contentByNotations/twoDimInitialRowsProvider";
11
13
  export class TwoDimensionalModel {
12
14
  static getOptions(configReader, designerConfig, modelInstance) {
13
15
  const options = configReader.options;
@@ -42,7 +44,18 @@ export class TwoDimensionalModel {
42
44
  data: Object.assign({}, options.data),
43
45
  charts,
44
46
  additionalElements: this.getAdditionalElements(options),
45
- tooltip: options.tooltip,
47
+ tooltip: {
48
+ getContent: (keyFieldValue) => {
49
+ const generator = new TwoDimTooltipContentGenerator({
50
+ datasource: modelInstance.dataModel.repository.getRawRows(),
51
+ keyFieldName: options.data.keyField.name,
52
+ publicOptions: options.tooltip,
53
+ initialRowsProvider: new TwoDimInitialRowsProvider({ chartsInfo: charts }),
54
+ valueGlobalFormatter: designerConfig.dataFormat.formatters
55
+ });
56
+ return generator.generateContent(keyFieldValue);
57
+ }
58
+ },
46
59
  chartSettings: this.getChartsSettings(designerConfig.canvas.chartOptions, options.orientation),
47
60
  valueLabels: TwoDimensionalModelHelper.getValueLabels(options.valueLabels, canvasModel, options.orientation, configReader.getValueLabelsStyleModel()),
48
61
  defs: {
@@ -82,15 +95,14 @@ export class TwoDimensionalModel {
82
95
  const styleModel = new TwoDimensionalChartStyleModel(charts, designerConfig.chartStyle);
83
96
  const chartsModel = [];
84
97
  charts.forEach((chart, index) => {
85
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
98
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
86
99
  const style = styleModel.getChartStyle(chart, index);
87
- const valueLabelsCoordinateCalculator = new ValueLabelCoordinateCalculator((_b = (_a = chart.valueLabels) === null || _a === void 0 ? void 0 : _a.position) === null || _b === void 0 ? void 0 : _b.mode, keyAxisOrient, canvasModel.getMargin());
88
- const valueLabelsAlignment = calculateValueLabelAlignment(keyAxisOrient, (_d = (_c = chart.valueLabels) === null || _c === void 0 ? void 0 : _c.position) === null || _d === void 0 ? void 0 : _d.mode, (_e = chart.valueLabels) === null || _e === void 0 ? void 0 : _e.rotation);
100
+ const valueLabelsCoordinateCalculator = new ValueLabelCoordinateCalculator((_a = chart.valueLabels) === null || _a === void 0 ? void 0 : _a.position, keyAxisOrient, canvasModel.getMargin());
101
+ const valueLabelsAlignment = calculateValueLabelAlignment(keyAxisOrient, (_c = (_b = chart.valueLabels) === null || _b === void 0 ? void 0 : _b.position) === null || _c === void 0 ? void 0 : _c.mode, (_d = chart.valueLabels) === null || _d === void 0 ? void 0 : _d.rotation);
89
102
  chartsModel.push({
90
103
  type: chart.type,
91
104
  isSegmented: chart.isSegmented,
92
105
  data: Object.assign({}, chart.data),
93
- tooltip: { show: true },
94
106
  cssClasses: ChartStyleModelService.getCssClasses(index),
95
107
  style,
96
108
  embeddedLabels: this.getEmbeddedLabelType(chart, chartOrientation),
@@ -99,44 +111,48 @@ export class TwoDimensionalModel {
99
111
  styles: {
100
112
  highlighted: {
101
113
  size: {
102
- radius: (_h = (_g = (_f = designerConfig.canvas.markers) === null || _f === void 0 ? void 0 : _f.highlighted) === null || _g === void 0 ? void 0 : _g.radius) !== null && _h !== void 0 ? _h : 4,
114
+ radius: (_g = (_f = (_e = designerConfig.canvas.markers) === null || _e === void 0 ? void 0 : _e.highlighted) === null || _f === void 0 ? void 0 : _f.radius) !== null && _g !== void 0 ? _g : 4,
103
115
  borderSize: "3.5px"
104
116
  }
105
117
  },
106
118
  normal: {
107
119
  size: {
108
- radius: (_l = (_k = (_j = designerConfig.canvas.markers) === null || _j === void 0 ? void 0 : _j.normal) === null || _k === void 0 ? void 0 : _k.radius) !== null && _l !== void 0 ? _l : 3,
109
- borderSize: `${(_p = (_o = (_m = designerConfig.canvas.markers) === null || _m === void 0 ? void 0 : _m.normal) === null || _o === void 0 ? void 0 : _o.borderSize) !== null && _p !== void 0 ? _p : 2}px`
120
+ radius: (_k = (_j = (_h = designerConfig.canvas.markers) === null || _h === void 0 ? void 0 : _h.normal) === null || _j === void 0 ? void 0 : _j.radius) !== null && _k !== void 0 ? _k : 3,
121
+ borderSize: `${(_o = (_m = (_l = designerConfig.canvas.markers) === null || _l === void 0 ? void 0 : _l.normal) === null || _m === void 0 ? void 0 : _m.borderSize) !== null && _o !== void 0 ? _o : 2}px`
110
122
  }
111
123
  }
112
124
  }
113
125
  },
114
126
  lineLikeViewOptions: {
115
- dashedStyles: parseDashStyles((_q = chart.lineStyles) === null || _q === void 0 ? void 0 : _q.dash),
116
- strokeWidth: (_s = (_r = chart.lineStyles) === null || _r === void 0 ? void 0 : _r.width) !== null && _s !== void 0 ? _s : LINE_CHART_DEFAULT_WIDTH,
127
+ dashedStyles: parseDashStyles((_p = chart.lineStyles) === null || _p === void 0 ? void 0 : _p.dash),
128
+ strokeWidth: (_r = (_q = chart.lineStyles) === null || _q === void 0 ? void 0 : _q.width) !== null && _r !== void 0 ? _r : LINE_CHART_DEFAULT_WIDTH,
117
129
  renderForKey: (dataRow, valueFieldName) => dataRow[valueFieldName] !== null && dataRow[valueFieldName] !== undefined
118
130
  },
119
131
  barViewOptions: getBarViewOptions(chart, keyAxisOrient, calculateBarIndexes(charts, chart, index)),
120
132
  legend: getLegendMarkerOptions(chart),
121
133
  index,
122
134
  valueLabels: {
123
- show: (_u = (_t = chart.valueLabels) === null || _t === void 0 ? void 0 : _t.on) !== null && _u !== void 0 ? _u : false,
135
+ show: (_t = (_s = chart.valueLabels) === null || _s === void 0 ? void 0 : _s.on) !== null && _t !== void 0 ? _t : false,
124
136
  handleX: (scaledValue) => valueLabelsCoordinateCalculator.getValueLabelX(scaledValue),
125
137
  handleY: (scaledValue) => valueLabelsCoordinateCalculator.getValueLabelY(scaledValue),
126
138
  handleScaledValue: (dataRow, datumField) => {
127
- var _a, _b, _c, _d;
128
- 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")
129
- return dataRow[datumField];
130
- if (chart.isSegmented)
131
- return dataRow[datumField] - (dataRow[datumField] - dataRow["0"]) / 2;
132
- else
133
- return dataRow[datumField] / 2;
139
+ var _a, _b;
140
+ return handleScaledValue(dataRow, datumField, chart.isSegmented, (_b = (_a = chart.valueLabels) === null || _a === void 0 ? void 0 : _a.position) === null || _b === void 0 ? void 0 : _b.mode);
134
141
  },
135
142
  textAnchor: valueLabelsAlignment.textAnchor,
136
143
  dominantBaseline: valueLabelsAlignment.dominantBaseline,
137
- format: configReader.getValueLabelFormatterForChart(index),
138
- rotation: (_v = chart.valueLabels) === null || _v === void 0 ? void 0 : _v.rotation,
139
- handleElement: (_w = chart.valueLabels) === null || _w === void 0 ? void 0 : _w.handleElement
144
+ rotation: (_u = chart.valueLabels) === null || _u === void 0 ? void 0 : _u.rotation,
145
+ handleElement: (_v = chart.valueLabels) === null || _v === void 0 ? void 0 : _v.handleElement,
146
+ forFields: (_x = (_w = chart.valueLabels) === null || _w === void 0 ? void 0 : _w.renderForFields) !== null && _x !== void 0 ? _x : chart.data.valueFields.map((field) => field.name),
147
+ setContent: ({ dataRow, fieldName }) => {
148
+ var _a;
149
+ if ((_a = chart.valueLabels) === null || _a === void 0 ? void 0 : _a.setContent)
150
+ return chart.valueLabels.setContent({
151
+ dataRow,
152
+ field: chart.data.valueFields.find((field) => field.name === fieldName)
153
+ });
154
+ return { textContent: configReader.getValueLabelFormatterForChart(index)(dataRow[fieldName]) };
155
+ }
140
156
  },
141
157
  areaViewOptions: getAreaViewOptions(chart, index, style, modelInstance.version.getVersionNumber()),
142
158
  dotViewOptions: {
@@ -144,7 +160,7 @@ export class TwoDimensionalModel {
144
160
  type: "line",
145
161
  handleEndCoordinate: (v) => v + 2,
146
162
  handleStartCoordinate: (v) => v - 2,
147
- width: (_z = (_y = (_x = chart.dotLikeStyles) === null || _x === void 0 ? void 0 : _x.shape) === null || _y === void 0 ? void 0 : _y.width) !== null && _z !== void 0 ? _z : LINE_CHART_DEFAULT_WIDTH
163
+ width: (_0 = (_z = (_y = chart.dotLikeStyles) === null || _y === void 0 ? void 0 : _y.shape) === null || _z === void 0 ? void 0 : _z.width) !== null && _0 !== void 0 ? _0 : LINE_CHART_DEFAULT_WIDTH
148
164
  }
149
165
  }
150
166
  });
@@ -193,10 +193,10 @@
193
193
  .mdt-charts-tooltip-content .tooltip-text-item > span {
194
194
  display: block;
195
195
  }
196
- .mdt-charts-tooltip-content .tooltip-text-item > span:first-of-type {
196
+ .mdt-charts-tooltip-content .tooltip-text-item .tooltip-field-title {
197
197
  flex: 1;
198
198
  }
199
- .mdt-charts-tooltip-content .tooltip-text-item > span:last-of-type {
199
+ .mdt-charts-tooltip-content .tooltip-text-item .tooltip-field-value {
200
200
  flex: 0;
201
201
  }
202
202
  .tooltip-field-value {
@@ -193,10 +193,10 @@
193
193
  .mdt-charts-tooltip-content .tooltip-text-item > span {
194
194
  display: block;
195
195
  }
196
- .mdt-charts-tooltip-content .tooltip-text-item > span:first-of-type {
196
+ .mdt-charts-tooltip-content .tooltip-text-item .tooltip-field-title {
197
197
  flex: 1;
198
198
  }
199
- .mdt-charts-tooltip-content .tooltip-text-item > span:last-of-type {
199
+ .mdt-charts-tooltip-content .tooltip-text-item .tooltip-field-value {
200
200
  flex: 0;
201
201
  }
202
202
  .tooltip-field-value {
package/package.json CHANGED
@@ -1,12 +1,11 @@
1
1
  {
2
2
  "name": "mdt-charts",
3
- "version": "1.30.2",
3
+ "version": "1.32.0",
4
4
  "description": "",
5
5
  "main": "lib/main.js",
6
6
  "scripts": {
7
- "dev": "npx webpack --mode development",
7
+ "dev": "npx webpack --mode development --watch",
8
8
  "build": "npx webpack --mode production",
9
- "watch": "npx webpack --mode development --watch",
10
9
  "test": "jest",
11
10
  "build-lib": "shx rm -rf lib && npm run build-ts && npm run build-style",
12
11
  "build-ts": "npx tsc -p tsconfig.production.json",
@@ -1,4 +0,0 @@
1
- import { TooltipSettings } from "../../designer/designerConfig";
2
- export declare class TooltipModel {
3
- static getTooltipModel(options: TooltipSettings): TooltipSettings;
4
- }