mdt-charts 1.10.3 → 1.12.1
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 +18 -5
- package/lib/designer/designerConfig.d.ts +8 -2
- package/lib/engine/features/aggregator/aggregator.d.ts +4 -3
- package/lib/engine/features/aggregator/aggregator.js +14 -11
- package/lib/engine/features/legend/legend.d.ts +10 -1
- package/lib/engine/features/legend/legend.js +10 -22
- package/lib/engine/features/legend/legendHelper.d.ts +4 -5
- package/lib/engine/features/legend/legendHelper.js +19 -23
- package/lib/engine/features/legend/legendHelperService.d.ts +12 -0
- package/lib/engine/features/legend/legendHelperService.js +30 -0
- package/lib/engine/features/recordOverflowAlert/recordOverflowAlertCore.d.ts +28 -0
- package/lib/engine/features/recordOverflowAlert/recordOverflowAlertCore.js +50 -0
- package/lib/engine/features/title/title.js +2 -0
- package/lib/engine/features/tolltip/tooltip.js +1 -1
- package/lib/engine/filterManager/filterEventManager.d.ts +3 -3
- package/lib/engine/filterManager/filterEventManager.js +4 -4
- package/lib/engine/intervalNotation/intervalManager.js +2 -5
- package/lib/engine/polarNotation/donut/DonutHelper.d.ts +2 -0
- package/lib/engine/polarNotation/donut/DonutHelper.js +20 -3
- package/lib/engine/polarNotation/donut/donut.js +1 -1
- package/lib/engine/polarNotation/extenders/polarRecordOverflowAlert.d.ts +15 -0
- package/lib/engine/polarNotation/extenders/polarRecordOverflowAlert.js +40 -0
- package/lib/engine/polarNotation/polarManager.js +16 -12
- package/lib/engine/twoDimensionalNotation/extenders/twoDimRecordOverflowAlert.d.ts +15 -0
- package/lib/engine/twoDimensionalNotation/extenders/twoDimRecordOverflowAlert.js +32 -0
- package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +13 -7
- package/lib/model/chartStyleModel/TwoDimensionalChartStyleModel.d.ts +19 -0
- package/lib/model/chartStyleModel/TwoDimensionalChartStyleModel.js +61 -0
- package/lib/model/chartStyleModel/chartStyleModel.d.ts +9 -0
- package/lib/model/chartStyleModel/chartStyleModel.js +27 -0
- package/lib/model/{dataManagerModel.d.ts → dataManagerModel/dataManagerModel.d.ts} +18 -6
- package/lib/model/{dataManagerModel.js → dataManagerModel/dataManagerModel.js} +52 -44
- package/lib/model/dataManagerModel/dataManagerModelService.d.ts +5 -0
- package/lib/model/dataManagerModel/dataManagerModelService.js +28 -0
- package/lib/model/featuresModel/axisModel.d.ts +10 -8
- package/lib/model/featuresModel/axisModel.js +28 -26
- package/lib/model/featuresModel/axisModelService.d.ts +4 -0
- package/lib/model/featuresModel/axisModelService.js +11 -0
- package/lib/model/featuresModel/legendModel/legendCanvasModel.d.ts +4 -2
- package/lib/model/featuresModel/legendModel/legendCanvasModel.js +42 -29
- package/lib/model/featuresModel/legendModel/legendModel.d.ts +4 -6
- package/lib/model/featuresModel/legendModel/legendModel.js +18 -21
- package/lib/model/featuresModel/legendModel/polarMarginCalculator.d.ts +11 -0
- package/lib/model/featuresModel/legendModel/polarMarginCalculator.js +42 -0
- package/lib/model/featuresModel/otherComponents.d.ts +9 -2
- package/lib/model/featuresModel/otherComponents.js +6 -4
- package/lib/model/featuresModel/scaleModel.d.ts +7 -6
- package/lib/model/featuresModel/scaleModel.js +9 -9
- package/lib/model/featuresModel/titleModel.d.ts +1 -1
- package/lib/model/featuresModel/titleModel.js +8 -6
- package/lib/model/marginModel.d.ts +7 -6
- package/lib/model/marginModel.js +44 -38
- package/lib/model/model.d.ts +25 -20
- package/lib/model/modelBuilder.js +27 -38
- package/lib/model/modelInstance/canvasModel/canvasModel.d.ts +24 -0
- package/lib/model/modelInstance/canvasModel/canvasModel.js +44 -0
- package/lib/model/modelInstance/canvasModel/legendCanvasModel.d.ts +7 -0
- package/lib/model/modelInstance/canvasModel/legendCanvasModel.js +13 -0
- package/lib/model/modelInstance/canvasModel/titleCanvas.d.ts +9 -0
- package/lib/model/modelInstance/canvasModel/titleCanvas.js +11 -0
- package/lib/model/modelInstance/dataModel.d.ts +11 -0
- package/lib/model/modelInstance/dataModel.js +23 -0
- package/lib/model/modelInstance/modelInstance.d.ts +10 -0
- package/lib/model/modelInstance/modelInstance.js +17 -0
- package/lib/model/notations/intervalModel.d.ts +2 -1
- package/lib/model/notations/intervalModel.js +17 -15
- package/lib/model/notations/polarModel.d.ts +11 -3
- package/lib/model/notations/polarModel.js +40 -8
- package/lib/model/notations/twoDimensionalModel.d.ts +7 -5
- package/lib/model/notations/twoDimensionalModel.js +19 -12
- package/lib/style/charts-main.css +27 -7
- package/lib/style/charts-main.less +27 -7
- package/package.json +3 -2
- package/tsconfig.production.json +23 -0
- package/lib/engine/features/recordOverflowAlert/recordOverflowAlert.d.ts +0 -14
- package/lib/engine/features/recordOverflowAlert/recordOverflowAlert.js +0 -97
- package/lib/model/chartStyleModel.d.ts +0 -16
- package/lib/model/chartStyleModel.js +0 -67
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { AxisModel } from "../featuresModel/axisModel";
|
|
2
|
-
import {
|
|
3
|
-
import { DataManagerModel } from "../dataManagerModel";
|
|
4
|
-
import { LegendModel } from "../featuresModel/legendModel/legendModel";
|
|
2
|
+
import { ChartStyleModelService } from "../chartStyleModel/chartStyleModel";
|
|
3
|
+
import { DataManagerModel } from "../dataManagerModel/dataManagerModel";
|
|
5
4
|
import { AxisType } from "../modelBuilder";
|
|
6
5
|
import { ScaleModel, ScaleType } from "../featuresModel/scaleModel";
|
|
6
|
+
import { TwoDimensionalModel } from "./twoDimensionalModel";
|
|
7
7
|
export class IntervalModel {
|
|
8
|
-
static getOptions(config, designerConfig, margin, dataScope, data) {
|
|
8
|
+
static getOptions(config, designerConfig, margin, dataScope, data, modelInstance) {
|
|
9
9
|
const options = config.options;
|
|
10
|
+
const canvasModel = modelInstance.canvasModel;
|
|
10
11
|
return {
|
|
11
|
-
legend:
|
|
12
|
+
legend: canvasModel.legendCanvas.getModel(),
|
|
12
13
|
title: options.title,
|
|
13
14
|
selectable: !!options.selectable,
|
|
14
15
|
orient: options.orientation,
|
|
@@ -17,7 +18,7 @@ export class IntervalModel {
|
|
|
17
18
|
domain: dataScope.allowableKeys,
|
|
18
19
|
range: {
|
|
19
20
|
start: 0,
|
|
20
|
-
end: ScaleModel.getRangePeek(ScaleType.Key, options.orientation,
|
|
21
|
+
end: ScaleModel.getRangePeek(ScaleType.Key, options.orientation, canvasModel)
|
|
21
22
|
},
|
|
22
23
|
type: 'band',
|
|
23
24
|
elementsAmount: 1
|
|
@@ -26,7 +27,7 @@ export class IntervalModel {
|
|
|
26
27
|
domain: ScaleModel.getDateValueDomain(data, options.chart, options.axis.key.position, options.data.dataSource),
|
|
27
28
|
range: {
|
|
28
29
|
start: 0,
|
|
29
|
-
end: ScaleModel.getRangePeek(ScaleType.Value, options.orientation,
|
|
30
|
+
end: ScaleModel.getRangePeek(ScaleType.Value, options.orientation, canvasModel)
|
|
30
31
|
},
|
|
31
32
|
type: 'datetime'
|
|
32
33
|
}
|
|
@@ -36,14 +37,14 @@ export class IntervalModel {
|
|
|
36
37
|
type: 'key',
|
|
37
38
|
orient: AxisModel.getAxisOrient(AxisType.Key, options.orientation, options.axis.key.position),
|
|
38
39
|
translate: {
|
|
39
|
-
translateX: AxisModel.getAxisTranslateX(AxisType.Key, options.orientation, options.axis.key.position,
|
|
40
|
-
translateY: AxisModel.getAxisTranslateY(AxisType.Key, options.orientation, options.axis.key.position,
|
|
40
|
+
translateX: AxisModel.getAxisTranslateX(AxisType.Key, options.orientation, options.axis.key.position, canvasModel),
|
|
41
|
+
translateY: AxisModel.getAxisTranslateY(AxisType.Key, options.orientation, options.axis.key.position, canvasModel)
|
|
41
42
|
},
|
|
42
43
|
cssClass: 'key-axis',
|
|
43
44
|
ticks: options.axis.key.ticks,
|
|
44
45
|
labels: {
|
|
45
46
|
maxSize: AxisModel.getLabelSize(designerConfig.canvas.axisLabel.maxSize.main, data[options.data.dataSource].map(d => d[options.data.keyField.name])).width,
|
|
46
|
-
position: AxisModel.getKeyAxisLabelPosition(
|
|
47
|
+
position: AxisModel.getKeyAxisLabelPosition(canvasModel, DataManagerModel.getDataValuesByKeyField(data, options.data.dataSource, options.data.keyField.name).length),
|
|
47
48
|
visible: true,
|
|
48
49
|
defaultTooltip: designerConfig.elementsOptions.tooltip.position === 'fixed'
|
|
49
50
|
},
|
|
@@ -53,8 +54,8 @@ export class IntervalModel {
|
|
|
53
54
|
type: 'value',
|
|
54
55
|
orient: AxisModel.getAxisOrient(AxisType.Value, options.orientation, options.axis.value.position),
|
|
55
56
|
translate: {
|
|
56
|
-
translateX: AxisModel.getAxisTranslateX(AxisType.Value, options.orientation, options.axis.value.position,
|
|
57
|
-
translateY: AxisModel.getAxisTranslateY(AxisType.Value, options.orientation, options.axis.value.position,
|
|
57
|
+
translateX: AxisModel.getAxisTranslateX(AxisType.Value, options.orientation, options.axis.value.position, canvasModel),
|
|
58
|
+
translateY: AxisModel.getAxisTranslateY(AxisType.Value, options.orientation, options.axis.value.position, canvasModel)
|
|
58
59
|
},
|
|
59
60
|
cssClass: 'value-axis',
|
|
60
61
|
ticks: options.axis.value.ticks,
|
|
@@ -71,7 +72,8 @@ export class IntervalModel {
|
|
|
71
72
|
type: options.type,
|
|
72
73
|
charts: this.getChartsModel(options.chart, designerConfig.chartStyle),
|
|
73
74
|
additionalElements: this.getAdditionalElements(options),
|
|
74
|
-
tooltip: options.tooltip
|
|
75
|
+
tooltip: options.tooltip,
|
|
76
|
+
chartSettings: TwoDimensionalModel.getChartsSettings(designerConfig.canvas.chartOptions.bar)
|
|
75
77
|
};
|
|
76
78
|
}
|
|
77
79
|
static getAdditionalElements(options) {
|
|
@@ -85,8 +87,8 @@ export class IntervalModel {
|
|
|
85
87
|
type: chart.type,
|
|
86
88
|
data: Object.assign({}, chart.data),
|
|
87
89
|
tooltip: chart.tooltip,
|
|
88
|
-
cssClasses:
|
|
89
|
-
style:
|
|
90
|
+
cssClasses: ChartStyleModelService.getCssClasses(0),
|
|
91
|
+
style: ChartStyleModelService.getChartStyle(1, chartStyleConfig)
|
|
90
92
|
});
|
|
91
93
|
return chartsModel;
|
|
92
94
|
}
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MdtChartsDataSource, MdtChartsPolarOptions } from "../../config/config";
|
|
2
2
|
import { DesignerConfig } from "../../designer/designerConfig";
|
|
3
|
-
import {
|
|
3
|
+
import { PolarOptionsModel, LegendCoordinate } from "../model";
|
|
4
|
+
import { CanvasModel } from "../modelInstance/canvasModel/canvasModel";
|
|
5
|
+
import { ModelInstance } from "../modelInstance/modelInstance";
|
|
6
|
+
/** If donut block has width less than this const, legend change postion from "right" to "bottom" */
|
|
7
|
+
export declare const MIN_DONUT_BLOCK_SIZE = 120;
|
|
4
8
|
export declare class PolarModel {
|
|
5
|
-
static getOptions(
|
|
9
|
+
static getOptions(options: MdtChartsPolarOptions, data: MdtChartsDataSource, designerConfig: DesignerConfig, modelInstance: ModelInstance): PolarOptionsModel;
|
|
10
|
+
static getLegendPositionByBlockSize(canvasModel: CanvasModel): "bottom" | "right";
|
|
11
|
+
static doesChartBlockHasEnoughWidthForContainsLegend(chartBlockWidth: number, legendWidth: number, legendCoordinate: LegendCoordinate): boolean;
|
|
12
|
+
static doesChartBlockHasEnoughHeightForContainsLegend(chartBlockHeight: number, legendCoordinate: LegendCoordinate): boolean;
|
|
13
|
+
private static getDonutSettings;
|
|
6
14
|
private static getChartsModel;
|
|
7
15
|
}
|
|
@@ -1,16 +1,48 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { ChartStyleModelService } from "../chartStyleModel/chartStyleModel";
|
|
2
|
+
/** If donut block has width less than this const, legend change postion from "right" to "bottom" */
|
|
3
|
+
export const MIN_DONUT_BLOCK_SIZE = 120;
|
|
3
4
|
export class PolarModel {
|
|
4
|
-
static getOptions(
|
|
5
|
-
const options = config.options;
|
|
5
|
+
static getOptions(options, data, designerConfig, modelInstance) {
|
|
6
6
|
return {
|
|
7
7
|
type: options.type,
|
|
8
8
|
selectable: !!options.selectable,
|
|
9
9
|
title: options.title,
|
|
10
10
|
data: Object.assign({}, options.data),
|
|
11
11
|
charts: this.getChartsModel(options.chart, data[options.data.dataSource].length, designerConfig.chartStyle),
|
|
12
|
-
legend:
|
|
13
|
-
tooltip: options.tooltip
|
|
12
|
+
legend: modelInstance.canvasModel.legendCanvas.getModel(),
|
|
13
|
+
tooltip: options.tooltip,
|
|
14
|
+
chartCanvas: this.getDonutSettings(designerConfig.canvas.chartOptions.donut, options.chart)
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//TODO: type for returned value
|
|
18
|
+
static getLegendPositionByBlockSize(canvasModel) {
|
|
19
|
+
const widthCoefficientWhenLegendShouldInBottom = 1.5;
|
|
20
|
+
const avgLegendWidth = 100;
|
|
21
|
+
const blockWidth = canvasModel.getBlockSize().width;
|
|
22
|
+
const blockHeight = canvasModel.getBlockSize().height;
|
|
23
|
+
return canvasModel.getChartBlockWidth() < MIN_DONUT_BLOCK_SIZE + avgLegendWidth
|
|
24
|
+
&& blockWidth * widthCoefficientWhenLegendShouldInBottom < blockHeight
|
|
25
|
+
? 'bottom'
|
|
26
|
+
: 'right';
|
|
27
|
+
}
|
|
28
|
+
static doesChartBlockHasEnoughWidthForContainsLegend(chartBlockWidth, legendWidth, legendCoordinate) {
|
|
29
|
+
const rightLegendMargin = legendCoordinate.right.margin;
|
|
30
|
+
return chartBlockWidth - legendWidth - rightLegendMargin.left - rightLegendMargin.right >= MIN_DONUT_BLOCK_SIZE;
|
|
31
|
+
}
|
|
32
|
+
static doesChartBlockHasEnoughHeightForContainsLegend(chartBlockHeight, legendCoordinate) {
|
|
33
|
+
const minHeightForLegend = 30;
|
|
34
|
+
const bottomLegendMargin = legendCoordinate.bottom.margin;
|
|
35
|
+
const heightForLegend = chartBlockHeight - bottomLegendMargin.bottom - bottomLegendMargin.top - MIN_DONUT_BLOCK_SIZE;
|
|
36
|
+
return heightForLegend >= minHeightForLegend;
|
|
37
|
+
}
|
|
38
|
+
static getDonutSettings(settings, chartOptions) {
|
|
39
|
+
return {
|
|
40
|
+
padAngle: settings.padAngle,
|
|
41
|
+
thickness: Object.assign({}, settings.thickness),
|
|
42
|
+
aggregator: {
|
|
43
|
+
margin: settings.aggregatorPad,
|
|
44
|
+
text: chartOptions.aggregator.text
|
|
45
|
+
}
|
|
14
46
|
};
|
|
15
47
|
}
|
|
16
48
|
static getChartsModel(chart, dataLength, chartStyleConfig) {
|
|
@@ -19,8 +51,8 @@ export class PolarModel {
|
|
|
19
51
|
type: chart.type,
|
|
20
52
|
data: Object.assign({}, chart.data),
|
|
21
53
|
tooltip: chart.tooltip,
|
|
22
|
-
cssClasses:
|
|
23
|
-
style:
|
|
54
|
+
cssClasses: ChartStyleModelService.getCssClasses(0),
|
|
55
|
+
style: ChartStyleModelService.getChartStyle(dataLength, chartStyleConfig)
|
|
24
56
|
});
|
|
25
57
|
return chartsModel;
|
|
26
58
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { ChartOrientation,
|
|
2
|
-
import { DesignerConfig } from "../../designer/designerConfig";
|
|
3
|
-
import {
|
|
1
|
+
import { ChartOrientation, MdtChartsDataSource, TwoDimensionalChart, MdtChartsTwoDimensionalOptions } from "../../config/config";
|
|
2
|
+
import { BarOptionsCanvas, DesignerConfig } from "../../designer/designerConfig";
|
|
3
|
+
import { DataScope, TwoDimensionalOptionsModel, TwoDimChartElementsSettings } from "../model";
|
|
4
|
+
import { ModelInstance } from "../modelInstance/modelInstance";
|
|
4
5
|
export declare class TwoDimensionalModel {
|
|
5
|
-
static getOptions(
|
|
6
|
+
static getOptions(options: MdtChartsTwoDimensionalOptions, designerConfig: DesignerConfig, dataScope: DataScope, data: MdtChartsDataSource, modelInstance: ModelInstance): TwoDimensionalOptionsModel;
|
|
6
7
|
static getChartsEmbeddedLabelsFlag(charts: TwoDimensionalChart[], chartOrientation: ChartOrientation): boolean;
|
|
7
8
|
/**
|
|
8
9
|
* Сортирует список чартов в порядке: area - bar - line.
|
|
@@ -10,10 +11,11 @@ export declare class TwoDimensionalModel {
|
|
|
10
11
|
* @param charts Чарты из конфига
|
|
11
12
|
*/
|
|
12
13
|
static sortCharts(charts: TwoDimensionalChart[]): void;
|
|
14
|
+
static getChartsSettings(barSettings: BarOptionsCanvas): TwoDimChartElementsSettings;
|
|
13
15
|
private static getChartsModel;
|
|
14
16
|
private static findChartsWithEmbeddedKeyLabels;
|
|
15
17
|
private static getEmbeddedLabelType;
|
|
16
18
|
private static getAdditionalElements;
|
|
17
19
|
private static getChartsByType;
|
|
18
|
-
|
|
20
|
+
static getChartsValueFieldsAmount(charts: TwoDimensionalChart[]): number[];
|
|
19
21
|
}
|
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ChartStyleModelService } from "../chartStyleModel/chartStyleModel";
|
|
2
|
+
import { TwoDimensionalChartStyleModel } from "../chartStyleModel/TwoDimensionalChartStyleModel";
|
|
2
3
|
import { AxisModel } from "../featuresModel/axisModel";
|
|
3
|
-
import { LegendModel } from "../featuresModel/legendModel/legendModel";
|
|
4
4
|
import { ScaleModel } from "../featuresModel/scaleModel";
|
|
5
5
|
export class TwoDimensionalModel {
|
|
6
|
-
static getOptions(
|
|
7
|
-
const
|
|
6
|
+
static getOptions(options, designerConfig, dataScope, data, modelInstance) {
|
|
7
|
+
const canvasModel = modelInstance.canvasModel;
|
|
8
8
|
return {
|
|
9
|
-
legend:
|
|
9
|
+
legend: canvasModel.legendCanvas.getModel(),
|
|
10
10
|
title: options.title,
|
|
11
11
|
selectable: !!options.selectable,
|
|
12
12
|
orient: options.orientation,
|
|
13
13
|
scale: {
|
|
14
|
-
key: ScaleModel.getScaleKey(dataScope.allowableKeys, options.orientation,
|
|
15
|
-
value: ScaleModel.getScaleLinear(options, data,
|
|
14
|
+
key: ScaleModel.getScaleKey(dataScope.allowableKeys, options.orientation, canvasModel, options.charts, this.getChartsByType(options.charts, 'bar')),
|
|
15
|
+
value: ScaleModel.getScaleLinear(options, data, canvasModel)
|
|
16
16
|
},
|
|
17
17
|
axis: {
|
|
18
|
-
key: AxisModel.getKeyAxis(options
|
|
19
|
-
value: AxisModel.getValueAxis(options.orientation, options.axis.value, designerConfig.canvas.axisLabel,
|
|
18
|
+
key: AxisModel.getKeyAxis(options, data, designerConfig.canvas.axisLabel, canvasModel, designerConfig.elementsOptions.tooltip),
|
|
19
|
+
value: AxisModel.getValueAxis(options.orientation, options.axis.value, designerConfig.canvas.axisLabel, canvasModel)
|
|
20
20
|
},
|
|
21
21
|
type: options.type,
|
|
22
22
|
data: Object.assign({}, options.data),
|
|
23
23
|
charts: this.getChartsModel(options.charts, options.orientation, designerConfig.chartStyle),
|
|
24
24
|
additionalElements: this.getAdditionalElements(options),
|
|
25
|
-
tooltip: options.tooltip
|
|
25
|
+
tooltip: options.tooltip,
|
|
26
|
+
chartSettings: this.getChartsSettings(designerConfig.canvas.chartOptions.bar)
|
|
26
27
|
};
|
|
27
28
|
}
|
|
28
29
|
static getChartsEmbeddedLabelsFlag(charts, chartOrientation) {
|
|
@@ -40,7 +41,13 @@ export class TwoDimensionalModel {
|
|
|
40
41
|
const chartOrder = ['area', 'bar', 'line'];
|
|
41
42
|
charts.sort((chart1, chart2) => chartOrder.indexOf(chart1.type) - chartOrder.indexOf(chart2.type));
|
|
42
43
|
}
|
|
44
|
+
static getChartsSettings(barSettings) {
|
|
45
|
+
return {
|
|
46
|
+
bar: Object.assign({}, barSettings)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
43
49
|
static getChartsModel(charts, chartOrientation, chartStyleConfig) {
|
|
50
|
+
const styleModel = new TwoDimensionalChartStyleModel(charts, chartStyleConfig);
|
|
44
51
|
this.sortCharts(charts);
|
|
45
52
|
const chartsModel = [];
|
|
46
53
|
charts.forEach((chart, index) => {
|
|
@@ -49,8 +56,8 @@ export class TwoDimensionalModel {
|
|
|
49
56
|
isSegmented: chart.isSegmented,
|
|
50
57
|
data: Object.assign({}, chart.data),
|
|
51
58
|
tooltip: chart.tooltip,
|
|
52
|
-
cssClasses:
|
|
53
|
-
style:
|
|
59
|
+
cssClasses: ChartStyleModelService.getCssClasses(index),
|
|
60
|
+
style: styleModel.getChartStyle(chart, index),
|
|
54
61
|
embeddedLabels: this.getEmbeddedLabelType(chart, chartOrientation),
|
|
55
62
|
markersOptions: chart.markers,
|
|
56
63
|
index
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap');
|
|
2
|
+
|
|
1
3
|
.wrapper {
|
|
2
4
|
margin: 0 auto;
|
|
3
5
|
position: relative;
|
|
@@ -41,28 +43,45 @@
|
|
|
41
43
|
|
|
42
44
|
|
|
43
45
|
/*========================================================================== Legend */
|
|
46
|
+
.legend-block {
|
|
47
|
+
display: flex;
|
|
48
|
+
height: 100%;
|
|
49
|
+
}
|
|
50
|
+
.legend-block-column {
|
|
51
|
+
flex-direction: column;
|
|
52
|
+
}
|
|
53
|
+
.legend-block-row {
|
|
54
|
+
flex-direction: row;
|
|
55
|
+
flex-wrap: wrap;
|
|
56
|
+
}
|
|
57
|
+
.legend-block-centered {
|
|
58
|
+
justify-content: center;
|
|
59
|
+
}
|
|
44
60
|
.legend-item {
|
|
45
61
|
cursor: default;
|
|
46
62
|
transition: opacity 0.1s;
|
|
63
|
+
/* will-change: opacity; */
|
|
64
|
+
}
|
|
65
|
+
.legend-block-column .legend-item:not(:first-of-type) {
|
|
66
|
+
margin-top: 15px;
|
|
47
67
|
}
|
|
48
68
|
.legend-item-inline {
|
|
49
69
|
white-space: nowrap;
|
|
70
|
+
overflow: hidden;
|
|
71
|
+
text-overflow: ellipsis;
|
|
50
72
|
}
|
|
51
|
-
.legend-item-inline:not(:first-of-type) {
|
|
73
|
+
.legend-wrapper-without-wrap .legend-item-inline:not(:first-of-type) {
|
|
52
74
|
margin-left: 20px;
|
|
53
75
|
}
|
|
76
|
+
.legend-wrapper-with-wrap .legend-item-inline {
|
|
77
|
+
margin: 5px;
|
|
78
|
+
}
|
|
54
79
|
.legend-item-row {
|
|
55
80
|
display: flex;
|
|
56
81
|
}
|
|
57
82
|
.legend-item-row > span {
|
|
58
83
|
display: block;
|
|
59
84
|
}
|
|
60
|
-
.mt-15 {
|
|
61
|
-
margin-top: 15px;
|
|
62
|
-
}
|
|
63
|
-
.mt-10 {
|
|
64
|
-
margin-top: 10px;
|
|
65
|
-
}
|
|
66
85
|
|
|
67
86
|
.legend-label {
|
|
68
87
|
font-size: 12px;
|
|
@@ -188,6 +207,7 @@
|
|
|
188
207
|
}
|
|
189
208
|
.aggregator-name {
|
|
190
209
|
margin-top: 10px;
|
|
210
|
+
pointer-events: auto;
|
|
191
211
|
}
|
|
192
212
|
|
|
193
213
|
/* Grid */
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap');
|
|
2
|
+
|
|
1
3
|
.wrapper {
|
|
2
4
|
margin: 0 auto;
|
|
3
5
|
position: relative;
|
|
@@ -41,28 +43,45 @@
|
|
|
41
43
|
|
|
42
44
|
|
|
43
45
|
/*========================================================================== Legend */
|
|
46
|
+
.legend-block {
|
|
47
|
+
display: flex;
|
|
48
|
+
height: 100%;
|
|
49
|
+
}
|
|
50
|
+
.legend-block-column {
|
|
51
|
+
flex-direction: column;
|
|
52
|
+
}
|
|
53
|
+
.legend-block-row {
|
|
54
|
+
flex-direction: row;
|
|
55
|
+
flex-wrap: wrap;
|
|
56
|
+
}
|
|
57
|
+
.legend-block-centered {
|
|
58
|
+
justify-content: center;
|
|
59
|
+
}
|
|
44
60
|
.legend-item {
|
|
45
61
|
cursor: default;
|
|
46
62
|
transition: opacity 0.1s;
|
|
63
|
+
/* will-change: opacity; */
|
|
64
|
+
}
|
|
65
|
+
.legend-block-column .legend-item:not(:first-of-type) {
|
|
66
|
+
margin-top: 15px;
|
|
47
67
|
}
|
|
48
68
|
.legend-item-inline {
|
|
49
69
|
white-space: nowrap;
|
|
70
|
+
overflow: hidden;
|
|
71
|
+
text-overflow: ellipsis;
|
|
50
72
|
}
|
|
51
|
-
.legend-item-inline:not(:first-of-type) {
|
|
73
|
+
.legend-wrapper-without-wrap .legend-item-inline:not(:first-of-type) {
|
|
52
74
|
margin-left: 20px;
|
|
53
75
|
}
|
|
76
|
+
.legend-wrapper-with-wrap .legend-item-inline {
|
|
77
|
+
margin: 5px;
|
|
78
|
+
}
|
|
54
79
|
.legend-item-row {
|
|
55
80
|
display: flex;
|
|
56
81
|
}
|
|
57
82
|
.legend-item-row > span {
|
|
58
83
|
display: block;
|
|
59
84
|
}
|
|
60
|
-
.mt-15 {
|
|
61
|
-
margin-top: 15px;
|
|
62
|
-
}
|
|
63
|
-
.mt-10 {
|
|
64
|
-
margin-top: 10px;
|
|
65
|
-
}
|
|
66
85
|
|
|
67
86
|
.legend-label {
|
|
68
87
|
font-size: 12px;
|
|
@@ -188,6 +207,7 @@
|
|
|
188
207
|
}
|
|
189
208
|
.aggregator-name {
|
|
190
209
|
margin-top: 10px;
|
|
210
|
+
pointer-events: auto;
|
|
191
211
|
}
|
|
192
212
|
|
|
193
213
|
/* Grid */
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mdt-charts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/main.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "npx webpack --mode development",
|
|
8
8
|
"build": "npx webpack --mode production",
|
|
9
9
|
"watch": "npx webpack --mode development --watch",
|
|
10
|
-
"test": "jest"
|
|
10
|
+
"test": "jest",
|
|
11
|
+
"build-lib": "npx tsc -p tsconfig.production.json"
|
|
11
12
|
},
|
|
12
13
|
"homepage": "https://github.com/VishulaKnow/charts",
|
|
13
14
|
"author": "",
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"outDir": "./lib/",
|
|
4
|
+
"noImplicitAny": true,
|
|
5
|
+
"target": "es6",
|
|
6
|
+
"lib": ["ES2017", "DOM"],
|
|
7
|
+
"jsx": "react",
|
|
8
|
+
"allowJs": true,
|
|
9
|
+
"types": [
|
|
10
|
+
"jest"
|
|
11
|
+
],
|
|
12
|
+
"declaration": true
|
|
13
|
+
},
|
|
14
|
+
"include": [
|
|
15
|
+
"src"
|
|
16
|
+
],
|
|
17
|
+
"exclude": [
|
|
18
|
+
"node_modules",
|
|
19
|
+
"**/__tests__/*",
|
|
20
|
+
"src/playground/*",
|
|
21
|
+
"**/*Example.ts"
|
|
22
|
+
]
|
|
23
|
+
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ChartOrientation } from "../../../config/config";
|
|
2
|
-
import { Block } from "../../block/block";
|
|
3
|
-
declare type AlertBlockPosition = 'top' | 'bottom' | 'right' | 'left';
|
|
4
|
-
export declare class RecordOverflowAlert {
|
|
5
|
-
private static readonly blockClass;
|
|
6
|
-
static render(block: Block, hidedRecordsAmount: number, position: AlertBlockPosition, chartOrientation?: ChartOrientation): void;
|
|
7
|
-
static update(block: Block, hidedRecordsAmount: number, position: AlertBlockPosition, chartOrientation?: ChartOrientation): void;
|
|
8
|
-
private static setAlertPosition;
|
|
9
|
-
private static getAlertText;
|
|
10
|
-
private static getWordTextEndingByAmount;
|
|
11
|
-
private static getBlockPositionAttrs;
|
|
12
|
-
private static getLeftAttrForRightBlock;
|
|
13
|
-
}
|
|
14
|
-
export {};
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { DomHelper } from '../../helpers/domHelper';
|
|
2
|
-
import { Legend } from '../legend/legend';
|
|
3
|
-
export class RecordOverflowAlert {
|
|
4
|
-
static render(block, hidedRecordsAmount, position, chartOrientation = null) {
|
|
5
|
-
const alertBlock = block.getWrapper()
|
|
6
|
-
.append('div')
|
|
7
|
-
.attr('class', this.blockClass)
|
|
8
|
-
.text(this.getAlertText(hidedRecordsAmount, chartOrientation));
|
|
9
|
-
const attrs = this.getBlockPositionAttrs(position, block);
|
|
10
|
-
this.setAlertPosition(alertBlock, attrs);
|
|
11
|
-
}
|
|
12
|
-
static update(block, hidedRecordsAmount, position, chartOrientation = null) {
|
|
13
|
-
let alertBlock = block.getWrapper()
|
|
14
|
-
.select(`div.${this.blockClass}`);
|
|
15
|
-
if (alertBlock.empty()) {
|
|
16
|
-
if (hidedRecordsAmount === 0)
|
|
17
|
-
return;
|
|
18
|
-
else
|
|
19
|
-
this.render(block, hidedRecordsAmount, position, chartOrientation);
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
if (hidedRecordsAmount === 0)
|
|
23
|
-
alertBlock.remove();
|
|
24
|
-
else
|
|
25
|
-
alertBlock.text(this.getAlertText(hidedRecordsAmount, chartOrientation));
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
static setAlertPosition(alertBlock, attrs) {
|
|
29
|
-
alertBlock
|
|
30
|
-
.style('position', 'absolute')
|
|
31
|
-
.style('left', attrs.left)
|
|
32
|
-
.style('right', attrs.right)
|
|
33
|
-
.style('top', attrs.top)
|
|
34
|
-
.style('bottom', attrs.bottom);
|
|
35
|
-
}
|
|
36
|
-
static getAlertText(hidedRecordsAmount, chartOrientation) {
|
|
37
|
-
return `+ ${hidedRecordsAmount} ${this.getWordTextEndingByAmount(hidedRecordsAmount, chartOrientation)}`;
|
|
38
|
-
}
|
|
39
|
-
static getWordTextEndingByAmount(hidedRecordsAmount, chartOrientation) {
|
|
40
|
-
const lastDigit = hidedRecordsAmount % 10;
|
|
41
|
-
if (chartOrientation === 'vertical') {
|
|
42
|
-
if (hidedRecordsAmount >= 10 && hidedRecordsAmount <= 20)
|
|
43
|
-
return 'столбцов';
|
|
44
|
-
if (lastDigit === 1)
|
|
45
|
-
return 'столбец';
|
|
46
|
-
if (lastDigit >= 2 && lastDigit <= 4)
|
|
47
|
-
return 'столбца';
|
|
48
|
-
return 'столбцов';
|
|
49
|
-
}
|
|
50
|
-
else if (chartOrientation === 'horizontal') {
|
|
51
|
-
if (hidedRecordsAmount >= 10 && hidedRecordsAmount <= 20)
|
|
52
|
-
return 'строк';
|
|
53
|
-
if (lastDigit === 1)
|
|
54
|
-
return 'строка';
|
|
55
|
-
if (lastDigit >= 2 && lastDigit <= 4)
|
|
56
|
-
return 'строки';
|
|
57
|
-
return 'строк';
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
if (hidedRecordsAmount >= 10 && hidedRecordsAmount <= 20)
|
|
61
|
-
return 'категорий';
|
|
62
|
-
if (lastDigit === 1)
|
|
63
|
-
return 'категория';
|
|
64
|
-
if (lastDigit >= 2 && lastDigit <= 4)
|
|
65
|
-
return 'категории';
|
|
66
|
-
return 'категорий';
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
static getBlockPositionAttrs(position, block) {
|
|
70
|
-
const attrs = {
|
|
71
|
-
bottom: null,
|
|
72
|
-
top: null,
|
|
73
|
-
right: null,
|
|
74
|
-
left: null
|
|
75
|
-
};
|
|
76
|
-
if (position === 'top') {
|
|
77
|
-
attrs.right = '17px';
|
|
78
|
-
attrs.top = '1rem';
|
|
79
|
-
}
|
|
80
|
-
if (position === 'right') {
|
|
81
|
-
attrs.bottom = '20px';
|
|
82
|
-
attrs.left = this.getLeftAttrForRightBlock(block) + 'px';
|
|
83
|
-
}
|
|
84
|
-
if (position === 'bottom') {
|
|
85
|
-
attrs.left = '20px';
|
|
86
|
-
attrs.bottom = '20px';
|
|
87
|
-
}
|
|
88
|
-
return attrs;
|
|
89
|
-
}
|
|
90
|
-
static getLeftAttrForRightBlock(block) {
|
|
91
|
-
const legendBlock = block.getSvg().select(`.${Legend.objectClass}`);
|
|
92
|
-
if (legendBlock.empty())
|
|
93
|
-
return null;
|
|
94
|
-
return DomHelper.getSelectionNumericAttr(legendBlock, 'x');
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
RecordOverflowAlert.blockClass = 'record-overflow-alert';
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { TwoDimensionalChartType } from "../config/config";
|
|
2
|
-
import { ChartStyleConfig } from "../designer/designerConfig";
|
|
3
|
-
import { ChartStyle } from "./model";
|
|
4
|
-
export declare class ChartStyleModel {
|
|
5
|
-
private static safeColorsAmount;
|
|
6
|
-
private static standartColors;
|
|
7
|
-
static getCssClasses(chartIndex: number): string[];
|
|
8
|
-
static get2DChartStyle(chartsAmount: number, chartType: TwoDimensionalChartType, chartsFieldsAmounts: number[], chartIndex: number, isSegmented: boolean, styleConfig: ChartStyleConfig): ChartStyle;
|
|
9
|
-
static getChartStyle(elementsAmount: number, styleConfig: ChartStyleConfig): ChartStyle;
|
|
10
|
-
private static getChartColors;
|
|
11
|
-
private static getChartOpacity;
|
|
12
|
-
private static getColorSet;
|
|
13
|
-
private static checkAndGet;
|
|
14
|
-
private static getStartIndex;
|
|
15
|
-
private static resetColor;
|
|
16
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import * as chroma from "chroma-js";
|
|
2
|
-
import { ModelHelper } from "./modelHelper";
|
|
3
|
-
export class ChartStyleModel {
|
|
4
|
-
static getCssClasses(chartIndex) {
|
|
5
|
-
const cssClasses = [`chart-${chartIndex}`];
|
|
6
|
-
return cssClasses;
|
|
7
|
-
}
|
|
8
|
-
static get2DChartStyle(chartsAmount, chartType, chartsFieldsAmounts, chartIndex, isSegmented, styleConfig) {
|
|
9
|
-
const startIndex = this.getStartIndex(chartIndex, chartsFieldsAmounts);
|
|
10
|
-
const baseColors = this.checkAndGet(styleConfig.baseColors);
|
|
11
|
-
const palette = this.getColorSet(baseColors, ModelHelper.getSum(chartsFieldsAmounts));
|
|
12
|
-
return {
|
|
13
|
-
elementColors: this.getChartColors(palette, chartsFieldsAmounts[chartIndex], startIndex, chartType),
|
|
14
|
-
opacity: this.getChartOpacity(chartsAmount, chartType, chartsFieldsAmounts[chartIndex], isSegmented)
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
static getChartStyle(elementsAmount, styleConfig) {
|
|
18
|
-
const baseColors = this.checkAndGet(styleConfig.baseColors);
|
|
19
|
-
return {
|
|
20
|
-
elementColors: this.getColorSet(baseColors, elementsAmount),
|
|
21
|
-
opacity: 1
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
static getChartColors(palette, elementsAmount, startIndex, chartType) {
|
|
25
|
-
const selectedColors = palette.slice(startIndex, startIndex + elementsAmount);
|
|
26
|
-
if (chartType !== 'line')
|
|
27
|
-
return selectedColors;
|
|
28
|
-
for (let i = 0; i < selectedColors.length; i++) {
|
|
29
|
-
selectedColors[i] = chroma.mix(selectedColors[i], 'white', 0.2).saturate(3).hex();
|
|
30
|
-
}
|
|
31
|
-
return selectedColors;
|
|
32
|
-
}
|
|
33
|
-
static getChartOpacity(chartsLength, chartType, chartsValueFieldAmount, isSegmented) {
|
|
34
|
-
if (chartType === 'area' && (chartsLength > 1 || chartsValueFieldAmount > 1) && !isSegmented)
|
|
35
|
-
return 0.5; // combined area with other charts has 0.5 opacity
|
|
36
|
-
return 1;
|
|
37
|
-
}
|
|
38
|
-
static getColorSet(baseColors, elementsAmount) {
|
|
39
|
-
return chroma.scale(baseColors)
|
|
40
|
-
.mode('rgb')
|
|
41
|
-
.domain([0, 0.55, 0.75, 1])
|
|
42
|
-
.colors(elementsAmount <= 1 ? 2 : elementsAmount);
|
|
43
|
-
}
|
|
44
|
-
static checkAndGet(baseColors) {
|
|
45
|
-
if (baseColors.length === 0 || baseColors.filter(color => color === 'rgba(0, 0, 0, 0)' || !color).length > 0) {
|
|
46
|
-
return this.standartColors;
|
|
47
|
-
}
|
|
48
|
-
return baseColors;
|
|
49
|
-
}
|
|
50
|
-
static getStartIndex(chartIndex, chartsFieldsAmounts) {
|
|
51
|
-
let startIndex = 0;
|
|
52
|
-
for (let i = 0; i < chartIndex; i++) {
|
|
53
|
-
startIndex += chartsFieldsAmounts[i];
|
|
54
|
-
}
|
|
55
|
-
return startIndex;
|
|
56
|
-
}
|
|
57
|
-
static resetColor(index, baseColor) {
|
|
58
|
-
let color = chroma(baseColor)
|
|
59
|
-
.luminance(0.5)
|
|
60
|
-
.saturate(1.5 + Math.floor(index / this.safeColorsAmount) * 0.5);
|
|
61
|
-
color = chroma(color)
|
|
62
|
-
.set('hsv.h', chroma(color).get('hsv.h') + Math.floor(index / this.safeColorsAmount) * 4);
|
|
63
|
-
return color.hex();
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
ChartStyleModel.safeColorsAmount = 8;
|
|
67
|
-
ChartStyleModel.standartColors = ["#209DE3", "#FF3131", "#FFBA00", "#20B078"];
|