mdt-charts 1.21.2 → 1.23.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.
- package/lib/config/config.d.ts +51 -15
- package/lib/engine/features/axis/axis.js +2 -0
- package/lib/engine/features/gridLine/gridLine.d.ts +3 -5
- package/lib/engine/features/gridLine/gridLine.js +15 -32
- package/lib/engine/features/legend/legend.d.ts +3 -0
- package/lib/engine/features/legend/legend.js +3 -0
- package/lib/engine/features/legend/legendHelper.d.ts +1 -0
- package/lib/engine/features/legend/legendHelper.js +11 -2
- package/lib/engine/features/legend/legendHelperService.d.ts +0 -1
- package/lib/engine/features/legend/legendHelperService.js +0 -3
- package/lib/engine/features/legend/legendMarkerCreator.js +7 -4
- package/lib/engine/features/valueLabels/valueLabels.d.ts +0 -1
- package/lib/engine/features/valueLabels/valueLabels.js +9 -14
- package/lib/engine/features/valueLabelsCollision/valueLabelsCollision.d.ts +7 -2
- package/lib/engine/features/valueLabelsCollision/valueLabelsCollision.js +25 -1
- package/lib/engine/twoDimensionalNotation/bar/bar.d.ts +1 -0
- package/lib/engine/twoDimensionalNotation/bar/bar.js +14 -9
- package/lib/engine/twoDimensionalNotation/bar/barHelper.d.ts +38 -6
- package/lib/engine/twoDimensionalNotation/bar/barHelper.js +67 -22
- package/lib/engine/twoDimensionalNotation/dot/dotChart.d.ts +36 -0
- package/lib/engine/twoDimensionalNotation/dot/dotChart.js +106 -0
- package/lib/engine/twoDimensionalNotation/line/lineHelper.js +4 -0
- package/lib/engine/twoDimensionalNotation/twoDimensionalManager.d.ts +1 -0
- package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +22 -2
- package/lib/model/dataManagerModel/dataManagerModel.d.ts +1 -2
- package/lib/model/dataManagerModel/dataManagerModel.js +15 -33
- package/lib/model/featuresModel/axisModel.d.ts +0 -1
- package/lib/model/featuresModel/axisModel.js +12 -32
- package/lib/model/featuresModel/legendModel/legendCanvasModel.d.ts +0 -1
- package/lib/model/featuresModel/legendModel/legendCanvasModel.js +0 -18
- package/lib/model/featuresModel/legendModel/legendModel.js +1 -1
- package/lib/model/featuresModel/legendModel/twoDimLegendModel.d.ts +2 -2
- package/lib/model/featuresModel/legendModel/twoDimLegendModel.js +3 -1
- package/lib/model/featuresModel/scaleModel/scaleModel.d.ts +1 -1
- package/lib/model/featuresModel/scaleModel/scaleModel.js +5 -5
- package/lib/model/featuresModel/scaleModel/scaleModelServices.d.ts +1 -1
- package/lib/model/featuresModel/scaleModel/scaleModelServices.js +15 -9
- package/lib/model/featuresModel/valueLabelsModel/valueLabelsModel.d.ts +6 -0
- package/lib/model/featuresModel/valueLabelsModel/valueLabelsModel.js +13 -0
- package/lib/model/model.d.ts +66 -6
- package/lib/model/modelBuilder.js +1 -3
- package/lib/model/modelInstance/configReader.js +5 -5
- package/lib/model/notations/polar/polarModel.js +11 -3
- package/lib/model/notations/twoDimensional/styles.d.ts +4 -1
- package/lib/model/notations/twoDimensional/styles.js +61 -4
- package/lib/model/notations/twoDimensionalModel.d.ts +2 -1
- package/lib/model/notations/twoDimensionalModel.js +66 -16
- package/lib/style/charts-main.css +9 -8
- package/lib/style/charts-main.less +9 -8
- package/package.json +1 -1
|
@@ -3,20 +3,19 @@ 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 { getAreaViewOptions, getLegendMarkerOptions, parseDashStyles, parseShape } from "./twoDimensional/styles";
|
|
6
|
+
import { getAreaViewOptions, getBarViewOptions, getLegendMarkerOptions, LINE_CHART_DEFAULT_WIDTH, parseDashStyles, parseShape } from "./twoDimensional/styles";
|
|
7
7
|
import { getResolvedTitle } from "../../model/featuresModel/titleModel";
|
|
8
|
-
import { calculateValueLabelAlignment, getValueLabelX, getValueLabelY } from "../../model/featuresModel/valueLabelsModel/valueLabelsModel";
|
|
8
|
+
import { calculateValueLabelAlignment, getValueLabelX, getValueLabelY, hasCollisionLeftSide, hasCollisionRightSide, shiftCoordinateXLeft, shiftCoordinateXRight } from "../../model/featuresModel/valueLabelsModel/valueLabelsModel";
|
|
9
9
|
import { TwoDimensionalModelHelper } from "../helpers/twoDimensionalModelHelper";
|
|
10
10
|
export class TwoDimensionalModel {
|
|
11
11
|
static getOptions(configReader, designerConfig, modelInstance) {
|
|
12
|
-
var _a;
|
|
13
|
-
let secondaryScaleValueInfo;
|
|
14
12
|
const options = configReader.options;
|
|
15
13
|
const canvasModel = modelInstance.canvasModel;
|
|
16
14
|
const scaleModel = new ScaleModel();
|
|
17
15
|
const scaleMarginRecalcer = new ScaleAxisRecalcer(() => scaleModel.getScaleLinear(options, modelInstance.dataModel.repository.getScopedRows(), canvasModel, configReader));
|
|
18
16
|
scaleMarginRecalcer.recalculateMargin(canvasModel, options.orientation, options.axis.key);
|
|
19
17
|
const scaleValueInfo = scaleMarginRecalcer.getScaleValue();
|
|
18
|
+
let secondaryScaleValueInfo;
|
|
20
19
|
if (configReader.containsSecondaryAxis()) {
|
|
21
20
|
const secondaryScaleMarginRecalcer = new ScaleAxisRecalcer(() => scaleModel.getScaleSecondaryLinear(options, modelInstance.dataModel.repository.getScopedRows(), canvasModel, configReader));
|
|
22
21
|
secondaryScaleMarginRecalcer.recalculateMargin(canvasModel, options.orientation, options.axis.key);
|
|
@@ -29,7 +28,7 @@ export class TwoDimensionalModel {
|
|
|
29
28
|
title: getResolvedTitle(options.title, modelInstance.dataModel.repository.getRawRows()),
|
|
30
29
|
selectable: !!options.selectable,
|
|
31
30
|
orient: options.orientation,
|
|
32
|
-
scale: Object.assign({ key: scaleModel.getScaleKey(modelInstance.dataModel.getAllowableKeys(), options.orientation, canvasModel, options.charts, this.
|
|
31
|
+
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 })),
|
|
33
32
|
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) })),
|
|
34
33
|
type: options.type,
|
|
35
34
|
data: Object.assign({}, options.data),
|
|
@@ -37,7 +36,7 @@ export class TwoDimensionalModel {
|
|
|
37
36
|
additionalElements: this.getAdditionalElements(options),
|
|
38
37
|
tooltip: options.tooltip,
|
|
39
38
|
chartSettings: this.getChartsSettings(designerConfig.canvas.chartOptions, options.orientation),
|
|
40
|
-
valueLabels: (
|
|
39
|
+
valueLabels: this.getValueLabels(options.valueLabels, canvasModel),
|
|
41
40
|
defs: {
|
|
42
41
|
gradients: TwoDimensionalModelHelper.getGradientDefs(charts, keyAxis.orient, options.orientation)
|
|
43
42
|
}
|
|
@@ -55,7 +54,7 @@ export class TwoDimensionalModel {
|
|
|
55
54
|
* @param charts Чарты из конфига
|
|
56
55
|
*/
|
|
57
56
|
static sortCharts(charts) {
|
|
58
|
-
const chartOrder = ['area', 'bar', 'line'];
|
|
57
|
+
const chartOrder = ['area', 'bar', 'line', 'dot'];
|
|
59
58
|
charts.sort((chart1, chart2) => chartOrder.indexOf(chart1.type) - chartOrder.indexOf(chart2.type));
|
|
60
59
|
}
|
|
61
60
|
static getChartsSettings(chartOptions, chartOrientation) {
|
|
@@ -70,9 +69,17 @@ export class TwoDimensionalModel {
|
|
|
70
69
|
this.sortCharts(charts);
|
|
71
70
|
const chartsModel = [];
|
|
72
71
|
charts.forEach((chart, index) => {
|
|
73
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
72
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
74
73
|
const style = styleModel.getChartStyle(chart, index);
|
|
75
|
-
chartsModel.push(
|
|
74
|
+
chartsModel.push({
|
|
75
|
+
type: chart.type,
|
|
76
|
+
isSegmented: chart.isSegmented,
|
|
77
|
+
data: Object.assign({}, chart.data),
|
|
78
|
+
tooltip: { show: true },
|
|
79
|
+
cssClasses: ChartStyleModelService.getCssClasses(index),
|
|
80
|
+
style,
|
|
81
|
+
embeddedLabels: this.getEmbeddedLabelType(chart, chartOrientation),
|
|
82
|
+
markersOptions: {
|
|
76
83
|
show: ({ row, valueFieldName }) => TwoDimensionalModelHelper.shouldMarkerShow(chart, dataModelRep.getRawRows(), valueFieldName, row, keyFieldName),
|
|
77
84
|
styles: {
|
|
78
85
|
highlighted: {
|
|
@@ -85,19 +92,33 @@ export class TwoDimensionalModel {
|
|
|
85
92
|
}
|
|
86
93
|
}
|
|
87
94
|
}
|
|
88
|
-
},
|
|
95
|
+
},
|
|
96
|
+
lineLikeViewOptions: {
|
|
89
97
|
dashedStyles: parseDashStyles((_k = chart.lineStyles) === null || _k === void 0 ? void 0 : _k.dash),
|
|
98
|
+
strokeWidth: (_m = (_l = chart.lineStyles) === null || _l === void 0 ? void 0 : _l.width) !== null && _m !== void 0 ? _m : LINE_CHART_DEFAULT_WIDTH,
|
|
90
99
|
renderForKey: (dataRow, valueFieldName) => dataRow[valueFieldName] !== null && dataRow[valueFieldName] !== undefined
|
|
91
|
-
},
|
|
100
|
+
},
|
|
101
|
+
barViewOptions: getBarViewOptions(chart, keyAxisOrient),
|
|
102
|
+
legend: getLegendMarkerOptions(chart),
|
|
103
|
+
index,
|
|
92
104
|
valueLabels: {
|
|
93
|
-
show:
|
|
105
|
+
show: (_p = (_o = chart.valueLabels) === null || _o === void 0 ? void 0 : _o.on) !== null && _p !== void 0 ? _p : false,
|
|
94
106
|
handleX: (scaledValue) => getValueLabelX(scaledValue, keyAxisOrient, canvasModel.getMargin()),
|
|
95
107
|
handleY: (scaledValue) => getValueLabelY(scaledValue, keyAxisOrient, canvasModel.getMargin()),
|
|
96
108
|
textAnchor: calculateValueLabelAlignment(keyAxisOrient).textAnchor,
|
|
97
109
|
dominantBaseline: calculateValueLabelAlignment(keyAxisOrient).dominantBaseline,
|
|
98
110
|
format: configReader.getValueLabelFormatterForChart(index),
|
|
111
|
+
},
|
|
112
|
+
areaViewOptions: getAreaViewOptions(chart, index, style),
|
|
113
|
+
dotViewOptions: {
|
|
114
|
+
shape: {
|
|
115
|
+
type: "line",
|
|
116
|
+
handleEndCoordinate: (v) => v + 2,
|
|
117
|
+
handleStartCoordinate: (v) => v - 2,
|
|
118
|
+
width: (_s = (_r = (_q = chart.dotLikeStyles) === null || _q === void 0 ? void 0 : _q.shape) === null || _r === void 0 ? void 0 : _r.width) !== null && _s !== void 0 ? _s : 2
|
|
119
|
+
}
|
|
99
120
|
}
|
|
100
|
-
})
|
|
121
|
+
});
|
|
101
122
|
});
|
|
102
123
|
return chartsModel;
|
|
103
124
|
}
|
|
@@ -115,11 +136,40 @@ export class TwoDimensionalModel {
|
|
|
115
136
|
return 'none';
|
|
116
137
|
}
|
|
117
138
|
static getAdditionalElements(options) {
|
|
139
|
+
var _a, _b;
|
|
140
|
+
const { flag, styles } = options.additionalElements.gridLine;
|
|
118
141
|
return {
|
|
119
|
-
gridLine:
|
|
142
|
+
gridLine: {
|
|
143
|
+
flag,
|
|
144
|
+
styles: {
|
|
145
|
+
dash: { on: (_b = (_a = styles === null || styles === void 0 ? void 0 : styles.dash) === null || _a === void 0 ? void 0 : _a.on) !== null && _b !== void 0 ? _b : false }
|
|
146
|
+
}
|
|
147
|
+
}
|
|
120
148
|
};
|
|
121
149
|
}
|
|
122
|
-
static
|
|
123
|
-
return charts.filter(chart => chart.type
|
|
150
|
+
static getChartsByTypes(charts, types) {
|
|
151
|
+
return charts.filter(chart => types.includes(chart.type));
|
|
152
|
+
}
|
|
153
|
+
static getValueLabels(valueLabels, canvasModel) {
|
|
154
|
+
var _a;
|
|
155
|
+
return {
|
|
156
|
+
collision: {
|
|
157
|
+
otherValueLables: (_a = valueLabels === null || valueLabels === void 0 ? void 0 : valueLabels.collision.otherValueLabels) !== null && _a !== void 0 ? _a : {
|
|
158
|
+
mode: 'none'
|
|
159
|
+
},
|
|
160
|
+
chartBlock: {
|
|
161
|
+
left: {
|
|
162
|
+
mode: 'shift',
|
|
163
|
+
hasCollision: (labelClientRect) => hasCollisionLeftSide(labelClientRect, canvasModel.getMargin()),
|
|
164
|
+
shiftCoordinate: (labelClientRect) => shiftCoordinateXRight(labelClientRect),
|
|
165
|
+
},
|
|
166
|
+
right: {
|
|
167
|
+
mode: 'shift',
|
|
168
|
+
hasCollision: (labelClientRect) => hasCollisionRightSide(labelClientRect, canvasModel.getBlockSize(), canvasModel.getMargin()),
|
|
169
|
+
shiftCoordinate: (labelClientRect) => shiftCoordinateXLeft(labelClientRect),
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
};
|
|
124
174
|
}
|
|
125
175
|
}
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
}
|
|
12
12
|
.line {
|
|
13
13
|
fill: none;
|
|
14
|
-
stroke-width: 4;
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
.area-border-line {
|
|
@@ -55,6 +54,9 @@
|
|
|
55
54
|
display: flex;
|
|
56
55
|
height: 100%;
|
|
57
56
|
}
|
|
57
|
+
.legend-block-centered {
|
|
58
|
+
justify-content: center;
|
|
59
|
+
}
|
|
58
60
|
.legend-block-column {
|
|
59
61
|
flex-direction: column;
|
|
60
62
|
}
|
|
@@ -62,9 +64,6 @@
|
|
|
62
64
|
flex-direction: row;
|
|
63
65
|
flex-wrap: wrap;
|
|
64
66
|
}
|
|
65
|
-
.legend-block-centered {
|
|
66
|
-
justify-content: center;
|
|
67
|
-
}
|
|
68
67
|
.legend-item {
|
|
69
68
|
cursor: default;
|
|
70
69
|
transition: opacity 0.1s;
|
|
@@ -103,6 +102,9 @@
|
|
|
103
102
|
overflow: hidden;
|
|
104
103
|
line-height: normal;
|
|
105
104
|
}
|
|
105
|
+
.legend-2d-label {
|
|
106
|
+
font-weight: 500;
|
|
107
|
+
}
|
|
106
108
|
.legend-label-nowrap {
|
|
107
109
|
white-space: nowrap;
|
|
108
110
|
text-overflow: ellipsis;
|
|
@@ -203,10 +205,10 @@
|
|
|
203
205
|
|
|
204
206
|
/*========================================================================= Additional */
|
|
205
207
|
.mdt-charts-axis .domain {
|
|
206
|
-
stroke:
|
|
208
|
+
stroke: rgba(231, 229, 228, 0.8);
|
|
207
209
|
}
|
|
208
210
|
.mdt-charts-axis .tick line:first-of-type {
|
|
209
|
-
stroke:
|
|
211
|
+
stroke: rgba(231, 229, 228, 0.8);
|
|
210
212
|
}
|
|
211
213
|
|
|
212
214
|
/* Aggregator */
|
|
@@ -229,8 +231,7 @@
|
|
|
229
231
|
|
|
230
232
|
/* Grid */
|
|
231
233
|
.grid-line {
|
|
232
|
-
stroke:
|
|
233
|
-
stroke-dasharray: 3;
|
|
234
|
+
stroke: rgba(231, 229, 228, 0.8);
|
|
234
235
|
}
|
|
235
236
|
|
|
236
237
|
/* Record overflow */
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
}
|
|
12
12
|
.line {
|
|
13
13
|
fill: none;
|
|
14
|
-
stroke-width: 4;
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
.area-border-line {
|
|
@@ -55,6 +54,9 @@
|
|
|
55
54
|
display: flex;
|
|
56
55
|
height: 100%;
|
|
57
56
|
}
|
|
57
|
+
.legend-block-centered {
|
|
58
|
+
justify-content: center;
|
|
59
|
+
}
|
|
58
60
|
.legend-block-column {
|
|
59
61
|
flex-direction: column;
|
|
60
62
|
}
|
|
@@ -62,9 +64,6 @@
|
|
|
62
64
|
flex-direction: row;
|
|
63
65
|
flex-wrap: wrap;
|
|
64
66
|
}
|
|
65
|
-
.legend-block-centered {
|
|
66
|
-
justify-content: center;
|
|
67
|
-
}
|
|
68
67
|
.legend-item {
|
|
69
68
|
cursor: default;
|
|
70
69
|
transition: opacity 0.1s;
|
|
@@ -103,6 +102,9 @@
|
|
|
103
102
|
overflow: hidden;
|
|
104
103
|
line-height: normal;
|
|
105
104
|
}
|
|
105
|
+
.legend-2d-label {
|
|
106
|
+
font-weight: 500;
|
|
107
|
+
}
|
|
106
108
|
.legend-label-nowrap {
|
|
107
109
|
white-space: nowrap;
|
|
108
110
|
text-overflow: ellipsis;
|
|
@@ -203,10 +205,10 @@
|
|
|
203
205
|
|
|
204
206
|
/*========================================================================= Additional */
|
|
205
207
|
.mdt-charts-axis .domain {
|
|
206
|
-
stroke:
|
|
208
|
+
stroke: rgba(231, 229, 228, 0.8);
|
|
207
209
|
}
|
|
208
210
|
.mdt-charts-axis .tick line:first-of-type {
|
|
209
|
-
stroke:
|
|
211
|
+
stroke: rgba(231, 229, 228, 0.8);
|
|
210
212
|
}
|
|
211
213
|
|
|
212
214
|
/* Aggregator */
|
|
@@ -229,8 +231,7 @@
|
|
|
229
231
|
|
|
230
232
|
/* Grid */
|
|
231
233
|
.grid-line {
|
|
232
|
-
stroke:
|
|
233
|
-
stroke-dasharray: 3;
|
|
234
|
+
stroke: rgba(231, 229, 228, 0.8);
|
|
234
235
|
}
|
|
235
236
|
|
|
236
237
|
/* Record overflow */
|