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
|
@@ -11,6 +11,7 @@ export class Donut {
|
|
|
11
11
|
const arcGenerator = DonutHelper.getArcGenerator(outerRadius, innerRadius);
|
|
12
12
|
const pieGenerator = DonutHelper.getPieGenerator(chart.data.valueField.name, settings.padAngle);
|
|
13
13
|
const translateAttr = DonutHelper.getTranslate(margin, blockSize);
|
|
14
|
+
Aggregator.render(block, data, chart.data.valueField, innerRadius, translateAttr, thickness, settings.aggregator);
|
|
14
15
|
const donutBlock = block.getSvg()
|
|
15
16
|
.append('g')
|
|
16
17
|
.attr('class', this.donutBlockClass)
|
|
@@ -19,7 +20,6 @@ export class Donut {
|
|
|
19
20
|
.attr('transform', `translate(${translateAttr.x}, ${translateAttr.y})`);
|
|
20
21
|
this.renderNewArcItems(arcGenerator, pieGenerator, donutBlock, data, chart);
|
|
21
22
|
this.renderClonesG(donutBlock);
|
|
22
|
-
Aggregator.render(block, data, chart.data.valueField, innerRadius, translateAttr, thickness, settings.aggregatorPad);
|
|
23
23
|
}
|
|
24
24
|
static update(block, data, margin, chart, blockSize, donutSettings, keyField) {
|
|
25
25
|
const outerRadius = DonutHelper.getOuterRadius(margin, blockSize);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LegendPosition } from "../../../model/model";
|
|
2
|
+
import { Block } from "../../block/block";
|
|
3
|
+
interface PolarRecordOverflowAlertOptions {
|
|
4
|
+
hidedRecordsAmount: number;
|
|
5
|
+
legendPosition: LegendPosition;
|
|
6
|
+
}
|
|
7
|
+
declare class PolarRecordOverflowAlertClass {
|
|
8
|
+
private readonly text;
|
|
9
|
+
render(block: Block, options: PolarRecordOverflowAlertOptions): void;
|
|
10
|
+
update(block: Block, options: PolarRecordOverflowAlertOptions): void;
|
|
11
|
+
private buildCoreOptions;
|
|
12
|
+
private getPositionAttrs;
|
|
13
|
+
}
|
|
14
|
+
export declare const PolarRecordOverflowAlert: PolarRecordOverflowAlertClass;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { RecordOverflowAlertCore } from "../../features/recordOverflowAlert/recordOverflowAlertCore";
|
|
2
|
+
class PolarRecordOverflowAlertClass {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.text = {
|
|
5
|
+
one: 'категория',
|
|
6
|
+
twoToFour: 'категории',
|
|
7
|
+
tenToTwenty: 'категорий',
|
|
8
|
+
other: 'категорий'
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
render(block, options) {
|
|
12
|
+
RecordOverflowAlertCore.render(block, this.buildCoreOptions(options));
|
|
13
|
+
}
|
|
14
|
+
update(block, options) {
|
|
15
|
+
RecordOverflowAlertCore.update(block, this.buildCoreOptions(options));
|
|
16
|
+
}
|
|
17
|
+
buildCoreOptions(options) {
|
|
18
|
+
return {
|
|
19
|
+
hidedRecordsAmount: options.hidedRecordsAmount,
|
|
20
|
+
text: this.text,
|
|
21
|
+
positionAttrs: this.getPositionAttrs(options)
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
getPositionAttrs(options) {
|
|
25
|
+
const position = options.legendPosition === 'off' ? 'bottom' : options.legendPosition;
|
|
26
|
+
if (position === 'right') {
|
|
27
|
+
return {
|
|
28
|
+
bottom: '0',
|
|
29
|
+
right: '0'
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
if (position === 'bottom') {
|
|
33
|
+
return {
|
|
34
|
+
bottom: '0',
|
|
35
|
+
left: '0'
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export const PolarRecordOverflowAlert = new PolarRecordOverflowAlertClass();
|
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
import { Legend } from "../features/legend/legend";
|
|
2
|
-
import { RecordOverflowAlert } from "../features/recordOverflowAlert/recordOverflowAlert";
|
|
3
2
|
import { Title } from "../features/title/title";
|
|
4
3
|
import { ElementHighlighter } from "../elementHighlighter/elementHighlighter";
|
|
5
4
|
import { Tooltip } from "../features/tolltip/tooltip";
|
|
6
5
|
import { Aggregator } from "../features/aggregator/aggregator";
|
|
7
6
|
import { Donut } from "./donut/donut";
|
|
7
|
+
import { PolarRecordOverflowAlert } from "./extenders/polarRecordOverflowAlert";
|
|
8
8
|
export class PolarManager {
|
|
9
9
|
static render(engine, model) {
|
|
10
10
|
const options = model.options;
|
|
11
11
|
engine.block.renderSvg(model.blockCanvas.size);
|
|
12
|
-
this.renderCharts(engine.block, options.charts, engine.data, options.data.dataSource, model.chartBlock.margin, model.blockCanvas.size,
|
|
12
|
+
this.renderCharts(engine.block, options.charts, engine.data, options.data.dataSource, model.chartBlock.margin, model.blockCanvas.size, options.chartCanvas);
|
|
13
13
|
Title.render(engine.block, options.title, model.otherComponents.titleBlock, model.blockCanvas.size);
|
|
14
14
|
Legend.render(engine.block, engine.data, options, model);
|
|
15
|
-
``;
|
|
16
15
|
Tooltip.render(engine.block, model, engine.data, model.otherComponents.tooltipBlock);
|
|
17
|
-
engine.block.filterEventManager.setListenerPolar(model.chartBlock.margin, model.blockCanvas.size, options
|
|
18
|
-
if (model.dataSettings.scope.hidedRecordsAmount !== 0
|
|
19
|
-
|
|
16
|
+
engine.block.filterEventManager.setListenerPolar(model.chartBlock.margin, model.blockCanvas.size, options);
|
|
17
|
+
if (model.dataSettings.scope.hidedRecordsAmount !== 0)
|
|
18
|
+
PolarRecordOverflowAlert.render(engine.block, {
|
|
19
|
+
hidedRecordsAmount: model.dataSettings.scope.hidedRecordsAmount,
|
|
20
|
+
legendPosition: model.options.legend.position
|
|
21
|
+
});
|
|
20
22
|
engine.block.getSvg()
|
|
21
23
|
.on('click', (e) => {
|
|
22
24
|
if (e.target === engine.block.getSvg().node())
|
|
23
|
-
engine.block.filterEventManager.clearKeysForPolar(model.chartBlock.margin, model.blockCanvas.size, options
|
|
25
|
+
engine.block.filterEventManager.clearKeysForPolar(model.chartBlock.margin, model.blockCanvas.size, options);
|
|
24
26
|
});
|
|
25
27
|
}
|
|
26
28
|
static update(block, model, data) {
|
|
@@ -32,15 +34,17 @@ export class PolarManager {
|
|
|
32
34
|
ElementHighlighter.toggleActivityStyle(Donut.getAllArcGroups(block), true);
|
|
33
35
|
Tooltip.hide(block);
|
|
34
36
|
const options = model.options;
|
|
35
|
-
Donut.update(block, data[options.data.dataSource], model.chartBlock.margin, options.charts[0], model.blockCanvas.size,
|
|
37
|
+
Donut.update(block, data[options.data.dataSource], model.chartBlock.margin, options.charts[0], model.blockCanvas.size, options.chartCanvas, options.data.keyField.name)
|
|
36
38
|
.then(() => {
|
|
37
39
|
Tooltip.render(block, model, data, model.otherComponents.tooltipBlock);
|
|
38
|
-
block.filterEventManager.setListenerPolar(model.chartBlock.margin, model.blockCanvas.size, options
|
|
40
|
+
block.filterEventManager.setListenerPolar(model.chartBlock.margin, model.blockCanvas.size, options);
|
|
39
41
|
});
|
|
40
|
-
Aggregator.update(block, data[options.data.dataSource], options.charts[0].data.valueField,
|
|
42
|
+
Aggregator.update(block, data[options.data.dataSource], options.charts[0].data.valueField, options.chartCanvas.aggregator);
|
|
41
43
|
Legend.update(block, data, model);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
PolarRecordOverflowAlert.update(block, {
|
|
45
|
+
hidedRecordsAmount: model.dataSettings.scope.hidedRecordsAmount,
|
|
46
|
+
legendPosition: model.options.legend.position
|
|
47
|
+
});
|
|
44
48
|
}
|
|
45
49
|
static updateColors(block, model) {
|
|
46
50
|
Legend.updateColors(block, model.options);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ChartOrientation } from "../../../config/config";
|
|
2
|
+
import { Block } from "../../block/block";
|
|
3
|
+
interface TwoDimRecordOverflowAlertOptions {
|
|
4
|
+
hidedRecordsAmount: number;
|
|
5
|
+
chartOrientation: ChartOrientation;
|
|
6
|
+
}
|
|
7
|
+
declare class TwoDimRecordOverflowAlertClass {
|
|
8
|
+
render(block: Block, options: TwoDimRecordOverflowAlertOptions): void;
|
|
9
|
+
update(block: Block, options: TwoDimRecordOverflowAlertOptions): void;
|
|
10
|
+
private buildCoreOptions;
|
|
11
|
+
private getText;
|
|
12
|
+
private getPositionAttrs;
|
|
13
|
+
}
|
|
14
|
+
export declare const TwoDimRecordOverflowAlert: TwoDimRecordOverflowAlertClass;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { RecordOverflowAlertCore } from "../../features/recordOverflowAlert/recordOverflowAlertCore";
|
|
2
|
+
class TwoDimRecordOverflowAlertClass {
|
|
3
|
+
render(block, options) {
|
|
4
|
+
RecordOverflowAlertCore.render(block, this.buildCoreOptions(options));
|
|
5
|
+
}
|
|
6
|
+
update(block, options) {
|
|
7
|
+
RecordOverflowAlertCore.update(block, this.buildCoreOptions(options));
|
|
8
|
+
}
|
|
9
|
+
buildCoreOptions(options) {
|
|
10
|
+
return {
|
|
11
|
+
hidedRecordsAmount: options.hidedRecordsAmount,
|
|
12
|
+
text: this.getText(options.chartOrientation),
|
|
13
|
+
positionAttrs: this.getPositionAttrs()
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
getText(chartOrientation) {
|
|
17
|
+
const isHorizontal = chartOrientation === 'horizontal';
|
|
18
|
+
return {
|
|
19
|
+
one: isHorizontal ? 'строка' : 'столбец',
|
|
20
|
+
twoToFour: isHorizontal ? 'строки' : 'столбца',
|
|
21
|
+
tenToTwenty: isHorizontal ? 'строк' : 'столбцов',
|
|
22
|
+
other: isHorizontal ? 'строк' : 'столбцов'
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
getPositionAttrs() {
|
|
26
|
+
return {
|
|
27
|
+
right: '17px',
|
|
28
|
+
top: '1rem'
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export const TwoDimRecordOverflowAlert = new TwoDimRecordOverflowAlertClass();
|
|
@@ -3,7 +3,6 @@ import { Axis } from "../features/axis/axis";
|
|
|
3
3
|
import { EmbeddedLabels } from "../features/embeddedLabels/embeddedLabels";
|
|
4
4
|
import { GridLine } from "../features/gridLine/gridLine";
|
|
5
5
|
import { Legend } from "../features/legend/legend";
|
|
6
|
-
import { RecordOverflowAlert } from "../features/recordOverflowAlert/recordOverflowAlert";
|
|
7
6
|
import { Scale } from "../features/scale/scale";
|
|
8
7
|
import { TipBox } from "../features/tipBox/tipBox";
|
|
9
8
|
import { Title } from "../features/title/title";
|
|
@@ -12,23 +11,27 @@ import { Helper } from "../helpers/helper";
|
|
|
12
11
|
import { Area } from "./area/area";
|
|
13
12
|
import { Bar } from "./bar/bar";
|
|
14
13
|
import { BarHelper } from "./bar/barHelper";
|
|
14
|
+
import { TwoDimRecordOverflowAlert } from "./extenders/twoDimRecordOverflowAlert";
|
|
15
15
|
import { Line } from "./line/line";
|
|
16
16
|
export class TwoDimensionalManager {
|
|
17
17
|
static render(engine, model) {
|
|
18
18
|
const options = model.options;
|
|
19
|
-
const scales = Scale.getScales(options.scale.key, options.scale.value,
|
|
19
|
+
const scales = Scale.getScales(options.scale.key, options.scale.value, options.chartSettings.bar);
|
|
20
20
|
engine.block.scales = scales;
|
|
21
21
|
engine.block.renderSvg(model.blockCanvas.size);
|
|
22
22
|
Axis.render(engine.block, scales, options.scale, options.axis, model.blockCanvas.size);
|
|
23
23
|
GridLine.render(engine.block, options.additionalElements.gridLine.flag, options.axis, model.blockCanvas.size, model.chartBlock.margin, options.scale.key);
|
|
24
|
-
this.renderCharts(engine.block, options.charts, scales, engine.data, options.data, model.chartBlock.margin, options.axis.key.orient,
|
|
24
|
+
this.renderCharts(engine.block, options.charts, scales, engine.data, options.data, model.chartBlock.margin, options.axis.key.orient, options.chartSettings.bar, model.blockCanvas.size);
|
|
25
25
|
engine.block.filterEventManager.registerEventFor2D(scales.key, model.chartBlock.margin, model.blockCanvas.size, options);
|
|
26
26
|
engine.block.filterEventManager.event2DUpdate(options);
|
|
27
27
|
Title.render(engine.block, options.title, model.otherComponents.titleBlock, model.blockCanvas.size);
|
|
28
28
|
Legend.render(engine.block, engine.data, options, model);
|
|
29
29
|
Tooltip.render(engine.block, model, engine.data, model.otherComponents.tooltipBlock, scales);
|
|
30
30
|
if (model.dataSettings.scope.hidedRecordsAmount !== 0)
|
|
31
|
-
|
|
31
|
+
TwoDimRecordOverflowAlert.render(engine.block, {
|
|
32
|
+
hidedRecordsAmount: model.dataSettings.scope.hidedRecordsAmount,
|
|
33
|
+
chartOrientation: options.orient
|
|
34
|
+
});
|
|
32
35
|
engine.block.getSvg()
|
|
33
36
|
.on('click', (e) => {
|
|
34
37
|
if (e.target === engine.block.getSvg().node())
|
|
@@ -42,19 +45,22 @@ export class TwoDimensionalManager {
|
|
|
42
45
|
Tooltip.hide(block);
|
|
43
46
|
const options = model.options;
|
|
44
47
|
ElementHighlighter.remove2DChartsFullHighlighting(block, options.charts);
|
|
45
|
-
const scales = Scale.getScales(options.scale.key, options.scale.value,
|
|
48
|
+
const scales = Scale.getScales(options.scale.key, options.scale.value, options.chartSettings.bar);
|
|
46
49
|
const keyDomainEquality = Helper.checkDomainsEquality(block.scales.key.domain(), scales.key.domain());
|
|
47
50
|
block.scales = scales;
|
|
48
51
|
Axis.update(block, scales, options.scale, options.axis, model.blockCanvas.size, keyDomainEquality);
|
|
49
52
|
GridLine.update(block, options.additionalElements.gridLine.flag, options.axis, model.blockCanvas.size, model.chartBlock.margin, options.scale.key);
|
|
50
|
-
const promises = this.updateCharts(block, options.charts, scales, data, model.options.data, model.chartBlock.margin, options.axis.key.orient, model.blockCanvas.size,
|
|
53
|
+
const promises = this.updateCharts(block, options.charts, scales, data, model.options.data, model.chartBlock.margin, options.axis.key.orient, model.blockCanvas.size, options.chartSettings.bar);
|
|
51
54
|
Promise.all(promises)
|
|
52
55
|
.then(() => {
|
|
53
56
|
block.filterEventManager.event2DUpdate(options);
|
|
54
57
|
block.filterEventManager.registerEventFor2D(scales.key, model.chartBlock.margin, model.blockCanvas.size, options);
|
|
55
58
|
Tooltip.render(block, model, data, model.otherComponents.tooltipBlock, scales);
|
|
56
59
|
});
|
|
57
|
-
|
|
60
|
+
TwoDimRecordOverflowAlert.update(block, {
|
|
61
|
+
hidedRecordsAmount: model.dataSettings.scope.hidedRecordsAmount,
|
|
62
|
+
chartOrientation: options.orient
|
|
63
|
+
});
|
|
58
64
|
}
|
|
59
65
|
static updateColors(block, model) {
|
|
60
66
|
Legend.updateColors(block, model.options);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { TwoDimensionalChart, TwoDimensionalChartType } from "../../config/config";
|
|
2
|
+
import { ChartStyleConfig } from "../../designer/designerConfig";
|
|
3
|
+
import { ChartStyle } from "../model";
|
|
4
|
+
export declare class TwoDimensionalChartStyleModel {
|
|
5
|
+
private charts;
|
|
6
|
+
private chartStyleConfig;
|
|
7
|
+
private service;
|
|
8
|
+
constructor(charts: TwoDimensionalChart[], chartStyleConfig: ChartStyleConfig);
|
|
9
|
+
getChartStyle(chart: TwoDimensionalChart, chartIndex: number): ChartStyle;
|
|
10
|
+
private getChartsValueFieldsAmounts;
|
|
11
|
+
}
|
|
12
|
+
export declare class TwoDimensionalChartStyleService {
|
|
13
|
+
getChartColors(chart: TwoDimensionalChart, styleConfig: ChartStyleConfig, chartsFieldsAmounts: number[], chartIndex: number): string[];
|
|
14
|
+
getChartOpacity(chartsLength: number, chartType: TwoDimensionalChartType, chartsValueFieldAmount: number, isChartSegmented: boolean): number;
|
|
15
|
+
private generateNewChartColors;
|
|
16
|
+
private isMoreThanOneValueFieldOnCanvas;
|
|
17
|
+
private makeColorsBrighter;
|
|
18
|
+
private getStartIndex;
|
|
19
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import * as chroma from "chroma-js";
|
|
2
|
+
import { ModelHelper } from "../modelHelper";
|
|
3
|
+
import { ChartStyleModelService } from "./chartStyleModel";
|
|
4
|
+
export class TwoDimensionalChartStyleModel {
|
|
5
|
+
constructor(charts, chartStyleConfig) {
|
|
6
|
+
this.charts = charts;
|
|
7
|
+
this.chartStyleConfig = chartStyleConfig;
|
|
8
|
+
this.service = new TwoDimensionalChartStyleService();
|
|
9
|
+
}
|
|
10
|
+
getChartStyle(chart, chartIndex) {
|
|
11
|
+
const fieldsAmounts = this.getChartsValueFieldsAmounts();
|
|
12
|
+
return {
|
|
13
|
+
elementColors: this.service.getChartColors(chart, this.chartStyleConfig, fieldsAmounts, chartIndex),
|
|
14
|
+
opacity: this.service.getChartOpacity(this.charts.length, chart.type, fieldsAmounts[chartIndex], chart.isSegmented)
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
getChartsValueFieldsAmounts() {
|
|
18
|
+
return this.charts.map(chart => chart.data.valueFields.length);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export class TwoDimensionalChartStyleService {
|
|
22
|
+
getChartColors(chart, styleConfig, chartsFieldsAmounts, chartIndex) {
|
|
23
|
+
const generatedColors = this.generateNewChartColors(chart.type, styleConfig, chartsFieldsAmounts, chartIndex);
|
|
24
|
+
chart.data.valueFields.forEach((field, fieldIndex) => {
|
|
25
|
+
if (field.color)
|
|
26
|
+
generatedColors[fieldIndex] = field.color;
|
|
27
|
+
});
|
|
28
|
+
return generatedColors;
|
|
29
|
+
}
|
|
30
|
+
getChartOpacity(chartsLength, chartType, chartsValueFieldAmount, isChartSegmented) {
|
|
31
|
+
if (chartType === 'area' && this.isMoreThanOneValueFieldOnCanvas(chartsLength, chartsValueFieldAmount) && !isChartSegmented)
|
|
32
|
+
return 0.5; // combined area with other charts has 0.5 opacity
|
|
33
|
+
return 1;
|
|
34
|
+
}
|
|
35
|
+
generateNewChartColors(chartType, styleConfig, chartsFieldsAmounts, chartIndex) {
|
|
36
|
+
const startIndex = this.getStartIndex(chartIndex, chartsFieldsAmounts);
|
|
37
|
+
const baseColors = ChartStyleModelService.checkAndGet(styleConfig.baseColors);
|
|
38
|
+
const palette = ChartStyleModelService.getColorSet(baseColors, ModelHelper.getSum(chartsFieldsAmounts));
|
|
39
|
+
const elementsAmount = chartsFieldsAmounts[chartIndex];
|
|
40
|
+
const selectedColors = palette.slice(startIndex, startIndex + elementsAmount);
|
|
41
|
+
if (chartType !== 'line')
|
|
42
|
+
return selectedColors;
|
|
43
|
+
this.makeColorsBrighter(selectedColors);
|
|
44
|
+
return selectedColors;
|
|
45
|
+
}
|
|
46
|
+
isMoreThanOneValueFieldOnCanvas(chartsLength, chartsValueFieldAmount) {
|
|
47
|
+
return (chartsLength > 1 || chartsValueFieldAmount > 1);
|
|
48
|
+
}
|
|
49
|
+
makeColorsBrighter(initialColors) {
|
|
50
|
+
for (let i = 0; i < initialColors.length; i++) {
|
|
51
|
+
initialColors[i] = chroma.mix(initialColors[i], 'white', 0.2).saturate(3).hex();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
getStartIndex(chartIndex, chartsFieldsAmounts) {
|
|
55
|
+
let startIndex = 0;
|
|
56
|
+
for (let i = 0; i < chartIndex; i++) {
|
|
57
|
+
startIndex += chartsFieldsAmounts[i];
|
|
58
|
+
}
|
|
59
|
+
return startIndex;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ChartStyleConfig } from "../../designer/designerConfig";
|
|
2
|
+
import { ChartStyle } from "../model";
|
|
3
|
+
export declare class ChartStyleModelService {
|
|
4
|
+
private static standartColors;
|
|
5
|
+
static getCssClasses(chartIndex: number): string[];
|
|
6
|
+
static getChartStyle(elementsAmount: number, styleConfig: ChartStyleConfig): ChartStyle;
|
|
7
|
+
static getColorSet(baseColors: string[], elementsAmount: number): string[];
|
|
8
|
+
static checkAndGet(baseColors: string[]): string[];
|
|
9
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as chroma from "chroma-js";
|
|
2
|
+
export class ChartStyleModelService {
|
|
3
|
+
static getCssClasses(chartIndex) {
|
|
4
|
+
const cssClasses = [`chart-${chartIndex}`];
|
|
5
|
+
return cssClasses;
|
|
6
|
+
}
|
|
7
|
+
static getChartStyle(elementsAmount, styleConfig) {
|
|
8
|
+
const baseColors = this.checkAndGet(styleConfig.baseColors);
|
|
9
|
+
return {
|
|
10
|
+
elementColors: this.getColorSet(baseColors, elementsAmount),
|
|
11
|
+
opacity: 1
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
static getColorSet(baseColors, elementsAmount) {
|
|
15
|
+
return chroma.scale(baseColors)
|
|
16
|
+
.mode('rgb')
|
|
17
|
+
.domain([0, 0.55, 0.75, 1])
|
|
18
|
+
.colors(elementsAmount <= 1 ? 2 : elementsAmount);
|
|
19
|
+
}
|
|
20
|
+
static checkAndGet(baseColors) {
|
|
21
|
+
if (baseColors.length === 0 || baseColors.filter(color => color === 'rgba(0, 0, 0, 0)' || !color).length > 0) {
|
|
22
|
+
return this.standartColors;
|
|
23
|
+
}
|
|
24
|
+
return baseColors;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
ChartStyleModelService.standartColors = ["#209DE3", "#FF3131", "#FFBA00", "#20B078"];
|
|
@@ -1,12 +1,24 @@
|
|
|
1
|
-
import { MdtChartsConfig, MdtChartsDataSource } from "
|
|
2
|
-
import { DesignerConfig } from "
|
|
3
|
-
import {
|
|
1
|
+
import { MdtChartsConfig, MdtChartsDataSource } from "../../config/config";
|
|
2
|
+
import { DesignerConfig } from "../../designer/designerConfig";
|
|
3
|
+
import { LegendBlockModel } from "../model";
|
|
4
|
+
import { ModelInstance } from "../modelInstance/modelInstance";
|
|
5
|
+
export interface DataLegendParams {
|
|
6
|
+
amount: number;
|
|
7
|
+
size: {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
4
12
|
export declare class DataManagerModel {
|
|
13
|
+
private static service;
|
|
5
14
|
static getPreparedData(data: MdtChartsDataSource, allowableKeys: string[], config: MdtChartsConfig): MdtChartsDataSource;
|
|
6
|
-
static
|
|
15
|
+
static initDataScope(config: MdtChartsConfig, data: MdtChartsDataSource, designerConfig: DesignerConfig, legendBlock: LegendBlockModel, modelInstance: ModelInstance): void;
|
|
7
16
|
static getDataValuesByKeyField(data: MdtChartsDataSource, dataSourceName: string, keyFieldName: string): string[];
|
|
8
|
-
private static
|
|
9
|
-
private static
|
|
17
|
+
private static initDataScopeFor2D;
|
|
18
|
+
private static initDataScopeForPolar;
|
|
19
|
+
private static getLegendDataParams;
|
|
20
|
+
private static getMaximumPossibleScope;
|
|
21
|
+
private static limitAllowableKeys;
|
|
10
22
|
/**
|
|
11
23
|
* Выводит количество элементов (преимущественно баров) в одной группе. Группа - один ключ
|
|
12
24
|
* @param configOptions
|
|
@@ -1,25 +1,27 @@
|
|
|
1
|
-
import { AxisModel } from "
|
|
2
|
-
import { LegendCanvasModel } from "
|
|
3
|
-
import {
|
|
4
|
-
import { ModelHelper } from "
|
|
1
|
+
import { AxisModel } from "../featuresModel/axisModel";
|
|
2
|
+
import { LegendCanvasModel } from "../featuresModel/legendModel/legendCanvasModel";
|
|
3
|
+
import { LegendPolarMarginCalculator } from "../featuresModel/legendModel/polarMarginCalculator";
|
|
4
|
+
import { ModelHelper } from "../modelHelper";
|
|
5
|
+
import { MIN_DONUT_BLOCK_SIZE, PolarModel } from "../notations/polarModel";
|
|
6
|
+
import { DataManagerModelService } from "./dataManagerModelService";
|
|
5
7
|
export class DataManagerModel {
|
|
6
8
|
static getPreparedData(data, allowableKeys, config) {
|
|
7
9
|
const scopedData = this.getScopedData(data, allowableKeys, config);
|
|
8
10
|
this.setDataType(scopedData, config);
|
|
9
11
|
return scopedData;
|
|
10
12
|
}
|
|
11
|
-
static
|
|
13
|
+
static initDataScope(config, data, designerConfig, legendBlock, modelInstance) {
|
|
12
14
|
if (config.options.type === '2d' || config.options.type === 'interval') {
|
|
13
|
-
|
|
15
|
+
this.initDataScopeFor2D(config.options, modelInstance, data, designerConfig);
|
|
14
16
|
}
|
|
15
17
|
else if (config.options.type === 'polar') {
|
|
16
|
-
|
|
18
|
+
this.initDataScopeForPolar(config.options, modelInstance, data, legendBlock, designerConfig.canvas.legendBlock);
|
|
17
19
|
}
|
|
18
20
|
}
|
|
19
21
|
static getDataValuesByKeyField(data, dataSourceName, keyFieldName) {
|
|
20
22
|
return data[dataSourceName].map(dataRow => dataRow[keyFieldName]);
|
|
21
23
|
}
|
|
22
|
-
static
|
|
24
|
+
static initDataScopeFor2D(configOptions, modelInstance, data, designerConfig) {
|
|
23
25
|
// Для interval всегда один элемент, так как там может быть только один столбик
|
|
24
26
|
let itemsLength = 1;
|
|
25
27
|
if (configOptions.type === '2d') {
|
|
@@ -29,48 +31,59 @@ export class DataManagerModel {
|
|
|
29
31
|
itemsLength = 1; // Если баров нет, то для одной записи выделяется столько же места, сколько для одного столбика
|
|
30
32
|
}
|
|
31
33
|
if (itemsLength !== 0) {
|
|
32
|
-
const axisLength = AxisModel.getAxisLength(configOptions.orientation,
|
|
34
|
+
const axisLength = AxisModel.getAxisLength(configOptions.orientation, modelInstance.canvasModel);
|
|
33
35
|
const uniqueKeys = ModelHelper.getUniqueValues(data[configOptions.data.dataSource].map(d => d[configOptions.data.keyField.name]));
|
|
34
36
|
const dataLength = uniqueKeys.length;
|
|
35
37
|
const limit = this.getDataLimitByItemSize(this.getElementsInGroupAmount(configOptions, itemsLength), dataLength, axisLength, designerConfig.canvas.chartOptions.bar);
|
|
36
38
|
const allowableKeys = uniqueKeys.slice(0, limit);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
const hidedRecordsAmount = dataLength - allowableKeys.length;
|
|
40
|
+
modelInstance.dataModel.initScope(this.limitAllowableKeys(allowableKeys, hidedRecordsAmount, modelInstance.dataModel));
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
const allKeys = this.getDataValuesByKeyField(data, configOptions.data.dataSource, configOptions.data.keyField.name);
|
|
44
|
+
modelInstance.dataModel.initScope(this.getMaximumPossibleScope(allKeys, modelInstance.dataModel));
|
|
41
45
|
}
|
|
42
|
-
return {
|
|
43
|
-
allowableKeys: this.getDataValuesByKeyField(data, configOptions.data.dataSource, configOptions.data.keyField.name),
|
|
44
|
-
hidedRecordsAmount: 0
|
|
45
|
-
};
|
|
46
46
|
}
|
|
47
|
-
static
|
|
48
|
-
const
|
|
47
|
+
static initDataScopeForPolar(configOptions, modelInstance, data, legendBlock, legendCanvas) {
|
|
48
|
+
const canvasModel = modelInstance.canvasModel;
|
|
49
49
|
const keyFieldName = configOptions.data.keyField.name;
|
|
50
|
-
const keys =
|
|
50
|
+
const keys = data[configOptions.data.dataSource].map(dataRow => dataRow[keyFieldName]);
|
|
51
51
|
if (!configOptions.legend.show) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
modelInstance.dataModel.initScope(this.getMaximumPossibleScope(keys, modelInstance.dataModel));
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
let position = PolarModel.getLegendPositionByBlockSize(modelInstance.canvasModel);
|
|
56
|
+
let { amount: maxItemsNumber, size } = this.getLegendDataParams(position, keys, legendCanvas, canvasModel, legendBlock);
|
|
57
|
+
if (position === "right" && !PolarModel.doesChartBlockHasEnoughWidthForContainsLegend(canvasModel.getChartBlockWidth(), size.width, legendBlock.coordinate)) {
|
|
58
|
+
const doesFreeSpaceExist = PolarModel.doesChartBlockHasEnoughHeightForContainsLegend(canvasModel.getChartBlockHeight(), legendBlock.coordinate);
|
|
59
|
+
if (doesFreeSpaceExist) {
|
|
60
|
+
const newParams = this.getLegendDataParams("bottom", keys, legendCanvas, canvasModel, legendBlock);
|
|
61
|
+
position = "bottom";
|
|
62
|
+
maxItemsNumber = newParams.amount;
|
|
63
|
+
size = newParams.size;
|
|
64
|
+
}
|
|
56
65
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
66
|
+
//TODO: global refactor of method
|
|
67
|
+
const allowableKeys = keys.slice(0, maxItemsNumber);
|
|
68
|
+
const hidedRecordsAmount = keys.length - maxItemsNumber;
|
|
69
|
+
const marginCalculator = new LegendPolarMarginCalculator();
|
|
70
|
+
marginCalculator.updateMargin(position, canvasModel, legendBlock, position === "bottom" ? size.height : size.width);
|
|
71
|
+
modelInstance.dataModel.initScope(this.limitAllowableKeys(allowableKeys, hidedRecordsAmount, modelInstance.dataModel));
|
|
72
|
+
}
|
|
73
|
+
//TODO: position type
|
|
74
|
+
static getLegendDataParams(position, keys, legendCanvas, canvasModel, legendBlock) {
|
|
63
75
|
if (position === 'right') {
|
|
64
|
-
|
|
76
|
+
return LegendCanvasModel.findElementsAmountByLegendSize(keys, position, legendCanvas.maxWidth, canvasModel.getChartBlockHeight() - legendBlock.coordinate.bottom.margin.bottom);
|
|
65
77
|
}
|
|
66
78
|
else {
|
|
67
|
-
|
|
68
|
-
maxItemsNumber = LegendCanvasModel.findElementsAmountByLegendSize(keys, position, blockSize.width - margin.left - margin.right, blockSize.height - margin.top - marginBottom - legendBlock.coordinate.bottom.margin.bottom - MIN_DONUT_BLOCK_SIZE);
|
|
79
|
+
return LegendCanvasModel.findElementsAmountByLegendSize(keys, position, canvasModel.getChartBlockWidth() - legendBlock.coordinate.bottom.margin.left - legendBlock.coordinate.bottom.margin.right, canvasModel.getChartBlockHeight() - legendBlock.coordinate.bottom.margin.bottom - legendBlock.coordinate.bottom.margin.top - MIN_DONUT_BLOCK_SIZE);
|
|
69
80
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
81
|
+
}
|
|
82
|
+
static getMaximumPossibleScope(keys, dataModel) {
|
|
83
|
+
return this.service.getMaximumPossibleAmount(keys, dataModel.getMaxRecordsAmount());
|
|
84
|
+
}
|
|
85
|
+
static limitAllowableKeys(allowableKeys, hidedRecordsAmount, dataModel) {
|
|
86
|
+
return this.service.limitAllowableKeys(allowableKeys, hidedRecordsAmount, dataModel.getMaxRecordsAmount());
|
|
74
87
|
}
|
|
75
88
|
/**
|
|
76
89
|
* Выводит количество элементов (преимущественно баров) в одной группе. Группа - один ключ
|
|
@@ -101,13 +114,7 @@ export class DataManagerModel {
|
|
|
101
114
|
return data.filter(d => allowableKeys.findIndex(key => key === d[keyFieldName]) !== -1);
|
|
102
115
|
}
|
|
103
116
|
static setDataType(data, config) {
|
|
104
|
-
if (config.options.type === '
|
|
105
|
-
// Форматиривание для оси ключей пока не совсем верно установлено
|
|
106
|
-
// if(config.options.data.keyField.format === 'date') {
|
|
107
|
-
// data[config.options.data.dataSource] = this.getTypedData(data[config.options.data.dataSource], config.options.data.keyField);
|
|
108
|
-
// }
|
|
109
|
-
}
|
|
110
|
-
else if (config.options.type === 'interval') {
|
|
117
|
+
if (config.options.type === 'interval') {
|
|
111
118
|
const chart = config.options.chart;
|
|
112
119
|
if (chart.data.valueField1.format === 'date') {
|
|
113
120
|
data[config.options.data.dataSource] = this.getTypedData(data[config.options.data.dataSource], chart.data.valueField1);
|
|
@@ -135,3 +142,4 @@ export class DataManagerModel {
|
|
|
135
142
|
return dataLength;
|
|
136
143
|
}
|
|
137
144
|
}
|
|
145
|
+
DataManagerModel.service = new DataManagerModelService();
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DataScope } from "../model";
|
|
2
|
+
export declare class DataManagerModelService {
|
|
3
|
+
getMaximumPossibleAmount(keys: string[], maxPossibleAmount: number): DataScope;
|
|
4
|
+
limitAllowableKeys(allowableKeys: string[], hidedRecordsAmount: number, globalRecordsMaxAmount: number): DataScope;
|
|
5
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export class DataManagerModelService {
|
|
2
|
+
getMaximumPossibleAmount(keys, maxPossibleAmount) {
|
|
3
|
+
if (maxPossibleAmount >= keys.length) {
|
|
4
|
+
return {
|
|
5
|
+
allowableKeys: keys,
|
|
6
|
+
hidedRecordsAmount: 0
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
return {
|
|
11
|
+
allowableKeys: keys.slice(0, maxPossibleAmount),
|
|
12
|
+
hidedRecordsAmount: keys.length - maxPossibleAmount
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
limitAllowableKeys(allowableKeys, hidedRecordsAmount, globalRecordsMaxAmount) {
|
|
17
|
+
if (allowableKeys.length <= globalRecordsMaxAmount) {
|
|
18
|
+
return {
|
|
19
|
+
allowableKeys,
|
|
20
|
+
hidedRecordsAmount
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
allowableKeys: allowableKeys.slice(0, globalRecordsMaxAmount),
|
|
25
|
+
hidedRecordsAmount: hidedRecordsAmount + allowableKeys.length - globalRecordsMaxAmount
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import { AxisPosition, ChartOrientation,
|
|
2
|
-
import {
|
|
1
|
+
import { AxisPosition, ChartOrientation, MdtChartsDataSource, NumberAxisOptions, AxisLabelPosition, MdtChartsTwoDimensionalOptions, DiscreteAxisOptions } from "../../config/config";
|
|
2
|
+
import { AxisModelOptions, Orient } from "../model";
|
|
3
3
|
import { AxisType } from "../modelBuilder";
|
|
4
4
|
import { AxisLabelCanvas, TooltipSettings } from "../../designer/designerConfig";
|
|
5
|
+
import { CanvasModel } from "../modelInstance/canvasModel/canvasModel";
|
|
5
6
|
export interface LabelSize {
|
|
6
7
|
width: number;
|
|
7
8
|
height: number;
|
|
8
9
|
}
|
|
9
10
|
export declare class AxisModel {
|
|
10
|
-
static
|
|
11
|
-
static
|
|
12
|
-
static
|
|
11
|
+
private static service;
|
|
12
|
+
static getKeyAxis(options: MdtChartsTwoDimensionalOptions, data: MdtChartsDataSource, labelConfig: AxisLabelCanvas, canvasModel: CanvasModel, tooltipSettings: TooltipSettings): AxisModelOptions;
|
|
13
|
+
static getValueAxis(orient: ChartOrientation, axisConfig: NumberAxisOptions, labelConfig: AxisLabelCanvas, canvasModel: CanvasModel): AxisModelOptions;
|
|
14
|
+
static getAxisLength(chartOrientation: ChartOrientation, canvasModel: CanvasModel): number;
|
|
13
15
|
static getAxisOrient(axisType: AxisType, chartOrientation: ChartOrientation, axisPosition: AxisPosition): Orient;
|
|
14
|
-
static getAxisTranslateX(axisType: AxisType, chartOrientation: ChartOrientation, axisPosition: AxisPosition,
|
|
15
|
-
static getAxisTranslateY(axisType: AxisType, chartOrientation: ChartOrientation, axisPosition: AxisPosition,
|
|
16
|
-
static getKeyAxisLabelPosition(
|
|
16
|
+
static getAxisTranslateX(axisType: AxisType, chartOrientation: ChartOrientation, axisPosition: AxisPosition, canvasModel: CanvasModel): number;
|
|
17
|
+
static getAxisTranslateY(axisType: AxisType, chartOrientation: ChartOrientation, axisPosition: AxisPosition, canvasModel: CanvasModel): number;
|
|
18
|
+
static getKeyAxisLabelPosition(canvasModel: CanvasModel, scopedDataLength: number, axisConfig?: DiscreteAxisOptions): AxisLabelPosition;
|
|
17
19
|
static getLabelSize(labelMaxWidth: number, labelTexts: any[]): LabelSize;
|
|
18
20
|
}
|