mdt-charts 1.9.7 → 1.9.11
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/README.md +190 -190
- package/dist/index.html +363 -48
- package/dist/listeners.89e1e272264c0e680de8.js +278 -0
- package/dist/main.f8b6bc6fee33cef1116c.js +228 -0
- package/dist/src_engine_engine_ts.ccee2a280374e0083541.js +759 -0
- package/dist/vendors-node_modules_chroma-js_chroma_js-node_modules_d3-array_src_max_js-node_modules_d3-arr-c3fc24.b32acc465b8557229277.js +1869 -0
- package/package.json +57 -57
- package/dist/bundle.js +0 -2
- package/dist/bundle.js.LICENSE.txt +0 -56
- package/lib/config/config.d.ts +0 -146
- package/lib/config/config.js +0 -1
- package/lib/designer/designerConfig.d.ts +0 -71
- package/lib/designer/designerConfig.js +0 -1
- package/lib/engine/block/block.d.ts +0 -35
- package/lib/engine/block/block.js +0 -110
- package/lib/engine/block/blockHelper.d.ts +0 -12
- package/lib/engine/block/blockHelper.js +0 -19
- package/lib/engine/contentManager.d.ts +0 -9
- package/lib/engine/contentManager.js +0 -29
- package/lib/engine/elementHighlighter/elementHighlighter.d.ts +0 -30
- package/lib/engine/elementHighlighter/elementHighlighter.js +0 -197
- package/lib/engine/elementHighlighter/selectHighlighter.d.ts +0 -11
- package/lib/engine/elementHighlighter/selectHighlighter.js +0 -95
- package/lib/engine/engine.d.ts +0 -20
- package/lib/engine/engine.js +0 -64
- package/lib/engine/features/aggregator/aggregator.d.ts +0 -22
- package/lib/engine/features/aggregator/aggregator.js +0 -95
- package/lib/engine/features/axis/axis.d.ts +0 -12
- package/lib/engine/features/axis/axis.js +0 -118
- package/lib/engine/features/axis/axisDomHelper.d.ts +0 -7
- package/lib/engine/features/axis/axisDomHelper.js +0 -24
- package/lib/engine/features/axis/axisHelper.d.ts +0 -9
- package/lib/engine/features/axis/axisHelper.js +0 -53
- package/lib/engine/features/axis/axisLabelDomHelper.d.ts +0 -17
- package/lib/engine/features/axis/axisLabelDomHelper.js +0 -143
- package/lib/engine/features/axis/axisLabelsEventManager.d.ts +0 -6
- package/lib/engine/features/axis/axisLabelsEventManager.js +0 -36
- package/lib/engine/features/embeddedLabels/embeddedLabels.d.ts +0 -23
- package/lib/engine/features/embeddedLabels/embeddedLabels.js +0 -147
- package/lib/engine/features/embeddedLabels/embeddedLabelsDomHelper.d.ts +0 -8
- package/lib/engine/features/embeddedLabels/embeddedLabelsDomHelper.js +0 -30
- package/lib/engine/features/embeddedLabels/embeddedLabelsHelper.d.ts +0 -27
- package/lib/engine/features/embeddedLabels/embeddedLabelsHelper.js +0 -65
- package/lib/engine/features/gridLine/gidLineHelper.d.ts +0 -13
- package/lib/engine/features/gridLine/gidLineHelper.js +0 -30
- package/lib/engine/features/gridLine/gridLine.d.ts +0 -11
- package/lib/engine/features/gridLine/gridLine.js +0 -67
- package/lib/engine/features/legend/legend.d.ts +0 -22
- package/lib/engine/features/legend/legend.js +0 -109
- package/lib/engine/features/legend/legendDomHelper.d.ts +0 -8
- package/lib/engine/features/legend/legendDomHelper.js +0 -48
- package/lib/engine/features/legend/legendEventsManager.d.ts +0 -12
- package/lib/engine/features/legend/legendEventsManager.js +0 -47
- package/lib/engine/features/legend/legendHelper.d.ts +0 -21
- package/lib/engine/features/legend/legendHelper.js +0 -97
- package/lib/engine/features/markDots/markDot.d.ts +0 -20
- package/lib/engine/features/markDots/markDot.js +0 -68
- package/lib/engine/features/markDots/markDotsHelper.d.ts +0 -6
- package/lib/engine/features/markDots/markDotsHelper.js +0 -16
- package/lib/engine/features/recordOverflowAlert/recordOverflowAlert.d.ts +0 -14
- package/lib/engine/features/recordOverflowAlert/recordOverflowAlert.js +0 -97
- package/lib/engine/features/scale/scale.d.ts +0 -16
- package/lib/engine/features/scale/scale.js +0 -74
- package/lib/engine/features/tipBox/tipBox.d.ts +0 -11
- package/lib/engine/features/tipBox/tipBox.js +0 -32
- package/lib/engine/features/tipBox/tipBoxHelper.d.ts +0 -16
- package/lib/engine/features/tipBox/tipBoxHelper.js +0 -48
- package/lib/engine/features/title/title.d.ts +0 -9
- package/lib/engine/features/title/title.js +0 -35
- package/lib/engine/features/tolltip/tooltip.d.ts +0 -19
- package/lib/engine/features/tolltip/tooltip.js +0 -180
- package/lib/engine/features/tolltip/tooltipComponentsManager.d.ts +0 -17
- package/lib/engine/features/tolltip/tooltipComponentsManager.js +0 -127
- package/lib/engine/features/tolltip/tooltipDomHelper.d.ts +0 -36
- package/lib/engine/features/tolltip/tooltipDomHelper.js +0 -114
- package/lib/engine/features/tolltip/tooltipHelper.d.ts +0 -16
- package/lib/engine/features/tolltip/tooltipHelper.js +0 -99
- package/lib/engine/filterManager/filterEventManager.d.ts +0 -33
- package/lib/engine/filterManager/filterEventManager.js +0 -127
- package/lib/engine/helpers/domHelper.d.ts +0 -30
- package/lib/engine/helpers/domHelper.js +0 -68
- package/lib/engine/helpers/helper.d.ts +0 -30
- package/lib/engine/helpers/helper.js +0 -89
- package/lib/engine/helpers/namesHelper.d.ts +0 -5
- package/lib/engine/helpers/namesHelper.js +0 -9
- package/lib/engine/intervalNotation/gantt.d.ts +0 -10
- package/lib/engine/intervalNotation/gantt.js +0 -62
- package/lib/engine/intervalNotation/intervalManager.d.ts +0 -7
- package/lib/engine/intervalNotation/intervalManager.js +0 -30
- package/lib/engine/polarNotation/donut/DonutHelper.d.ts +0 -15
- package/lib/engine/polarNotation/donut/DonutHelper.js +0 -58
- package/lib/engine/polarNotation/donut/donut.d.ts +0 -32
- package/lib/engine/polarNotation/donut/donut.js +0 -124
- package/lib/engine/polarNotation/polarManager.d.ts +0 -10
- package/lib/engine/polarNotation/polarManager.js +0 -55
- package/lib/engine/transitionManager.d.ts +0 -19
- package/lib/engine/transitionManager.js +0 -64
- package/lib/engine/twoDimensionalNotation/area/area.d.ts +0 -17
- package/lib/engine/twoDimensionalNotation/area/area.js +0 -131
- package/lib/engine/twoDimensionalNotation/area/areaHelper.d.ts +0 -9
- package/lib/engine/twoDimensionalNotation/area/areaHelper.js +0 -40
- package/lib/engine/twoDimensionalNotation/bar/bar.d.ts +0 -34
- package/lib/engine/twoDimensionalNotation/bar/bar.js +0 -216
- package/lib/engine/twoDimensionalNotation/bar/barHelper.d.ts +0 -24
- package/lib/engine/twoDimensionalNotation/bar/barHelper.js +0 -103
- package/lib/engine/twoDimensionalNotation/line/line.d.ts +0 -17
- package/lib/engine/twoDimensionalNotation/line/line.js +0 -132
- package/lib/engine/twoDimensionalNotation/line/lineHelper.d.ts +0 -8
- package/lib/engine/twoDimensionalNotation/line/lineHelper.js +0 -28
- package/lib/engine/twoDimensionalNotation/twoDimensionalManager.d.ts +0 -11
- package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +0 -101
- package/lib/engine/valueFormatter.d.ts +0 -6
- package/lib/engine/valueFormatter.js +0 -8
- package/lib/main.d.ts +0 -79
- package/lib/main.js +0 -85
- package/lib/model/chartStyleModel.d.ts +0 -16
- package/lib/model/chartStyleModel.js +0 -67
- package/lib/model/dataManagerModel.d.ts +0 -22
- package/lib/model/dataManagerModel.js +0 -137
- package/lib/model/featuresModel/axisModel.d.ts +0 -18
- package/lib/model/featuresModel/axisModel.js +0 -111
- package/lib/model/featuresModel/legendModel/legendCanvasModel.d.ts +0 -7
- package/lib/model/featuresModel/legendModel/legendCanvasModel.js +0 -86
- package/lib/model/featuresModel/legendModel/legendModel.d.ts +0 -13
- package/lib/model/featuresModel/legendModel/legendModel.js +0 -78
- package/lib/model/featuresModel/otherComponents.d.ts +0 -6
- package/lib/model/featuresModel/otherComponents.js +0 -12
- package/lib/model/featuresModel/scaleModel.d.ts +0 -17
- package/lib/model/featuresModel/scaleModel.js +0 -100
- package/lib/model/featuresModel/titleModel.d.ts +0 -4
- package/lib/model/featuresModel/titleModel.js +0 -14
- package/lib/model/featuresModel/tooltipModel.d.ts +0 -4
- package/lib/model/featuresModel/tooltipModel.js +0 -7
- package/lib/model/marginModel.d.ts +0 -19
- package/lib/model/marginModel.js +0 -126
- package/lib/model/model.d.ts +0 -220
- package/lib/model/model.js +0 -1
- package/lib/model/modelBuilder.d.ts +0 -16
- package/lib/model/modelBuilder.js +0 -128
- package/lib/model/modelHelper.d.ts +0 -7
- package/lib/model/modelHelper.js +0 -41
- package/lib/model/notations/intervalModel.d.ts +0 -8
- package/lib/model/notations/intervalModel.js +0 -93
- package/lib/model/notations/polarModel.d.ts +0 -7
- package/lib/model/notations/polarModel.js +0 -27
- package/lib/model/notations/twoDimensionalModel.d.ts +0 -19
- package/lib/model/notations/twoDimensionalModel.js +0 -85
- package/lib/style/charts-main.css +0 -240
- package/lib/style/charts-main.less +0 -240
- package/test.html +0 -196
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { stack } from 'd3-shape';
|
|
2
|
-
import { select } from 'd3-selection';
|
|
3
|
-
import { MarkDot } from "../../features/markDots/markDot";
|
|
4
|
-
import { AreaHelper } from './areaHelper';
|
|
5
|
-
import { DomHelper } from '../../helpers/domHelper';
|
|
6
|
-
import { Helper } from '../../helpers/helper';
|
|
7
|
-
export class Area {
|
|
8
|
-
static render(block, scales, data, keyField, margin, keyAxisOrient, chart, blockSize) {
|
|
9
|
-
if (chart.isSegmented)
|
|
10
|
-
this.renderSegmented(block, scales, data, keyField, margin, keyAxisOrient, chart);
|
|
11
|
-
else
|
|
12
|
-
this.renderGrouped(block, scales, data, keyField, margin, keyAxisOrient, chart, blockSize);
|
|
13
|
-
}
|
|
14
|
-
static update(block, scales, newData, keyField, margin, chart, keyAxisOrient, blockSize) {
|
|
15
|
-
let promises;
|
|
16
|
-
if (chart.isSegmented) {
|
|
17
|
-
promises = this.updateSegmented(block, scales, newData, keyField, margin, chart, keyAxisOrient);
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
promises = this.updateGrouped(block, scales, newData, keyField, margin, chart, keyAxisOrient, blockSize);
|
|
21
|
-
}
|
|
22
|
-
return promises;
|
|
23
|
-
}
|
|
24
|
-
static updateColors(block, chart) {
|
|
25
|
-
chart.data.valueFields.forEach((_vf, valueIndex) => {
|
|
26
|
-
const path = block.getChartGroup(chart.index)
|
|
27
|
-
.select(`.${this.areaChartClass}${Helper.getCssClassesLine(chart.cssClasses)}.chart-element-${valueIndex}`);
|
|
28
|
-
DomHelper.setChartStyle(path, chart.style, valueIndex, 'fill');
|
|
29
|
-
MarkDot.updateColors(block, chart, valueIndex);
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
static renderGrouped(block, scales, data, keyField, margin, keyAxisOrient, chart, blockSize) {
|
|
33
|
-
chart.data.valueFields.forEach((field, valueIndex) => {
|
|
34
|
-
const area = AreaHelper.getGroupedAreaGenerator(keyAxisOrient, scales, margin, keyField.name, field.name, blockSize);
|
|
35
|
-
const path = block.getChartGroup(chart.index)
|
|
36
|
-
.append('path')
|
|
37
|
-
.attr('d', area(data))
|
|
38
|
-
.attr('class', this.areaChartClass)
|
|
39
|
-
.style('clip-path', `url(#${block.getClipPathId()})`)
|
|
40
|
-
.style('pointer-events', 'none');
|
|
41
|
-
DomHelper.setCssClasses(path, Helper.getCssClassesWithElementIndex(chart.cssClasses, valueIndex));
|
|
42
|
-
DomHelper.setChartStyle(path, chart.style, valueIndex, 'fill');
|
|
43
|
-
MarkDot.render(block, data, keyAxisOrient, scales, margin, keyField.name, valueIndex, field.name, chart);
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
static renderSegmented(block, scales, data, keyField, margin, keyAxisOrient, chart) {
|
|
47
|
-
const stackedData = stack().keys(chart.data.valueFields.map(field => field.name))(data);
|
|
48
|
-
const areaGenerator = AreaHelper.getSegmentedAreaGenerator(keyAxisOrient, scales, margin, keyField.name);
|
|
49
|
-
const areas = block.getChartGroup(chart.index)
|
|
50
|
-
.selectAll(`.${this.areaChartClass}${Helper.getCssClassesLine(chart.cssClasses)}`)
|
|
51
|
-
.data(stackedData)
|
|
52
|
-
.enter()
|
|
53
|
-
.append('path')
|
|
54
|
-
.attr('d', d => areaGenerator(d))
|
|
55
|
-
.attr('class', this.areaChartClass)
|
|
56
|
-
.style('clip-path', `url(#${block.getClipPathId()})`)
|
|
57
|
-
.style('pointer-events', 'none');
|
|
58
|
-
areas.each(function (d, i) {
|
|
59
|
-
DomHelper.setCssClasses(select(this), Helper.getCssClassesWithElementIndex(chart.cssClasses, i));
|
|
60
|
-
});
|
|
61
|
-
this.setSegmentColor(areas, chart.style.elementColors);
|
|
62
|
-
stackedData.forEach((dataset, index) => {
|
|
63
|
-
MarkDot.render(block, dataset, keyAxisOrient, scales, margin, keyField.name, index, '1', chart);
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
static updateGrouped(block, scales, newData, keyField, margin, chart, keyAxisOrient, blockSize) {
|
|
67
|
-
const promises = [];
|
|
68
|
-
chart.data.valueFields.forEach((field, valueIndex) => {
|
|
69
|
-
const areaGenerator = AreaHelper.getGroupedAreaGenerator(keyAxisOrient, scales, margin, keyField.name, field.name, blockSize);
|
|
70
|
-
const areaObject = block.getChartGroup(chart.index)
|
|
71
|
-
.select(`.${this.areaChartClass}${Helper.getCssClassesLine(chart.cssClasses)}.chart-element-${valueIndex}`);
|
|
72
|
-
const prom = this.updateGroupedPath(block, areaObject, areaGenerator, newData);
|
|
73
|
-
promises.push(prom);
|
|
74
|
-
MarkDot.update(block, newData, keyAxisOrient, scales, margin, keyField.name, valueIndex, field.name, chart);
|
|
75
|
-
});
|
|
76
|
-
return promises;
|
|
77
|
-
}
|
|
78
|
-
static updateSegmented(block, scales, newData, keyField, margin, chart, keyAxisOrient) {
|
|
79
|
-
const stackedData = stack().keys(chart.data.valueFields.map(field => field.name))(newData);
|
|
80
|
-
const areaGenerator = AreaHelper.getSegmentedAreaGenerator(keyAxisOrient, scales, margin, keyField.name);
|
|
81
|
-
const areas = block.getChartGroup(chart.index)
|
|
82
|
-
.selectAll(`path.${this.areaChartClass}${Helper.getCssClassesLine(chart.cssClasses)}`)
|
|
83
|
-
.data(stackedData);
|
|
84
|
-
const prom = this.updateSegmentedPath(block, areas, areaGenerator);
|
|
85
|
-
areas.each((dataset, index) => {
|
|
86
|
-
// '1' - атрибут, показывающий координаты согласно полю значения
|
|
87
|
-
MarkDot.update(block, dataset, keyAxisOrient, scales, margin, keyField.name, index, '1', chart);
|
|
88
|
-
});
|
|
89
|
-
return [prom];
|
|
90
|
-
}
|
|
91
|
-
static updateGroupedPath(block, areaObject, areaGenerator, newData) {
|
|
92
|
-
return new Promise(resolve => {
|
|
93
|
-
if (areaObject.size() === 0) {
|
|
94
|
-
resolve('');
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
let areaHandler = areaObject;
|
|
98
|
-
if (block.transitionManager.durations.chartUpdate > 0)
|
|
99
|
-
areaHandler = areaHandler.interrupt()
|
|
100
|
-
.transition()
|
|
101
|
-
.duration(block.transitionManager.durations.chartUpdate)
|
|
102
|
-
.on('end', () => resolve(''));
|
|
103
|
-
areaHandler
|
|
104
|
-
.attr('d', areaGenerator(newData));
|
|
105
|
-
if (block.transitionManager.durations.chartUpdate <= 0)
|
|
106
|
-
resolve('');
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
static updateSegmentedPath(block, areasObjects, areaGenerator) {
|
|
110
|
-
return new Promise(resolve => {
|
|
111
|
-
if (areasObjects.size() === 0) {
|
|
112
|
-
resolve('');
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
let areaHandler = areasObjects;
|
|
116
|
-
if (block.transitionManager.durations.chartUpdate > 0)
|
|
117
|
-
areaHandler = areaHandler.interrupt()
|
|
118
|
-
.transition()
|
|
119
|
-
.duration(block.transitionManager.durations.chartUpdate)
|
|
120
|
-
.on('end', () => resolve(''));
|
|
121
|
-
areaHandler
|
|
122
|
-
.attr('d', d => areaGenerator(d));
|
|
123
|
-
if (block.transitionManager.durations.chartUpdate <= 0)
|
|
124
|
-
resolve('');
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
static setSegmentColor(segments, colorPalette) {
|
|
128
|
-
segments.style('fill', (d, i) => colorPalette[i % colorPalette.length]);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
Area.areaChartClass = 'area';
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Area as IArea } from 'd3-shape';
|
|
2
|
-
import { MdtChartsDataRow, Size } from '../../../config/config';
|
|
3
|
-
import { BlockMargin, Orient } from "../../../model/model";
|
|
4
|
-
import { Scales } from "../../features/scale/scale";
|
|
5
|
-
export declare class AreaHelper {
|
|
6
|
-
static getGroupedAreaGenerator(keyAxisOrient: Orient, scales: Scales, margin: BlockMargin, keyFieldName: string, valueFieldName: string, blockSize: Size): IArea<MdtChartsDataRow>;
|
|
7
|
-
static getSegmentedAreaGenerator(keyAxisOrient: Orient, scales: Scales, margin: BlockMargin, keyFieldName: string): IArea<MdtChartsDataRow>;
|
|
8
|
-
static getZeroCoordinate(axisOrient: Orient, margin: BlockMargin, blockSize: Size): number;
|
|
9
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { area } from 'd3-shape';
|
|
2
|
-
import { Scale } from "../../features/scale/scale";
|
|
3
|
-
export class AreaHelper {
|
|
4
|
-
static getGroupedAreaGenerator(keyAxisOrient, scales, margin, keyFieldName, valueFieldName, blockSize) {
|
|
5
|
-
if (keyAxisOrient === 'bottom' || keyAxisOrient === 'top')
|
|
6
|
-
return area()
|
|
7
|
-
.x(d => Scale.getScaledValue(scales.key, d[keyFieldName]) + margin.left)
|
|
8
|
-
.y0(d => this.getZeroCoordinate(keyAxisOrient, margin, blockSize))
|
|
9
|
-
.y1(d => scales.value(d[valueFieldName]) + margin.top);
|
|
10
|
-
if (keyAxisOrient === 'left' || keyAxisOrient === 'right')
|
|
11
|
-
return area()
|
|
12
|
-
.x0(d => this.getZeroCoordinate(keyAxisOrient, margin, blockSize))
|
|
13
|
-
.x1(d => scales.value(d[valueFieldName]) + margin.left)
|
|
14
|
-
.y(d => Scale.getScaledValue(scales.key, d[keyFieldName]) + margin.top);
|
|
15
|
-
}
|
|
16
|
-
static getSegmentedAreaGenerator(keyAxisOrient, scales, margin, keyFieldName) {
|
|
17
|
-
if (keyAxisOrient === 'bottom' || keyAxisOrient === 'top') {
|
|
18
|
-
return area()
|
|
19
|
-
.x(d => Scale.getScaledValue(scales.key, d.data[keyFieldName]) + margin.left)
|
|
20
|
-
.y0(d => scales.value(d[0]) + margin.top)
|
|
21
|
-
.y1(d => scales.value(d[1]) + margin.top);
|
|
22
|
-
}
|
|
23
|
-
if (keyAxisOrient === 'left' || keyAxisOrient === 'right') {
|
|
24
|
-
return area()
|
|
25
|
-
.x0(d => scales.value(d[0]) + margin.left)
|
|
26
|
-
.x1(d => scales.value(d[1]) + margin.left)
|
|
27
|
-
.y(d => Scale.getScaledValue(scales.key, d.data[keyFieldName]) + margin.top);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
static getZeroCoordinate(axisOrient, margin, blockSize) {
|
|
31
|
-
if (axisOrient === 'bottom')
|
|
32
|
-
return blockSize.height - margin.bottom;
|
|
33
|
-
if (axisOrient === 'top')
|
|
34
|
-
return margin.top;
|
|
35
|
-
if (axisOrient === 'left')
|
|
36
|
-
return margin.left;
|
|
37
|
-
if (axisOrient === 'right')
|
|
38
|
-
return blockSize.width - margin.right;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Selection, BaseType } from 'd3-selection';
|
|
2
|
-
import { BarChartSettings, BlockMargin, Field, Orient, TwoDimensionalChartModel } from "../../../model/model";
|
|
3
|
-
import { Scales } from "../../features/scale/scale";
|
|
4
|
-
import { Block } from "../../block/block";
|
|
5
|
-
import { MdtChartsDataRow, Size } from "../../../config/config";
|
|
6
|
-
export interface RectElemWithAttrs extends SVGElement {
|
|
7
|
-
attrs?: {
|
|
8
|
-
x: number;
|
|
9
|
-
y: number;
|
|
10
|
-
width: number;
|
|
11
|
-
height: number;
|
|
12
|
-
orient: 'vertical' | 'horizontal';
|
|
13
|
-
scaleSize: number;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
export declare class Bar {
|
|
17
|
-
static readonly barItemClass = "bar-item";
|
|
18
|
-
static readonly barItemCloneClass = "bar-item-clone";
|
|
19
|
-
private static readonly barSegmentGroupClass;
|
|
20
|
-
static render(block: Block, scales: Scales, data: MdtChartsDataRow[], keyField: Field, margin: BlockMargin, keyAxisOrient: Orient, chart: TwoDimensionalChartModel, blockSize: Size, barSettings: BarChartSettings, barsAmounts: number[], isSegmented: boolean, firstBarIndex: number): void;
|
|
21
|
-
static update(block: Block, newData: MdtChartsDataRow[], scales: Scales, margin: BlockMargin, keyAxisOrient: Orient, chart: TwoDimensionalChartModel, blockSize: Size, barsAmounts: number[], keyField: Field, firstBarIndex: number, barSettings: BarChartSettings, isSegmented: boolean): Promise<any>[];
|
|
22
|
-
static updateColors(block: Block, chart: TwoDimensionalChartModel): void;
|
|
23
|
-
static getAllBarsForChart(block: Block, chartCssClasses: string[]): Selection<BaseType, MdtChartsDataRow, BaseType, unknown>;
|
|
24
|
-
private static renderGrouped;
|
|
25
|
-
private static renderSegmented;
|
|
26
|
-
private static updateGrouped;
|
|
27
|
-
private static updateSegmented;
|
|
28
|
-
private static fillBarAttrs;
|
|
29
|
-
private static setSegmentColor;
|
|
30
|
-
/**
|
|
31
|
-
* Устнановка координат для удобного обновления.
|
|
32
|
-
*/
|
|
33
|
-
private static setInitialAttrsInfo;
|
|
34
|
-
}
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
import { stack } from 'd3-shape';
|
|
2
|
-
import { select } from 'd3-selection';
|
|
3
|
-
import { EmbeddedLabels } from "../../features/embeddedLabels/embeddedLabels";
|
|
4
|
-
import { EmbeddedLabelsHelper } from "../../features/embeddedLabels/embeddedLabelsHelper";
|
|
5
|
-
import { BarHelper } from "./barHelper";
|
|
6
|
-
import { sum } from "d3-array";
|
|
7
|
-
import { DomHelper } from "../../helpers/domHelper";
|
|
8
|
-
import { Helper } from "../../helpers/helper";
|
|
9
|
-
export class Bar {
|
|
10
|
-
static render(block, scales, data, keyField, margin, keyAxisOrient, chart, blockSize, barSettings, barsAmounts, isSegmented, firstBarIndex) {
|
|
11
|
-
if (isSegmented)
|
|
12
|
-
this.renderSegmented(block, scales, data, keyField, margin, keyAxisOrient, chart, barsAmounts, blockSize, firstBarIndex, barSettings);
|
|
13
|
-
else
|
|
14
|
-
this.renderGrouped(block, scales, data, keyField, margin, keyAxisOrient, chart, barsAmounts, blockSize, firstBarIndex, barSettings);
|
|
15
|
-
}
|
|
16
|
-
static update(block, newData, scales, margin, keyAxisOrient, chart, blockSize, barsAmounts, keyField, firstBarIndex, barSettings, isSegmented) {
|
|
17
|
-
let promises;
|
|
18
|
-
if (isSegmented) {
|
|
19
|
-
promises = this.updateSegmented(block, newData, scales, margin, keyAxisOrient, chart, blockSize, barsAmounts, keyField, firstBarIndex, barSettings);
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
promises = this.updateGrouped(block, newData, scales, margin, keyAxisOrient, chart, blockSize, barsAmounts, keyField, firstBarIndex, barSettings);
|
|
23
|
-
}
|
|
24
|
-
return promises;
|
|
25
|
-
}
|
|
26
|
-
static updateColors(block, chart) {
|
|
27
|
-
chart.data.valueFields.forEach((_vf, index) => {
|
|
28
|
-
const bars = block.getChartGroup(chart.index)
|
|
29
|
-
.selectAll(`.${this.barItemClass}${Helper.getCssClassesLine(chart.cssClasses)}${Helper.getCssClassesLine(Helper.getCssClassesWithElementIndex(chart.cssClasses, index))}`);
|
|
30
|
-
DomHelper.setChartStyle(bars, chart.style, index, 'fill');
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
static getAllBarsForChart(block, chartCssClasses) {
|
|
34
|
-
return block.getSvg().selectAll(`rect.${this.barItemClass}${Helper.getCssClassesLine(chartCssClasses)}`);
|
|
35
|
-
}
|
|
36
|
-
static renderGrouped(block, scales, data, keyField, margin, keyAxisOrient, chart, barsAmounts, blockSize, firstBarIndex, barSettings) {
|
|
37
|
-
chart.data.valueFields.forEach((field, index) => {
|
|
38
|
-
const bars = block.getChartGroup(chart.index)
|
|
39
|
-
.selectAll(`.${this.barItemClass}${Helper.getCssClassesLine(chart.cssClasses)}${Helper.getCssClassesLine(Helper.getCssClassesWithElementIndex(chart.cssClasses, index))}`)
|
|
40
|
-
.data(data)
|
|
41
|
-
.enter()
|
|
42
|
-
.append('rect')
|
|
43
|
-
.attr('class', this.barItemClass)
|
|
44
|
-
.style('clip-path', `url(#${block.getClipPathId()})`);
|
|
45
|
-
const barAttrs = BarHelper.getGroupedBarAttrs(keyAxisOrient, scales, margin, keyField.name, field.name, blockSize, BarHelper.getBarIndex(barsAmounts, chart.index - firstBarIndex) + index, sum(barsAmounts), barSettings);
|
|
46
|
-
this.fillBarAttrs(bars, barAttrs);
|
|
47
|
-
DomHelper.setCssClasses(bars, Helper.getCssClassesWithElementIndex(chart.cssClasses, index));
|
|
48
|
-
DomHelper.setChartStyle(bars, chart.style, index, 'fill');
|
|
49
|
-
this.setInitialAttrsInfo(bars, keyAxisOrient, barSettings);
|
|
50
|
-
if (chart.embeddedLabels !== 'none')
|
|
51
|
-
EmbeddedLabels.render(block, bars, barAttrs, EmbeddedLabelsHelper.getLabelField(chart.embeddedLabels, chart.data.valueFields, keyField, index), chart.embeddedLabels, keyAxisOrient, blockSize, margin, index, chart.cssClasses);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
static renderSegmented(block, scales, data, keyField, margin, keyAxisOrient, chart, barsAmounts, blockSize, firstBarIndex, barSettings) {
|
|
55
|
-
const stackedData = stack().keys(chart.data.valueFields.map(field => field.name))(data);
|
|
56
|
-
let groups = block.getChartGroup(chart.index)
|
|
57
|
-
.selectAll(`g.${this.barSegmentGroupClass}${Helper.getCssClassesLine(chart.cssClasses)}`)
|
|
58
|
-
.data(stackedData);
|
|
59
|
-
if (groups.empty())
|
|
60
|
-
groups = groups
|
|
61
|
-
.data(stackedData)
|
|
62
|
-
.enter()
|
|
63
|
-
.append('g')
|
|
64
|
-
.attr('class', this.barSegmentGroupClass);
|
|
65
|
-
const bars = groups
|
|
66
|
-
.selectAll(`rect${Helper.getCssClassesLine(chart.cssClasses)}`)
|
|
67
|
-
.data(d => d)
|
|
68
|
-
.enter()
|
|
69
|
-
.append('rect')
|
|
70
|
-
.attr('class', this.barItemClass)
|
|
71
|
-
.style('clip-path', `url(#${block.getClipPathId()})`);
|
|
72
|
-
const barAttrs = BarHelper.getStackedBarAttr(keyAxisOrient, scales, margin, keyField.name, blockSize, BarHelper.getBarIndex(barsAmounts, chart.index) - firstBarIndex, sum(barsAmounts), barSettings);
|
|
73
|
-
this.fillBarAttrs(bars, barAttrs);
|
|
74
|
-
this.setInitialAttrsInfo(bars, keyAxisOrient, barSettings);
|
|
75
|
-
DomHelper.setCssClasses(groups, chart.cssClasses);
|
|
76
|
-
DomHelper.setCssClasses(bars, chart.cssClasses); // Для обозначения принадлежности бара к конкретному чарту
|
|
77
|
-
const thisClass = this;
|
|
78
|
-
groups.each(function (d, i) {
|
|
79
|
-
DomHelper.setCssClasses(select(this).selectAll(`rect${Helper.getCssClassesLine(chart.cssClasses)}`), Helper.getCssClassesWithElementIndex(chart.cssClasses, i)); // Для обозначения принадлежности бара к конкретной части стака
|
|
80
|
-
thisClass.setSegmentColor(select(this).selectAll(Helper.getCssClassesLine(chart.cssClasses)), chart.style.elementColors, i);
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
static updateGrouped(block, newData, scales, margin, keyAxisOrient, chart, blockSize, barsAmounts, keyField, firstBarIndex, barSettings) {
|
|
84
|
-
const promises = [];
|
|
85
|
-
chart.data.valueFields.forEach((valueField, index) => {
|
|
86
|
-
const indexesOfRemoved = [];
|
|
87
|
-
block.getChartGroup(chart.index)
|
|
88
|
-
.selectAll(`.${this.barItemClass}${Helper.getCssClassesLine(chart.cssClasses)}.chart-element-${index}`)
|
|
89
|
-
.filter((d, i) => {
|
|
90
|
-
if (newData.findIndex(row => row[keyField.name] === d[keyField.name]) === -1) {
|
|
91
|
-
indexesOfRemoved.push(i); // Набор индексов для встроенных лейблов
|
|
92
|
-
return true;
|
|
93
|
-
}
|
|
94
|
-
return false;
|
|
95
|
-
})
|
|
96
|
-
.transition()
|
|
97
|
-
.duration(block.transitionManager.durations.elementFadeOut)
|
|
98
|
-
.style('opacity', 0)
|
|
99
|
-
.remove();
|
|
100
|
-
const bars = block.getChartGroup(chart.index)
|
|
101
|
-
.selectAll(`.${this.barItemClass}${Helper.getCssClassesLine(chart.cssClasses)}.chart-element-${index}`)
|
|
102
|
-
.filter(d => newData.findIndex(row => row[keyField.name] === d[keyField.name]) !== -1)
|
|
103
|
-
.style('opacity', 1)
|
|
104
|
-
.data(newData);
|
|
105
|
-
const newBars = bars
|
|
106
|
-
.enter()
|
|
107
|
-
.append('rect')
|
|
108
|
-
.attr('class', this.barItemClass)
|
|
109
|
-
.style('clip-path', `url(#${block.getClipPathId()})`);
|
|
110
|
-
const barAttrs = BarHelper.getGroupedBarAttrs(keyAxisOrient, scales, margin, keyField.name, valueField.name, blockSize, BarHelper.getBarIndex(barsAmounts, chart.index) + index - firstBarIndex, sum(barsAmounts), barSettings);
|
|
111
|
-
const prom = this.fillBarAttrs(bars, barAttrs, block.transitionManager.durations.chartUpdate)
|
|
112
|
-
.then(() => {
|
|
113
|
-
bars.style('opacity', null);
|
|
114
|
-
this.setInitialAttrsInfo(bars, keyAxisOrient, barSettings);
|
|
115
|
-
});
|
|
116
|
-
this.fillBarAttrs(newBars, barAttrs);
|
|
117
|
-
promises.push(prom);
|
|
118
|
-
this.setInitialAttrsInfo(newBars, keyAxisOrient, barSettings);
|
|
119
|
-
DomHelper.setCssClasses(newBars, Helper.getCssClassesWithElementIndex(chart.cssClasses, index));
|
|
120
|
-
DomHelper.setChartStyle(newBars, chart.style, index, 'fill');
|
|
121
|
-
if (chart.embeddedLabels !== 'none') {
|
|
122
|
-
EmbeddedLabels.removeUnused(block, chart.cssClasses, index, indexesOfRemoved);
|
|
123
|
-
EmbeddedLabels.update(block, bars, keyAxisOrient, barAttrs, margin, valueField, chart.embeddedLabels, blockSize, newData, index, chart.cssClasses);
|
|
124
|
-
if (!newBars.empty())
|
|
125
|
-
EmbeddedLabels.render(block, newBars, barAttrs, valueField, chart.embeddedLabels, keyAxisOrient, blockSize, margin, index, chart.cssClasses);
|
|
126
|
-
EmbeddedLabels.restoreRemoved(block, bars, barAttrs, valueField, chart.embeddedLabels, keyAxisOrient, blockSize, margin, index, chart.cssClasses, keyField.name);
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
return promises;
|
|
130
|
-
}
|
|
131
|
-
static updateSegmented(block, newData, scales, margin, keyAxisOrient, chart, blockSize, barsAmounts, keyField, firstBarIndex, barSettings) {
|
|
132
|
-
const stackedData = stack().keys(chart.data.valueFields.map(field => field.name))(newData);
|
|
133
|
-
block.getChartGroup(chart.index)
|
|
134
|
-
.selectAll(`.${this.barItemClass}${Helper.getCssClassesLine(chart.cssClasses)}`)
|
|
135
|
-
.filter(d => newData.findIndex(row => row[keyField.name] === d.data[keyField.name]) === -1)
|
|
136
|
-
.transition()
|
|
137
|
-
.duration(block.transitionManager.durations.elementFadeOut)
|
|
138
|
-
.style('opacity', 0)
|
|
139
|
-
.remove();
|
|
140
|
-
const groups = block.getChartGroup(chart.index)
|
|
141
|
-
.selectAll(`g.${this.barSegmentGroupClass}${Helper.getCssClassesLine(chart.cssClasses)}`)
|
|
142
|
-
.data(stackedData);
|
|
143
|
-
const bars = groups
|
|
144
|
-
.selectAll(`.${this.barItemClass}${Helper.getCssClassesLine(chart.cssClasses)}`)
|
|
145
|
-
.filter(d => newData.findIndex(row => row[keyField.name] === d.data[keyField.name]) !== -1)
|
|
146
|
-
.style('opacity', 1)
|
|
147
|
-
.data(d => d);
|
|
148
|
-
const newBars = bars.enter()
|
|
149
|
-
.append('rect')
|
|
150
|
-
.attr('class', this.barItemClass)
|
|
151
|
-
.style('clip-path', `url(#${block.getClipPathId()})`);
|
|
152
|
-
const barAttrs = BarHelper.getStackedBarAttr(keyAxisOrient, scales, margin, keyField.name, blockSize, BarHelper.getBarIndex(barsAmounts, chart.index) - firstBarIndex, sum(barsAmounts), barSettings);
|
|
153
|
-
const prom = this.fillBarAttrs(bars, barAttrs, block.transitionManager.durations.chartUpdate)
|
|
154
|
-
.then(() => {
|
|
155
|
-
this.setInitialAttrsInfo(bars, keyAxisOrient, barSettings);
|
|
156
|
-
bars.style('opacity', null);
|
|
157
|
-
});
|
|
158
|
-
this.fillBarAttrs(newBars, barAttrs);
|
|
159
|
-
this.setInitialAttrsInfo(newBars, keyAxisOrient, barSettings);
|
|
160
|
-
DomHelper.setCssClasses(newBars, chart.cssClasses);
|
|
161
|
-
const thisClass = this;
|
|
162
|
-
groups.each(function (d, i) {
|
|
163
|
-
DomHelper.setCssClasses(select(this).selectAll(`rect${Helper.getCssClassesLine(chart.cssClasses)}`), Helper.getCssClassesWithElementIndex(chart.cssClasses, i)); // Для обозначения принадлежности бара к конкретной части стака
|
|
164
|
-
thisClass.setSegmentColor(select(this).selectAll(Helper.getCssClassesLine(chart.cssClasses)), chart.style.elementColors, i);
|
|
165
|
-
});
|
|
166
|
-
return [prom];
|
|
167
|
-
}
|
|
168
|
-
static fillBarAttrs(bars, barAttrs, transitionDuration = 0) {
|
|
169
|
-
return new Promise((resolve) => {
|
|
170
|
-
if (bars.size() === 0) {
|
|
171
|
-
resolve('');
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
let barsHander = bars;
|
|
175
|
-
if (transitionDuration > 0) {
|
|
176
|
-
barsHander = barsHander
|
|
177
|
-
.interrupt()
|
|
178
|
-
.transition()
|
|
179
|
-
.duration(transitionDuration)
|
|
180
|
-
.on('end', () => resolve(''));
|
|
181
|
-
}
|
|
182
|
-
barsHander.attr('x', d => barAttrs.x(d))
|
|
183
|
-
.attr('y', d => barAttrs.y(d))
|
|
184
|
-
.attr('height', d => barAttrs.height(d))
|
|
185
|
-
.attr('width', d => barAttrs.width(d));
|
|
186
|
-
if (transitionDuration <= 0)
|
|
187
|
-
resolve('');
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
static setSegmentColor(segments, colorPalette, segmentedIndex) {
|
|
191
|
-
segments.style('fill', colorPalette[segmentedIndex % colorPalette.length]);
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Устнановка координат для удобного обновления.
|
|
195
|
-
*/
|
|
196
|
-
static setInitialAttrsInfo(bars, keyAxisOrient, barSettings) {
|
|
197
|
-
bars.each(function () {
|
|
198
|
-
const width = DomHelper.getSelectionNumericAttr(select(this), 'width');
|
|
199
|
-
const height = DomHelper.getSelectionNumericAttr(select(this), 'height');
|
|
200
|
-
const orient = keyAxisOrient === 'left' || keyAxisOrient === 'right' ? 'horizontal' : 'vertical';
|
|
201
|
-
let scaleSize = 0.06 * (orient === 'vertical' ? width : height);
|
|
202
|
-
scaleSize = scaleSize > barSettings.barDistance / 2 ? barSettings.barDistance / 2 : scaleSize;
|
|
203
|
-
this.attrs = {
|
|
204
|
-
x: DomHelper.getSelectionNumericAttr(select(this), 'x'),
|
|
205
|
-
y: DomHelper.getSelectionNumericAttr(select(this), 'y'),
|
|
206
|
-
width,
|
|
207
|
-
height,
|
|
208
|
-
orient,
|
|
209
|
-
scaleSize
|
|
210
|
-
};
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
Bar.barItemClass = 'bar-item';
|
|
215
|
-
Bar.barItemCloneClass = 'bar-item-clone';
|
|
216
|
-
Bar.barSegmentGroupClass = 'bar-segment-group';
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { BarChartSettings, BlockMargin, Orient, TwoDimensionalChartModel } from "../../../model/model";
|
|
2
|
-
import { Scales } from "../../features/scale/scale";
|
|
3
|
-
import { MdtChartsDataRow, Size } from "../../../config/config";
|
|
4
|
-
export interface BarAttrsHelper {
|
|
5
|
-
x: (dataRow: MdtChartsDataRow) => number;
|
|
6
|
-
y: (dataRow: MdtChartsDataRow) => number;
|
|
7
|
-
width: (dataRow: MdtChartsDataRow) => number;
|
|
8
|
-
height: (dataRow: MdtChartsDataRow) => number;
|
|
9
|
-
}
|
|
10
|
-
export declare class BarHelper {
|
|
11
|
-
static getGroupedBarAttrs(keyAxisOrient: Orient, scales: Scales, margin: BlockMargin, keyField: string, valueFieldName: string, blockSize: Size, barIndex: number, barsAmount: number, barSettings: BarChartSettings): BarAttrsHelper;
|
|
12
|
-
static getStackedBarAttr(keyAxisOrient: Orient, scales: Scales, margin: BlockMargin, keyField: string, blockSize: Size, barIndex: number, barsAmount: number, barSettings: BarChartSettings): BarAttrsHelper;
|
|
13
|
-
static getBarsInGroupAmount(charts: TwoDimensionalChartModel[]): number[];
|
|
14
|
-
/**
|
|
15
|
-
* Получение индекса бара среди всх графиков и value-филдов. Используется для того, чтобы узнать, какой по счету в группе
|
|
16
|
-
* этот бар идет (сегментированный всегда один, группированный - количество value-филдов).
|
|
17
|
-
* @param barsAmounts
|
|
18
|
-
* @param chartIndex
|
|
19
|
-
*/
|
|
20
|
-
static getBarIndex(barsAmounts: number[], chartIndex: number): number;
|
|
21
|
-
private static setBarAttrsByKey;
|
|
22
|
-
private static setGroupedBarAttrsByValue;
|
|
23
|
-
private static setSegmentedBarAttrsByValue;
|
|
24
|
-
}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { Scale } from "../../features/scale/scale";
|
|
2
|
-
import { Helper } from "../../helpers/helper";
|
|
3
|
-
export class BarHelper {
|
|
4
|
-
static getGroupedBarAttrs(keyAxisOrient, scales, margin, keyField, valueFieldName, blockSize, barIndex, barsAmount, barSettings) {
|
|
5
|
-
const attrs = {
|
|
6
|
-
x: null,
|
|
7
|
-
y: null,
|
|
8
|
-
width: null,
|
|
9
|
-
height: null
|
|
10
|
-
};
|
|
11
|
-
this.setBarAttrsByKey(attrs, keyAxisOrient, scales.key, margin, keyField, barIndex, barsAmount, barSettings, false);
|
|
12
|
-
this.setGroupedBarAttrsByValue(attrs, keyAxisOrient, margin, scales.value, valueFieldName, blockSize);
|
|
13
|
-
return attrs;
|
|
14
|
-
}
|
|
15
|
-
static getStackedBarAttr(keyAxisOrient, scales, margin, keyField, blockSize, barIndex, barsAmount, barSettings) {
|
|
16
|
-
const attrs = {
|
|
17
|
-
x: null,
|
|
18
|
-
y: null,
|
|
19
|
-
width: null,
|
|
20
|
-
height: null
|
|
21
|
-
};
|
|
22
|
-
this.setBarAttrsByKey(attrs, keyAxisOrient, scales.key, margin, keyField, barIndex, barsAmount, barSettings, true);
|
|
23
|
-
this.setSegmentedBarAttrsByValue(attrs, keyAxisOrient, scales.value, margin, blockSize);
|
|
24
|
-
return attrs;
|
|
25
|
-
}
|
|
26
|
-
static getBarsInGroupAmount(charts) {
|
|
27
|
-
let amounts = [];
|
|
28
|
-
charts.forEach((chart) => {
|
|
29
|
-
if (chart.type === 'bar' && chart.isSegmented)
|
|
30
|
-
amounts.push(1); // Сегментированный бар содержит все свои valueFields в одном баре
|
|
31
|
-
else if (chart.type === 'bar')
|
|
32
|
-
amounts.push(chart.data.valueFields.length);
|
|
33
|
-
});
|
|
34
|
-
return amounts;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Получение индекса бара среди всх графиков и value-филдов. Используется для того, чтобы узнать, какой по счету в группе
|
|
38
|
-
* этот бар идет (сегментированный всегда один, группированный - количество value-филдов).
|
|
39
|
-
* @param barsAmounts
|
|
40
|
-
* @param chartIndex
|
|
41
|
-
*/
|
|
42
|
-
static getBarIndex(barsAmounts, chartIndex) {
|
|
43
|
-
if (barsAmounts.length < 2)
|
|
44
|
-
return 0;
|
|
45
|
-
let index = 0;
|
|
46
|
-
barsAmounts.forEach((chartBars, i) => {
|
|
47
|
-
if (i < chartIndex) {
|
|
48
|
-
index += chartBars;
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
return index;
|
|
52
|
-
}
|
|
53
|
-
static setBarAttrsByKey(attrs, keyAxisOrient, scaleKey, margin, keyField, barIndex, barsAmount, barSettings, isSegmented) {
|
|
54
|
-
const barStep = (Scale.getScaleBandWidth(scaleKey) - barSettings.barDistance * (barsAmount - 1)) / barsAmount; // Space for one bar
|
|
55
|
-
const barSize = barStep > barSettings.maxBarWidth ? barSettings.maxBarWidth : barStep;
|
|
56
|
-
const barDiff = (barStep - barSize) * barsAmount / 2; // if bar bigger than maxWidth, diff for x coordinate
|
|
57
|
-
const barPad = barSize * barIndex + barSettings.barDistance * barIndex + barDiff; // Отступ бара от края. Зависит от количества баров в одной группе и порядке текущего бара
|
|
58
|
-
if (keyAxisOrient === 'top' || keyAxisOrient === 'bottom') {
|
|
59
|
-
attrs.x = d => scaleKey(Helper.getKeyFieldValue(d, keyField, isSegmented)) + margin.left + barPad;
|
|
60
|
-
attrs.width = d => barSize;
|
|
61
|
-
}
|
|
62
|
-
if (keyAxisOrient === 'left' || keyAxisOrient === 'right') {
|
|
63
|
-
attrs.y = d => scaleKey(Helper.getKeyFieldValue(d, keyField, isSegmented)) + margin.top + barPad;
|
|
64
|
-
attrs.height = d => barSize;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
static setGroupedBarAttrsByValue(attrs, keyAxisOrient, margin, scaleValue, valueFieldName, blockSize) {
|
|
68
|
-
if (keyAxisOrient === 'top') {
|
|
69
|
-
attrs.y = d => margin.top;
|
|
70
|
-
attrs.height = d => Helper.getValueOrZero(scaleValue(d[valueFieldName]));
|
|
71
|
-
}
|
|
72
|
-
if (keyAxisOrient === 'bottom') {
|
|
73
|
-
attrs.y = d => scaleValue(d[valueFieldName]) + margin.top;
|
|
74
|
-
attrs.height = d => Helper.getValueOrZero(blockSize.height - margin.top - margin.bottom - scaleValue(d[valueFieldName]));
|
|
75
|
-
}
|
|
76
|
-
if (keyAxisOrient === 'left') {
|
|
77
|
-
attrs.x = d => margin.left + 1;
|
|
78
|
-
attrs.width = d => Helper.getValueOrZero(scaleValue(d[valueFieldName]));
|
|
79
|
-
}
|
|
80
|
-
if (keyAxisOrient === 'right') {
|
|
81
|
-
attrs.x = d => scaleValue(d[valueFieldName]) + margin.left;
|
|
82
|
-
attrs.width = d => Helper.getValueOrZero(blockSize.width - margin.left - margin.right - scaleValue(d[valueFieldName]));
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
static setSegmentedBarAttrsByValue(attrs, keyAxisOrient, scaleValue, margin, blockSize) {
|
|
86
|
-
if (keyAxisOrient === 'top') {
|
|
87
|
-
attrs.y = d => margin.top + scaleValue(d[0]);
|
|
88
|
-
attrs.height = d => Helper.getValueOrZero(scaleValue(d[1] - d[0]));
|
|
89
|
-
}
|
|
90
|
-
if (keyAxisOrient === 'bottom') {
|
|
91
|
-
attrs.y = d => scaleValue(d[1]) + margin.top;
|
|
92
|
-
attrs.height = d => Helper.getValueOrZero(blockSize.height - margin.top - margin.bottom - scaleValue(d[1] - d[0]));
|
|
93
|
-
}
|
|
94
|
-
if (keyAxisOrient === 'left') {
|
|
95
|
-
attrs.x = d => margin.left + scaleValue(d[0]) + 1;
|
|
96
|
-
attrs.width = d => Helper.getValueOrZero(scaleValue(d[1] - d[0]));
|
|
97
|
-
}
|
|
98
|
-
if (keyAxisOrient === 'right') {
|
|
99
|
-
attrs.x = d => scaleValue(d[1]) + margin.left;
|
|
100
|
-
attrs.width = d => Helper.getValueOrZero(blockSize.width - margin.left - margin.right - scaleValue(d[1] - d[0]));
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { BlockMargin, Field, Orient, TwoDimensionalChartModel } from "../../../model/model";
|
|
2
|
-
import { Scales } from "../../features/scale/scale";
|
|
3
|
-
import { Block } from "../../block/block";
|
|
4
|
-
import { MdtChartsDataRow } from '../../../config/config';
|
|
5
|
-
export declare class Line {
|
|
6
|
-
static readonly lineChartClass = "line";
|
|
7
|
-
static render(block: Block, scales: Scales, data: MdtChartsDataRow[], keyField: Field, margin: BlockMargin, keyAxisOrient: Orient, chart: TwoDimensionalChartModel): void;
|
|
8
|
-
static update(block: Block, scales: Scales, newData: MdtChartsDataRow[], keyField: Field, margin: BlockMargin, keyAxisOrient: Orient, chart: TwoDimensionalChartModel): Promise<any>[];
|
|
9
|
-
static updateColors(block: Block, chart: TwoDimensionalChartModel): void;
|
|
10
|
-
private static renderGrouped;
|
|
11
|
-
private static renderSegmented;
|
|
12
|
-
private static updateGrouped;
|
|
13
|
-
private static updateSegmeneted;
|
|
14
|
-
private static updateGroupedPath;
|
|
15
|
-
private static updateSegmentedPath;
|
|
16
|
-
private static setSegmentColor;
|
|
17
|
-
}
|