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
|
@@ -1,23 +1,5 @@
|
|
|
1
1
|
import { CLASSES } from "../../modelBuilder";
|
|
2
2
|
export class LegendCanvasModel {
|
|
3
|
-
static getLegendItemWidth(text) {
|
|
4
|
-
const itemWrapper = document.createElement('div');
|
|
5
|
-
itemWrapper.style.opacity = '0';
|
|
6
|
-
const colorBlock = document.createElement('span');
|
|
7
|
-
const textBlock = document.createElement('span');
|
|
8
|
-
itemWrapper.style.display = 'inline-block';
|
|
9
|
-
itemWrapper.classList.add(CLASSES.legendItem);
|
|
10
|
-
colorBlock.classList.add(CLASSES.legendColor);
|
|
11
|
-
textBlock.classList.add(CLASSES.legendLabel);
|
|
12
|
-
textBlock.textContent = text;
|
|
13
|
-
itemWrapper.append(colorBlock, textBlock);
|
|
14
|
-
document.body.append(itemWrapper);
|
|
15
|
-
const sumWidth = itemWrapper.getBoundingClientRect().width
|
|
16
|
-
+ parseFloat(window.getComputedStyle(itemWrapper, null).getPropertyValue('margin-left'))
|
|
17
|
-
+ parseFloat(window.getComputedStyle(itemWrapper, null).getPropertyValue('margin-right'));
|
|
18
|
-
itemWrapper.remove();
|
|
19
|
-
return sumWidth;
|
|
20
|
-
}
|
|
21
3
|
//TODO: find better solution
|
|
22
4
|
static findElementsAmountByLegendSize(items, position, legendBlockWidth, legendBlockHeight) {
|
|
23
5
|
const legendWrapper = this.getLegendWrapperEl(legendBlockWidth, position === "right" ? "column" : "row");
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MdtChartsTwoDimLegend } from "../../../config/config";
|
|
2
2
|
import { LegendBlockModel } from "../../model";
|
|
3
3
|
import { TwoDimConfigReader } from "../../modelInstance/configReader";
|
|
4
4
|
import { ModelInstance } from "../../modelInstance/modelInstance";
|
|
5
5
|
export declare class TwoDimLegendModel {
|
|
6
6
|
private configReader;
|
|
7
7
|
constructor(configReader: TwoDimConfigReader);
|
|
8
|
-
recalcMarginWith2DLegend(modelInstance: ModelInstance, legendBlockModel: LegendBlockModel, legendOptions:
|
|
8
|
+
recalcMarginWith2DLegend(modelInstance: ModelInstance, legendBlockModel: LegendBlockModel, legendOptions: MdtChartsTwoDimLegend): void;
|
|
9
9
|
private getLegendModel;
|
|
10
10
|
}
|
|
@@ -24,7 +24,9 @@ export class TwoDimLegendModel {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
getLegendModel(legendOptions) {
|
|
27
|
-
|
|
27
|
+
var _a;
|
|
28
|
+
const position = legendOptions.show
|
|
29
|
+
? (_a = legendOptions.position) !== null && _a !== void 0 ? _a : "top" : "off";
|
|
28
30
|
return {
|
|
29
31
|
position
|
|
30
32
|
};
|
|
@@ -7,7 +7,7 @@ export declare enum ScaleType {
|
|
|
7
7
|
Value = 1
|
|
8
8
|
}
|
|
9
9
|
export declare class ScaleModel {
|
|
10
|
-
getScaleKey(allowableKeys: string[], orient: ChartOrientation, canvasModel: CanvasModel, charts: MdtChartsTwoDimensionalChart[],
|
|
10
|
+
getScaleKey(allowableKeys: string[], orient: ChartOrientation, canvasModel: CanvasModel, charts: MdtChartsTwoDimensionalChart[], bandLikeCharts: MdtChartsTwoDimensionalChart[]): ScaleKeyModel;
|
|
11
11
|
getScaleLinear(options: MdtChartsTwoDimensionalOptions, dataRows: MdtChartsDataRow[], canvasModel: CanvasModel, configReader?: TwoDimConfigReader): ScaleValueModel;
|
|
12
12
|
getScaleSecondaryLinear(options: MdtChartsTwoDimensionalOptions, dataRows: MdtChartsDataRow[], canvasModel: CanvasModel, configReader?: TwoDimConfigReader): ScaleValueModel;
|
|
13
13
|
private getScaleKeyType;
|
|
@@ -6,7 +6,7 @@ export var ScaleType;
|
|
|
6
6
|
ScaleType[ScaleType["Value"] = 1] = "Value";
|
|
7
7
|
})(ScaleType || (ScaleType = {}));
|
|
8
8
|
export class ScaleModel {
|
|
9
|
-
getScaleKey(allowableKeys, orient, canvasModel, charts,
|
|
9
|
+
getScaleKey(allowableKeys, orient, canvasModel, charts, bandLikeCharts) {
|
|
10
10
|
return {
|
|
11
11
|
domain: allowableKeys,
|
|
12
12
|
range: {
|
|
@@ -14,7 +14,7 @@ export class ScaleModel {
|
|
|
14
14
|
end: getScaleKeyRangePeek(orient, canvasModel)
|
|
15
15
|
},
|
|
16
16
|
type: this.getScaleKeyType(charts),
|
|
17
|
-
elementsAmount: getElementsAmountForScale(
|
|
17
|
+
elementsAmount: getElementsAmountForScale(bandLikeCharts)
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
getScaleLinear(options, dataRows, canvasModel, configReader) {
|
|
@@ -42,8 +42,8 @@ export class ScaleModel {
|
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
getScaleKeyType(charts) {
|
|
45
|
-
if (charts.
|
|
46
|
-
return '
|
|
47
|
-
return '
|
|
45
|
+
if (charts.some((chart) => chart.type === 'bar' || chart.type === 'dot'))
|
|
46
|
+
return 'band';
|
|
47
|
+
return 'point';
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -2,4 +2,4 @@ import { ChartOrientation, MdtChartsTwoDimensionalChart } from "../../../config/
|
|
|
2
2
|
import { CanvasSizesModel } from "../../modelInstance/canvasModel/canvasSizesModel/canvasSizeModel";
|
|
3
3
|
export declare function getScaleKeyRangePeek(chartOrientation: ChartOrientation, canvasModel: CanvasSizesModel): number;
|
|
4
4
|
export declare function getScaleValueRangePeek(chartOrientation: string, canvasModel: CanvasSizesModel): number;
|
|
5
|
-
export declare function getElementsAmountForScale(
|
|
5
|
+
export declare function getElementsAmountForScale(bandLikeCharts: MdtChartsTwoDimensionalChart[]): number;
|
|
@@ -8,15 +8,21 @@ export function getScaleValueRangePeek(chartOrientation, canvasModel) {
|
|
|
8
8
|
return canvasModel.getChartBlockHeight();
|
|
9
9
|
return canvasModel.getChartBlockWidth();
|
|
10
10
|
}
|
|
11
|
-
export function getElementsAmountForScale(
|
|
12
|
-
if (
|
|
11
|
+
export function getElementsAmountForScale(bandLikeCharts) {
|
|
12
|
+
if (bandLikeCharts.length === 0)
|
|
13
13
|
return 1;
|
|
14
|
-
let
|
|
15
|
-
|
|
16
|
-
if (chart.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
let barAmounts = {};
|
|
15
|
+
bandLikeCharts.forEach(chart => {
|
|
16
|
+
if (!barAmounts[chart.type])
|
|
17
|
+
barAmounts[chart.type] = 0;
|
|
18
|
+
if (chart.type === 'dot')
|
|
19
|
+
barAmounts[chart.type] = 1;
|
|
20
|
+
if (chart.type === 'bar') {
|
|
21
|
+
if (chart.isSegmented)
|
|
22
|
+
barAmounts[chart.type] += 1;
|
|
23
|
+
else
|
|
24
|
+
barAmounts[chart.type] += chart.data.valueFields.length;
|
|
25
|
+
}
|
|
20
26
|
});
|
|
21
|
-
return
|
|
27
|
+
return Math.max(...Object.values(barAmounts));
|
|
22
28
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { BlockMargin, Orient, ValueLabelAnchor, ValueLabelDominantBaseline } from "../../model";
|
|
2
|
+
import { BoundingRect } from "../../../engine/features/valueLabelsCollision/valueLabelsCollision";
|
|
3
|
+
import { Size } from "../../../config/config";
|
|
2
4
|
interface ValueLabelAlignment {
|
|
3
5
|
dominantBaseline: ValueLabelDominantBaseline;
|
|
4
6
|
textAnchor: ValueLabelAnchor;
|
|
@@ -6,4 +8,8 @@ interface ValueLabelAlignment {
|
|
|
6
8
|
export declare function getValueLabelY(scaledValue: number, keyAxisOrient: Orient, margin: BlockMargin): number;
|
|
7
9
|
export declare function getValueLabelX(scaledValue: number, keyAxisOrient: Orient, margin: BlockMargin): number;
|
|
8
10
|
export declare function calculateValueLabelAlignment(keyAxisOrient: Orient): ValueLabelAlignment;
|
|
11
|
+
export declare function hasCollisionLeftSide(labelClientRect: BoundingRect, margin: BlockMargin): boolean;
|
|
12
|
+
export declare function hasCollisionRightSide(labelClientRect: BoundingRect, blockSize: Size, margin: BlockMargin): boolean;
|
|
13
|
+
export declare function shiftCoordinateXLeft(labelClientRect: BoundingRect): void;
|
|
14
|
+
export declare function shiftCoordinateXRight(labelClientRect: BoundingRect): void;
|
|
9
15
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const OFFSET_SIZE_PX = 10;
|
|
2
|
+
const BORDER_OFFSET_SIZE_PX = 2;
|
|
2
3
|
export function getValueLabelY(scaledValue, keyAxisOrient, margin) {
|
|
3
4
|
switch (keyAxisOrient) {
|
|
4
5
|
case 'bottom':
|
|
@@ -31,3 +32,15 @@ export function calculateValueLabelAlignment(keyAxisOrient) {
|
|
|
31
32
|
return { dominantBaseline: "middle", textAnchor: "end" };
|
|
32
33
|
}
|
|
33
34
|
}
|
|
35
|
+
export function hasCollisionLeftSide(labelClientRect, margin) {
|
|
36
|
+
return labelClientRect.x - labelClientRect.width / 2 <= margin.left;
|
|
37
|
+
}
|
|
38
|
+
export function hasCollisionRightSide(labelClientRect, blockSize, margin) {
|
|
39
|
+
return labelClientRect.x + labelClientRect.width / 2 >= blockSize.width - margin.right;
|
|
40
|
+
}
|
|
41
|
+
export function shiftCoordinateXLeft(labelClientRect) {
|
|
42
|
+
labelClientRect.x -= labelClientRect.width / 2 + BORDER_OFFSET_SIZE_PX;
|
|
43
|
+
}
|
|
44
|
+
export function shiftCoordinateXRight(labelClientRect) {
|
|
45
|
+
labelClientRect.x += +labelClientRect.width / 2 + BORDER_OFFSET_SIZE_PX;
|
|
46
|
+
}
|
package/lib/model/model.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { ChartOrientation, MdtChartsColorField, IntervalChartType, PolarChartType, Size, TooltipOptions, TwoDimensionalChartType, AxisLabelPosition, ShowTickFn, MdtChartsDataRow, TwoDimensionalValueGroup,
|
|
1
|
+
import { ChartOrientation, MdtChartsColorField, IntervalChartType, PolarChartType, Size, TooltipOptions, TwoDimensionalChartType, AxisLabelPosition, ShowTickFn, MdtChartsDataRow, TwoDimensionalValueGroup, ValueLabelsCollisionMode } from "../config/config";
|
|
2
2
|
import { DataType, DonutOptionsCanvas, Formatter, StaticLegendBlockCanvas, TooltipSettings, Transitions } from "../designer/designerConfig";
|
|
3
|
+
import { BoundingRect } from "../engine/features/valueLabelsCollision/valueLabelsCollision";
|
|
3
4
|
declare type AxisType = "key" | "value";
|
|
4
5
|
export declare type Orient = "top" | "bottom" | "left" | "right";
|
|
5
6
|
export declare type ScaleKeyType = "band" | "point";
|
|
@@ -134,6 +135,10 @@ export interface AxisModelOptions {
|
|
|
134
135
|
cssClass: string;
|
|
135
136
|
ticks: AxisTicksModel;
|
|
136
137
|
labels: AxisLabelModel;
|
|
138
|
+
line: AxisLineModel;
|
|
139
|
+
}
|
|
140
|
+
export interface AxisLineModel {
|
|
141
|
+
visible: boolean;
|
|
137
142
|
}
|
|
138
143
|
export interface TranslateModel {
|
|
139
144
|
translateX: number;
|
|
@@ -155,11 +160,18 @@ export interface AdditionalElementsOptions {
|
|
|
155
160
|
}
|
|
156
161
|
export interface GridLineOptions {
|
|
157
162
|
flag: GridLineFlag;
|
|
163
|
+
styles: GridLineStyles;
|
|
158
164
|
}
|
|
159
165
|
export interface GridLineFlag {
|
|
160
166
|
key: boolean;
|
|
161
167
|
value: boolean;
|
|
162
168
|
}
|
|
169
|
+
interface GridLineStyles {
|
|
170
|
+
dash: GridLineStylesDash;
|
|
171
|
+
}
|
|
172
|
+
interface GridLineStylesDash {
|
|
173
|
+
on: boolean;
|
|
174
|
+
}
|
|
163
175
|
export interface TwoDimChartElementsSettings {
|
|
164
176
|
bar: BarChartSettings;
|
|
165
177
|
lineLike: LineLikeChartSettings;
|
|
@@ -194,9 +206,41 @@ interface LineLikeChartCurveOptions {
|
|
|
194
206
|
interface BarLikeChartHatchOptions {
|
|
195
207
|
on: boolean;
|
|
196
208
|
}
|
|
209
|
+
export interface BarLikeChartBorderRadius {
|
|
210
|
+
grouped: BarBorderRadius;
|
|
211
|
+
segmented: SegmentedBarBorderRadius;
|
|
212
|
+
}
|
|
213
|
+
export interface BarBorderRadius {
|
|
214
|
+
topLeft: number;
|
|
215
|
+
topRight: number;
|
|
216
|
+
bottomLeft: number;
|
|
217
|
+
bottomRight: number;
|
|
218
|
+
}
|
|
219
|
+
interface SegmentedBarBorderRadius {
|
|
220
|
+
handle: (segmentIndex: number) => BarBorderRadius;
|
|
221
|
+
}
|
|
197
222
|
export interface TwoDimensionalValueLabels {
|
|
198
223
|
collision: ValueLabelsCollision;
|
|
199
224
|
}
|
|
225
|
+
export interface ValueLabelsCollision {
|
|
226
|
+
otherValueLables: OtherValueLables;
|
|
227
|
+
chartBlock: ValueLabelsChartBlock;
|
|
228
|
+
}
|
|
229
|
+
export interface OtherValueLables {
|
|
230
|
+
mode: ValueLabelsCollisionMode;
|
|
231
|
+
}
|
|
232
|
+
export interface ValueLabelsChartBlock {
|
|
233
|
+
left: {
|
|
234
|
+
mode: "none" | "shift";
|
|
235
|
+
hasCollision: (labelClientRect: BoundingRect) => boolean;
|
|
236
|
+
shiftCoordinate: (labelClientRect: BoundingRect) => void;
|
|
237
|
+
};
|
|
238
|
+
right: {
|
|
239
|
+
mode: "none" | "shift";
|
|
240
|
+
hasCollision: (labelClientRect: BoundingRect) => boolean;
|
|
241
|
+
shiftCoordinate: (labelClientRect: BoundingRect) => void;
|
|
242
|
+
};
|
|
243
|
+
}
|
|
200
244
|
export interface DonutChartSettings extends Omit<DonutOptionsCanvas, "aggregatorPad" | "thickness"> {
|
|
201
245
|
aggregator: DonutAggregatorModel;
|
|
202
246
|
thickness: DonutThicknessOptions;
|
|
@@ -234,11 +278,13 @@ export interface ChartLegendModel {
|
|
|
234
278
|
lineViewOptions: TwoDimensionalChartLegendLineModel;
|
|
235
279
|
}
|
|
236
280
|
export declare type LegendMarkerShape = "default" | "bar" | "line";
|
|
237
|
-
export interface TwoDimensionalChartLegendBarModel
|
|
281
|
+
export interface TwoDimensionalChartLegendBarModel {
|
|
282
|
+
hatch: BarLikeChartHatchOptions;
|
|
283
|
+
borderRadius: BarBorderRadius;
|
|
238
284
|
width: number;
|
|
239
285
|
}
|
|
240
286
|
export interface TwoDimensionalChartLegendLineModel extends Omit<TwoDimensionalLineLikeChartViewModel, 'renderForKey'> {
|
|
241
|
-
|
|
287
|
+
length: number;
|
|
242
288
|
}
|
|
243
289
|
interface TwoDimensionalLineLikeChartModel {
|
|
244
290
|
lineLikeViewOptions: TwoDimensionalLineLikeChartViewModel;
|
|
@@ -246,14 +292,16 @@ interface TwoDimensionalLineLikeChartModel {
|
|
|
246
292
|
}
|
|
247
293
|
interface TwoDimensionalLineLikeChartViewModel {
|
|
248
294
|
dashedStyles: LineLikeChartDashOptions;
|
|
295
|
+
strokeWidth: number;
|
|
249
296
|
renderForKey: LineLikeChartRenderFn;
|
|
250
297
|
}
|
|
251
298
|
export declare type LineLikeChartRenderFn = (dataRow: MdtChartsDataRow, valueFieldName: string) => boolean;
|
|
252
299
|
interface TwoDimensionalBarLikeChartModel {
|
|
253
300
|
barViewOptions: TwoDimensionalBarLikeChartViewModel;
|
|
254
301
|
}
|
|
255
|
-
interface TwoDimensionalBarLikeChartViewModel {
|
|
302
|
+
export interface TwoDimensionalBarLikeChartViewModel {
|
|
256
303
|
hatch: BarLikeChartHatchOptions;
|
|
304
|
+
borderRadius: BarLikeChartBorderRadius;
|
|
257
305
|
}
|
|
258
306
|
interface TwoDimensionalAreaChartModel {
|
|
259
307
|
areaViewOptions: AreaChartViewOptions;
|
|
@@ -272,14 +320,26 @@ export interface AreaViewBorderLine {
|
|
|
272
320
|
on: boolean;
|
|
273
321
|
colorStyle: ChartStyle;
|
|
274
322
|
}
|
|
275
|
-
export interface
|
|
323
|
+
export interface DotChartModel {
|
|
324
|
+
dotViewOptions: DotChartViewModel;
|
|
325
|
+
}
|
|
326
|
+
export interface DotChartViewModel {
|
|
327
|
+
shape: DotChartShapeOptions;
|
|
328
|
+
}
|
|
329
|
+
interface DotChartShapeOptions {
|
|
330
|
+
type: "line";
|
|
331
|
+
handleStartCoordinate: (calculatedBandItemStartCoordinate: number) => number;
|
|
332
|
+
handleEndCoordinate: (calculatedBandItemSize: number) => number;
|
|
333
|
+
width: number;
|
|
334
|
+
}
|
|
335
|
+
export interface TwoDimensionalChartModel extends ChartModel, TwoDimensionalLineLikeChartModel, TwoDimensionalBarLikeChartModel, TwoDimensionalAreaChartModel, DotChartModel, DotChartModel {
|
|
276
336
|
type: TwoDimensionalChartType;
|
|
277
337
|
data: TwoDimensionalChartDataModel;
|
|
278
338
|
index: number;
|
|
279
339
|
embeddedLabels: EmbeddedLabelTypeModel;
|
|
280
340
|
isSegmented: boolean;
|
|
281
341
|
legend: ChartLegendModel;
|
|
282
|
-
valueLabels
|
|
342
|
+
valueLabels: TwoDimChartValueLabelsOptions;
|
|
283
343
|
}
|
|
284
344
|
export interface IntervalChartModel extends Omit<ChartModel, "legend"> {
|
|
285
345
|
type: IntervalChartType;
|
|
@@ -76,12 +76,10 @@ export function assembleModel(config, data, designerConfig) {
|
|
|
76
76
|
options: null,
|
|
77
77
|
dataSettings: null
|
|
78
78
|
};
|
|
79
|
-
const dataRows = modelInstance.dataModel.repository.getRawRows();
|
|
80
|
-
const resolvedTitle = getResolvedTitle(config.options.title, dataRows);
|
|
81
79
|
const otherComponents = OtherComponentsModel.getOtherComponentsModel({
|
|
82
80
|
elementsOptions: designerConfig.elementsOptions,
|
|
83
81
|
legendConfig: designerConfig.canvas.legendBlock,
|
|
84
|
-
title:
|
|
82
|
+
title: getResolvedTitle(config.options.title, modelInstance.dataModel.repository.getRawRows())
|
|
85
83
|
}, modelInstance);
|
|
86
84
|
const marginModel = new MarginModel(designerConfig, config);
|
|
87
85
|
marginModel.initMargin(otherComponents, modelInstance);
|
|
@@ -55,18 +55,18 @@ export class TwoDimConfigReader {
|
|
|
55
55
|
return !!this.options.axis.valueSecondary && this.options.charts.some(chart => chart.data.valueGroup === 'secondary');
|
|
56
56
|
}
|
|
57
57
|
getValueLabelFormatterForChart(chartIndex) {
|
|
58
|
-
var _a, _b, _c;
|
|
58
|
+
var _a, _b, _c, _d;
|
|
59
59
|
const chart = this.options.charts[chartIndex];
|
|
60
60
|
const axis = this.options.axis;
|
|
61
|
-
if (chart.valueLabels.format)
|
|
61
|
+
if ((_a = chart.valueLabels) === null || _a === void 0 ? void 0 : _a.format)
|
|
62
62
|
return chart.valueLabels.format;
|
|
63
63
|
if (chart.data.valueGroup === "secondary") {
|
|
64
|
-
if ((
|
|
64
|
+
if ((_b = axis.valueSecondary.labels) === null || _b === void 0 ? void 0 : _b.format)
|
|
65
65
|
return axis.valueSecondary.labels.format;
|
|
66
|
-
else if ((
|
|
66
|
+
else if ((_c = axis.value.labels) === null || _c === void 0 ? void 0 : _c.format)
|
|
67
67
|
return axis.value.labels.format;
|
|
68
68
|
}
|
|
69
|
-
else if ((
|
|
69
|
+
else if ((_d = axis.value.labels) === null || _d === void 0 ? void 0 : _d.format)
|
|
70
70
|
return axis.value.labels.format;
|
|
71
71
|
const valueFieldFormat = chart.data.valueFields[0].format;
|
|
72
72
|
return (v) => this.designerConfig.dataFormat.formatters(v, { type: valueFieldFormat });
|
|
@@ -47,13 +47,21 @@ export class PolarModel {
|
|
|
47
47
|
chartsModel.push({
|
|
48
48
|
type: chart.type,
|
|
49
49
|
data: Object.assign({}, chart.data),
|
|
50
|
-
tooltip:
|
|
50
|
+
tooltip: { show: true },
|
|
51
51
|
cssClasses: ChartStyleModelService.getCssClasses(0),
|
|
52
52
|
style: ChartStyleModelService.getChartStyle(dataLength, chartStyleConfig),
|
|
53
53
|
legend: {
|
|
54
54
|
markerShape: "default",
|
|
55
|
-
barViewOptions: {
|
|
56
|
-
|
|
55
|
+
barViewOptions: {
|
|
56
|
+
hatch: { on: false },
|
|
57
|
+
borderRadius: { topLeft: 0, topRight: 0, bottomLeft: 0, bottomRight: 0 },
|
|
58
|
+
width: 0
|
|
59
|
+
},
|
|
60
|
+
lineViewOptions: {
|
|
61
|
+
dashedStyles: { on: false, dashSize: 0, gapSize: 0 },
|
|
62
|
+
strokeWidth: 0,
|
|
63
|
+
length: 0
|
|
64
|
+
}
|
|
57
65
|
}
|
|
58
66
|
});
|
|
59
67
|
return chartsModel;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { AreaChartViewOptions, ChartLegendModel, ChartStyle, GradientId, LineLikeChartDashOptions, LineLikeChartShapeOptions } from "../../model";
|
|
1
|
+
import { AreaChartViewOptions, BarBorderRadius, ChartLegendModel, ChartStyle, GradientId, LineLikeChartDashOptions, LineLikeChartShapeOptions, Orient, TwoDimensionalBarLikeChartViewModel } from "../../model";
|
|
2
2
|
import { ChartOrientation, MdtChartsLineLikeChartDashedStyles, MdtChartsTwoDimensionalChart, TwoDimensionalChartType } from "../../../config/config";
|
|
3
3
|
import { MdtChartsLineLikeChartShape } from "../../../designer/designerConfig";
|
|
4
|
+
export declare const LINE_CHART_DEFAULT_WIDTH = 2;
|
|
4
5
|
export declare function parseShape(chartOrientation: ChartOrientation, configOptions?: MdtChartsLineLikeChartShape): LineLikeChartShapeOptions;
|
|
5
6
|
export declare function parseDashStyles(configOptions?: MdtChartsLineLikeChartDashedStyles): LineLikeChartDashOptions;
|
|
7
|
+
export declare function getBarViewOptions(chart: MdtChartsTwoDimensionalChart, keyAxisOrient: Orient): TwoDimensionalBarLikeChartViewModel;
|
|
8
|
+
export declare function getSegmentedRadiusValues(segmentsLength: number, segmentIndex: number, keyAxisOrient: Orient, defaultRadius: number): BarBorderRadius;
|
|
6
9
|
export declare function getLegendMarkerOptions(chart: MdtChartsTwoDimensionalChart): ChartLegendModel;
|
|
7
10
|
export declare function getWidthOfLegendMarkerByType(chartType: TwoDimensionalChartType): number;
|
|
8
11
|
export declare function getAreaViewOptions(chart: MdtChartsTwoDimensionalChart, chartIndex: number, style: ChartStyle): AreaChartViewOptions;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { LineCurveType } from "../../model";
|
|
2
2
|
import { styledElementValues } from "../../modelBuilder";
|
|
3
|
+
const BAR_CHART_BORDER_RADIUS_DEFAULT = 2;
|
|
4
|
+
export const LINE_CHART_DEFAULT_WIDTH = 2;
|
|
3
5
|
export function parseShape(chartOrientation, configOptions) {
|
|
4
6
|
var _a;
|
|
5
7
|
const curveType = (_a = configOptions === null || configOptions === void 0 ? void 0 : configOptions.curve) === null || _a === void 0 ? void 0 : _a.type;
|
|
@@ -27,17 +29,72 @@ export function parseDashStyles(configOptions) {
|
|
|
27
29
|
gapSize: (_c = configOptions === null || configOptions === void 0 ? void 0 : configOptions.gapSize) !== null && _c !== void 0 ? _c : DEFAULT_GAP_SIZE_PX
|
|
28
30
|
};
|
|
29
31
|
}
|
|
32
|
+
export function getBarViewOptions(chart, keyAxisOrient) {
|
|
33
|
+
var _a, _b, _c, _d, _e, _f;
|
|
34
|
+
const hatch = { on: (_c = (_b = (_a = chart.barStyles) === null || _a === void 0 ? void 0 : _a.hatch) === null || _b === void 0 ? void 0 : _b.on) !== null && _c !== void 0 ? _c : false };
|
|
35
|
+
const defaultRadius = (_f = (_e = (_d = chart.barStyles) === null || _d === void 0 ? void 0 : _d.borderRadius) === null || _e === void 0 ? void 0 : _e.value) !== null && _f !== void 0 ? _f : BAR_CHART_BORDER_RADIUS_DEFAULT;
|
|
36
|
+
const borderRadius = {
|
|
37
|
+
grouped: getRadiusValues(defaultRadius),
|
|
38
|
+
segmented: {
|
|
39
|
+
handle: (valueIndex) => getSegmentedRadiusValues(chart.data.valueFields.length, valueIndex, keyAxisOrient, defaultRadius),
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
return { hatch, borderRadius };
|
|
43
|
+
}
|
|
44
|
+
function getRadiusValues(defaultRadius) {
|
|
45
|
+
return {
|
|
46
|
+
topLeft: defaultRadius,
|
|
47
|
+
topRight: defaultRadius,
|
|
48
|
+
bottomLeft: defaultRadius,
|
|
49
|
+
bottomRight: defaultRadius
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export function getSegmentedRadiusValues(segmentsLength, segmentIndex, keyAxisOrient, defaultRadius) {
|
|
53
|
+
const radiusConfigs = {
|
|
54
|
+
first: {
|
|
55
|
+
top: { topLeft: defaultRadius, topRight: defaultRadius, bottomLeft: 0, bottomRight: 0 },
|
|
56
|
+
bottom: { topLeft: 0, topRight: 0, bottomLeft: defaultRadius, bottomRight: defaultRadius },
|
|
57
|
+
left: { topLeft: defaultRadius, topRight: 0, bottomLeft: defaultRadius, bottomRight: 0 },
|
|
58
|
+
right: { topLeft: 0, topRight: defaultRadius, bottomLeft: 0, bottomRight: defaultRadius },
|
|
59
|
+
},
|
|
60
|
+
last: {
|
|
61
|
+
top: { topLeft: 0, topRight: 0, bottomLeft: defaultRadius, bottomRight: defaultRadius },
|
|
62
|
+
bottom: { topLeft: defaultRadius, topRight: defaultRadius, bottomLeft: 0, bottomRight: 0 },
|
|
63
|
+
left: { topLeft: 0, topRight: defaultRadius, bottomLeft: 0, bottomRight: defaultRadius },
|
|
64
|
+
right: { topLeft: defaultRadius, topRight: 0, bottomLeft: defaultRadius, bottomRight: 0 },
|
|
65
|
+
},
|
|
66
|
+
middle: { topLeft: 0, topRight: 0, bottomLeft: 0, bottomRight: 0 },
|
|
67
|
+
default: getRadiusValues(defaultRadius)
|
|
68
|
+
};
|
|
69
|
+
if (segmentsLength === 1)
|
|
70
|
+
return radiusConfigs.default;
|
|
71
|
+
else if (segmentIndex === 0)
|
|
72
|
+
return radiusConfigs.first[keyAxisOrient];
|
|
73
|
+
else if (segmentIndex === segmentsLength - 1)
|
|
74
|
+
return radiusConfigs.last[keyAxisOrient];
|
|
75
|
+
else
|
|
76
|
+
return radiusConfigs.middle;
|
|
77
|
+
}
|
|
30
78
|
export function getLegendMarkerOptions(chart) {
|
|
31
|
-
var _a, _b, _c, _d;
|
|
79
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
32
80
|
const shapeByType = {
|
|
33
81
|
area: "default",
|
|
34
82
|
bar: "bar",
|
|
35
|
-
line: "line"
|
|
83
|
+
line: "line",
|
|
84
|
+
dot: "default"
|
|
36
85
|
};
|
|
37
86
|
return {
|
|
38
87
|
markerShape: shapeByType[chart.type],
|
|
39
|
-
barViewOptions: {
|
|
40
|
-
|
|
88
|
+
barViewOptions: {
|
|
89
|
+
hatch: { on: (_c = (_b = (_a = chart.barStyles) === null || _a === void 0 ? void 0 : _a.hatch) === null || _b === void 0 ? void 0 : _b.on) !== null && _c !== void 0 ? _c : false },
|
|
90
|
+
borderRadius: getRadiusValues((_f = (_e = (_d = chart.barStyles) === null || _d === void 0 ? void 0 : _d.borderRadius) === null || _e === void 0 ? void 0 : _e.value) !== null && _f !== void 0 ? _f : BAR_CHART_BORDER_RADIUS_DEFAULT),
|
|
91
|
+
width: getWidthOfLegendMarkerByType("bar")
|
|
92
|
+
},
|
|
93
|
+
lineViewOptions: {
|
|
94
|
+
dashedStyles: parseDashStyles((_g = chart.lineStyles) === null || _g === void 0 ? void 0 : _g.dash),
|
|
95
|
+
strokeWidth: (_j = (_h = chart.lineStyles) === null || _h === void 0 ? void 0 : _h.width) !== null && _j !== void 0 ? _j : LINE_CHART_DEFAULT_WIDTH,
|
|
96
|
+
length: getWidthOfLegendMarkerByType("line")
|
|
97
|
+
}
|
|
41
98
|
};
|
|
42
99
|
}
|
|
43
100
|
export function getWidthOfLegendMarkerByType(chartType) {
|
|
@@ -17,5 +17,6 @@ export declare class TwoDimensionalModel {
|
|
|
17
17
|
private static findChartsWithEmbeddedKeyLabels;
|
|
18
18
|
private static getEmbeddedLabelType;
|
|
19
19
|
private static getAdditionalElements;
|
|
20
|
-
private static
|
|
20
|
+
private static getChartsByTypes;
|
|
21
|
+
private static getValueLabels;
|
|
21
22
|
}
|