mdt-charts 1.13.2 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -189
- package/lib/config/config.d.ts +28 -6
- package/lib/designer/designerConfig.d.ts +20 -2
- package/lib/engine/block/blockSvg.d.ts +3 -1
- package/lib/engine/block/blockSvg.js +8 -3
- package/lib/engine/block/defs.d.ts +7 -0
- package/lib/engine/block/defs.js +18 -0
- package/lib/engine/cardsNotation/card/cardService.js +2 -2
- package/lib/engine/elementHighlighter/elementHighlighter.js +2 -1
- package/lib/engine/features/axis/axis.js +6 -3
- package/lib/engine/features/axis/axisHelper.d.ts +2 -2
- package/lib/engine/features/axis/axisHelper.js +6 -11
- package/lib/engine/features/axis/axisLabelDomHelper.js +9 -11
- package/lib/engine/features/legend/legend.d.ts +17 -12
- package/lib/engine/features/legend/legend.js +38 -22
- package/lib/engine/features/legend/legendDomHelper.d.ts +8 -4
- package/lib/engine/features/legend/legendDomHelper.js +20 -8
- package/lib/engine/features/legend/legendEventsManager.d.ts +2 -2
- package/lib/engine/features/legend/legendEventsManager.js +5 -5
- package/lib/engine/features/legend/legendHelper.d.ts +6 -3
- package/lib/engine/features/legend/legendHelper.js +5 -7
- package/lib/engine/features/legend/legendMarkerCreator.d.ts +21 -0
- package/lib/engine/features/legend/legendMarkerCreator.js +88 -0
- package/lib/engine/features/legend/legendWidthCalculator.d.ts +16 -0
- package/lib/engine/features/legend/legendWidthCalculator.js +119 -0
- package/lib/engine/features/tolltip/tooltip.js +2 -5
- package/lib/engine/features/tolltip/tooltipDomHelper.d.ts +4 -4
- package/lib/engine/features/tolltip/tooltipDomHelper.js +13 -26
- package/lib/engine/helpers/domHelper.js +1 -1
- package/lib/engine/helpers/pipeline/Pipeline.d.ts +9 -0
- package/lib/engine/helpers/pipeline/Pipeline.js +37 -0
- package/lib/engine/intervalNotation/intervalManager.js +0 -2
- package/lib/engine/polarNotation/polarManager.js +3 -3
- package/lib/engine/twoDimensionalNotation/bar/bar.d.ts +16 -13
- package/lib/engine/twoDimensionalNotation/bar/bar.js +30 -18
- package/lib/engine/twoDimensionalNotation/bar/barHelper.d.ts +3 -0
- package/lib/engine/twoDimensionalNotation/bar/barHelper.js +9 -0
- package/lib/engine/twoDimensionalNotation/line/line.d.ts +22 -11
- package/lib/engine/twoDimensionalNotation/line/line.js +33 -17
- package/lib/engine/twoDimensionalNotation/line/lineGenerator.d.ts +15 -0
- package/lib/engine/twoDimensionalNotation/line/lineGenerator.js +27 -0
- package/lib/engine/twoDimensionalNotation/line/lineHelper.d.ts +18 -4
- package/lib/engine/twoDimensionalNotation/line/lineHelper.js +26 -16
- package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +13 -12
- package/lib/model/featuresModel/axisModel.d.ts +2 -1
- package/lib/model/featuresModel/axisModel.js +11 -1
- package/lib/model/featuresModel/legendModel/legendModel.d.ts +2 -1
- package/lib/model/featuresModel/legendModel/legendModel.js +5 -1
- package/lib/model/featuresModel/otherComponents.d.ts +2 -1
- package/lib/model/featuresModel/otherComponents.js +1 -1
- package/lib/model/featuresModel/scaleModel/scaleModel.d.ts +2 -1
- package/lib/model/featuresModel/scaleModel/scaleModel.js +4 -2
- package/lib/model/margin/marginModel.d.ts +6 -3
- package/lib/model/margin/marginModel.js +12 -8
- package/lib/model/margin/twoDim/twoDimMarginModel.d.ts +6 -3
- package/lib/model/margin/twoDim/twoDimMarginModel.js +30 -29
- package/lib/model/model.d.ts +56 -4
- package/lib/model/model.js +7 -1
- package/lib/model/modelBuilder.js +11 -6
- package/lib/model/modelInstance/configReader.d.ts +19 -0
- package/lib/model/modelInstance/configReader.js +35 -0
- package/lib/model/modelInstance/dataModel/dataModel.d.ts +2 -2
- package/lib/model/modelInstance/dataModel/dataModel.js +0 -1
- package/lib/model/modelInstance/dataModel/dataRepository.d.ts +6 -2
- package/lib/model/modelInstance/dataModel/dataRepository.js +15 -2
- package/lib/model/modelInstance/modelInstance.d.ts +2 -1
- package/lib/model/modelInstance/modelInstance.js +6 -4
- package/lib/model/notations/cards/cardsChangeService.js +2 -2
- package/lib/model/notations/cards/cardsModelService.js +1 -1
- package/lib/model/notations/intervalModel.js +4 -3
- package/lib/model/notations/polar/polarModel.js +6 -1
- package/lib/model/notations/twoDimensional/styles.d.ts +6 -0
- package/lib/model/notations/twoDimensional/styles.js +41 -0
- package/lib/model/notations/twoDimensionalModel.d.ts +5 -5
- package/lib/model/notations/twoDimensionalModel.js +13 -8
- package/lib/style/charts-main.css +3 -0
- package/lib/style/charts-main.less +3 -0
- package/package.json +5 -5
- package/lib/engine/contentManager.d.ts +0 -9
- package/lib/engine/contentManager.js +0 -29
- package/lib/model/modelInstance/canvasModel/marginModelService.d.ts +0 -11
- package/lib/model/modelInstance/canvasModel/marginModelService.js +0 -26
package/README.md
CHANGED
|
@@ -1,190 +1,2 @@
|
|
|
1
1
|
# Charts
|
|
2
|
-
**Demo**: https://vishulaknow.github.io/charts-demo/
|
|
3
|
-
## Установка
|
|
4
|
-
```
|
|
5
|
-
npm install mdt-charts
|
|
6
|
-
```
|
|
7
|
-
## Импорт
|
|
8
|
-
```js
|
|
9
|
-
import { Chart } from "mdt-charts"
|
|
10
|
-
```
|
|
11
|
-
## Импорт TypeScript интерфейсов
|
|
12
|
-
```ts
|
|
13
|
-
import { Config, DesignerConfig } from "mdt-charts"
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
## Использование
|
|
17
|
-
|
|
18
|
-
Для создания графика минимально требуется конфигуратор, конфигуратор дизайнера и данные.
|
|
19
|
-
|
|
20
|
-
```ts
|
|
21
|
-
const chart = new Chart(config, designerConfig, data);
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### Конфигуратор
|
|
25
|
-
|
|
26
|
-
Пример настроек для построения простого барчарта:
|
|
27
|
-
|
|
28
|
-
```json
|
|
29
|
-
{
|
|
30
|
-
"canvas": {
|
|
31
|
-
"class": "svg-chart outline",
|
|
32
|
-
"size": {
|
|
33
|
-
"width": 800,
|
|
34
|
-
"height": 400
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
"options": {
|
|
38
|
-
"title": "Количество автомобилей",
|
|
39
|
-
"type": "2d",
|
|
40
|
-
"isSegmented": false,
|
|
41
|
-
"axis": {
|
|
42
|
-
"key": {
|
|
43
|
-
"position": "end",
|
|
44
|
-
"ticks": {
|
|
45
|
-
"flag": false
|
|
46
|
-
},
|
|
47
|
-
"visibility": true
|
|
48
|
-
},
|
|
49
|
-
"value": {
|
|
50
|
-
"domain": {
|
|
51
|
-
"start": -1,
|
|
52
|
-
"end": -1
|
|
53
|
-
},
|
|
54
|
-
"position": "start",
|
|
55
|
-
"ticks": {
|
|
56
|
-
"flag": false
|
|
57
|
-
},
|
|
58
|
-
"visibility": true
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
"additionalElements": {
|
|
62
|
-
"gridLine": {
|
|
63
|
-
"flag": {
|
|
64
|
-
"value": true,
|
|
65
|
-
"key": true
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
"legend": {
|
|
70
|
-
"show": true
|
|
71
|
-
},
|
|
72
|
-
"orientation": "vertical",
|
|
73
|
-
"data": {
|
|
74
|
-
"dataSource": "dataSet",
|
|
75
|
-
"keyField": {
|
|
76
|
-
"name": "brand",
|
|
77
|
-
"format": "string"
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
"selectable": true,
|
|
81
|
-
"charts": [
|
|
82
|
-
{
|
|
83
|
-
"title": "Рост стоимости",
|
|
84
|
-
"type": "bar",
|
|
85
|
-
"data": {
|
|
86
|
-
"valueFields": [
|
|
87
|
-
{
|
|
88
|
-
"name": "price",
|
|
89
|
-
"format": "money",
|
|
90
|
-
"title": "Заголовок"
|
|
91
|
-
}
|
|
92
|
-
]
|
|
93
|
-
},
|
|
94
|
-
"tooltip": {
|
|
95
|
-
"show": true
|
|
96
|
-
},
|
|
97
|
-
"markers": {
|
|
98
|
-
"show": true
|
|
99
|
-
},
|
|
100
|
-
"embeddedLabels": "key"
|
|
101
|
-
}
|
|
102
|
-
]
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
### Конфигуратор дизайнера
|
|
108
|
-
|
|
109
|
-
Пример рекомендованных значений для конфигуратора дизайнера:
|
|
110
|
-
|
|
111
|
-
```ts
|
|
112
|
-
const designerConfig: DesignerConfig = {
|
|
113
|
-
canvas: {
|
|
114
|
-
axisLabel: {
|
|
115
|
-
maxSize: {
|
|
116
|
-
main: 60
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
chartBlockMargin: {
|
|
120
|
-
top: 30,
|
|
121
|
-
bottom: 20,
|
|
122
|
-
left: 20,
|
|
123
|
-
right: 20
|
|
124
|
-
},
|
|
125
|
-
legendBlock: {
|
|
126
|
-
maxWidth: 200
|
|
127
|
-
},
|
|
128
|
-
chartOptions: {
|
|
129
|
-
bar: {
|
|
130
|
-
minBarWidth: 3,
|
|
131
|
-
maxBarWidth: 30,
|
|
132
|
-
groupMinDistance: 16,
|
|
133
|
-
barDistance: 8,
|
|
134
|
-
groupMaxDistance: 35
|
|
135
|
-
},
|
|
136
|
-
donut: {
|
|
137
|
-
padAngle: 0,
|
|
138
|
-
minThickness: 40,
|
|
139
|
-
maxThickness: 60,
|
|
140
|
-
aggregatorPad: 30
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
chartStyle: {
|
|
145
|
-
baseColors: ['#209de3', '#ff3131', '#ffba00', '#20b078']
|
|
146
|
-
},
|
|
147
|
-
elementsOptions: {
|
|
148
|
-
tooltip: {
|
|
149
|
-
position: 'followCursor'
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
dataFormat: {
|
|
153
|
-
formatters: (value: any, options: { type?: string; title?: string; empty?: string; } = {}) => {
|
|
154
|
-
var type = typeof value;
|
|
155
|
-
if ((value === undefined || value === null || value === "") && type != "boolean" && options.type != "boolean")
|
|
156
|
-
return value;
|
|
157
|
-
if (type == "boolean" || options.type == "boolean") {
|
|
158
|
-
return value.toString();
|
|
159
|
-
}
|
|
160
|
-
if (value instanceof Date) {
|
|
161
|
-
return value.getFullYear() + '-' + (value.getMonth() + 1) + '-' + value.getDate() + ' ' + value.getHours() + ':' + value.getMinutes()
|
|
162
|
-
}
|
|
163
|
-
if (options.type === "markdown") {
|
|
164
|
-
return value.toString();
|
|
165
|
-
}
|
|
166
|
-
if ((options.type === "money" || options.type === "number")) {
|
|
167
|
-
return Intl.NumberFormat('ru-Ru', { minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(value);
|
|
168
|
-
}
|
|
169
|
-
return value;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
## Для разработчиков
|
|
176
|
-
|
|
177
|
-
Для загрузки всех зависимостей использйте скрипт:
|
|
178
|
-
|
|
179
|
-
```
|
|
180
|
-
npm install
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
Для сборки плейграунда необходимо запустить скрипт:
|
|
185
|
-
|
|
186
|
-
```
|
|
187
|
-
npm run dev
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
Полученные файлы будут расположены в папке dist.
|
|
2
|
+
**Demo**: https://vishulaknow.github.io/charts-demo/
|
package/lib/config/config.d.ts
CHANGED
|
@@ -123,11 +123,16 @@ interface AxisTicks {
|
|
|
123
123
|
}
|
|
124
124
|
export interface NumberAxisOptions extends AxisOptions {
|
|
125
125
|
domain: NumberDomain;
|
|
126
|
+
labels?: NumberAxisLabel;
|
|
126
127
|
}
|
|
127
128
|
export interface NumberDomain {
|
|
128
129
|
start: number;
|
|
129
130
|
end: number;
|
|
130
131
|
}
|
|
132
|
+
export interface NumberAxisLabel {
|
|
133
|
+
format: (v: number) => string;
|
|
134
|
+
}
|
|
135
|
+
export declare type AxisLabelFormatter = (v: number) => string;
|
|
131
136
|
export interface DiscreteAxisOptions extends AxisOptions {
|
|
132
137
|
labels?: MdtChartsDiscreteAxisLabel;
|
|
133
138
|
}
|
|
@@ -140,10 +145,7 @@ export interface IntervalAxis {
|
|
|
140
145
|
}
|
|
141
146
|
interface DateAxisOptions extends AxisOptions {
|
|
142
147
|
}
|
|
143
|
-
export
|
|
144
|
-
field: string;
|
|
145
|
-
dataType?: DataType;
|
|
146
|
-
}
|
|
148
|
+
export declare type MdtChartsCardValue = MdtChartsField;
|
|
147
149
|
export interface MdtChartsCardsChange {
|
|
148
150
|
value: MdtChartsCardValue;
|
|
149
151
|
color?: MdtChartsColorRangeItem[];
|
|
@@ -163,12 +165,32 @@ interface ChartSettings {
|
|
|
163
165
|
interface Tooltip {
|
|
164
166
|
show: boolean;
|
|
165
167
|
}
|
|
166
|
-
|
|
168
|
+
interface MdtChartsLineLikeChart {
|
|
169
|
+
markers: MarkersOptions;
|
|
170
|
+
lineStyles?: MdtChartsLineLikeChartStyles;
|
|
171
|
+
}
|
|
172
|
+
export interface MdtChartsLineLikeChartStyles {
|
|
173
|
+
dash?: MdtChartsLineLikeChartDashedStyles;
|
|
174
|
+
}
|
|
175
|
+
export interface MdtChartsLineLikeChartDashedStyles {
|
|
176
|
+
on: boolean;
|
|
177
|
+
dashSize?: number;
|
|
178
|
+
gapSize?: number;
|
|
179
|
+
}
|
|
180
|
+
interface MdtChartsBarLikeChart {
|
|
181
|
+
barStyles?: MdtChartsBarLikeChartStyles;
|
|
182
|
+
}
|
|
183
|
+
interface MdtChartsBarLikeChartStyles {
|
|
184
|
+
hatch?: MdtChartsBarLikeChartHatchedStyles;
|
|
185
|
+
}
|
|
186
|
+
interface MdtChartsBarLikeChartHatchedStyles {
|
|
187
|
+
on: boolean;
|
|
188
|
+
}
|
|
189
|
+
export interface MdtChartsTwoDimensionalChart extends ChartSettings, MdtChartsLineLikeChart, MdtChartsBarLikeChart {
|
|
167
190
|
type: TwoDimensionalChartType;
|
|
168
191
|
data: TwoDimensionalChartData;
|
|
169
192
|
embeddedLabels: EmbeddedLabelType;
|
|
170
193
|
isSegmented: boolean;
|
|
171
|
-
markers: MarkersOptions;
|
|
172
194
|
}
|
|
173
195
|
export interface PolarChart extends ChartSettings {
|
|
174
196
|
type: PolarChartType;
|
|
@@ -2,7 +2,11 @@ export declare type DataType = string;
|
|
|
2
2
|
export declare type DataTypeOptions = {
|
|
3
3
|
[option: string]: any;
|
|
4
4
|
};
|
|
5
|
-
export declare type Formatter = (value: any, options?:
|
|
5
|
+
export declare type Formatter = (value: any, options?: {
|
|
6
|
+
type?: string;
|
|
7
|
+
title?: string;
|
|
8
|
+
empty?: string;
|
|
9
|
+
}) => string;
|
|
6
10
|
export declare type TooltipPosition = 'followCursor' | 'fixed';
|
|
7
11
|
export interface DesignerConfig {
|
|
8
12
|
canvas: Canvas;
|
|
@@ -31,10 +35,15 @@ interface BlockMargin {
|
|
|
31
35
|
}
|
|
32
36
|
export interface LegendBlockCanvas {
|
|
33
37
|
maxWidth: number | string;
|
|
38
|
+
static?: StaticLegendBlockCanvas;
|
|
34
39
|
}
|
|
35
|
-
interface
|
|
40
|
+
export interface StaticLegendBlockCanvas {
|
|
41
|
+
maxLinesAmount: number;
|
|
42
|
+
}
|
|
43
|
+
export interface ChartOptionsCanvas {
|
|
36
44
|
bar: BarOptionsCanvas;
|
|
37
45
|
donut: DonutOptionsCanvas;
|
|
46
|
+
line?: LineOptionsCanvas;
|
|
38
47
|
}
|
|
39
48
|
export interface BarOptionsCanvas {
|
|
40
49
|
minBarWidth: number;
|
|
@@ -53,6 +62,15 @@ export interface MdtChartsDonutThicknessOptions {
|
|
|
53
62
|
max: number | string;
|
|
54
63
|
value?: number | string;
|
|
55
64
|
}
|
|
65
|
+
interface LineOptionsCanvas {
|
|
66
|
+
shape?: MdtChartsLineLikeChartShape;
|
|
67
|
+
}
|
|
68
|
+
export declare type MdtChartsLineLikeChartCurveType = "monotone" | "none";
|
|
69
|
+
export interface MdtChartsLineLikeChartShape {
|
|
70
|
+
curve?: {
|
|
71
|
+
type?: MdtChartsLineLikeChartCurveType;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
56
74
|
interface DataFormat {
|
|
57
75
|
formatters: Formatter;
|
|
58
76
|
}
|
|
@@ -9,6 +9,7 @@ export declare class BlockSvg {
|
|
|
9
9
|
private parentBlockId;
|
|
10
10
|
private parent;
|
|
11
11
|
private svgCssClasses;
|
|
12
|
+
private hatchPatternDef;
|
|
12
13
|
private readonly chartBlockClass;
|
|
13
14
|
private readonly chartGroupClass;
|
|
14
15
|
constructor(options: BlockSvgOptions);
|
|
@@ -21,6 +22,7 @@ export declare class BlockSvg {
|
|
|
21
22
|
getClipPathId(): string;
|
|
22
23
|
renderChartClipPath(margin: BlockMargin, blockSize: Size): void;
|
|
23
24
|
updateChartClipPath(margin: BlockMargin, blockSize: Size): void;
|
|
24
|
-
|
|
25
|
+
renderBarHatchPattern(): void;
|
|
26
|
+
private ensureDefsRendered;
|
|
25
27
|
}
|
|
26
28
|
export {};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { NamesHelper } from "../helpers/namesHelper";
|
|
2
2
|
import { BlockHelper } from "./blockHelper";
|
|
3
|
+
import { HatchPatternDef } from "./defs";
|
|
3
4
|
export class BlockSvg {
|
|
4
5
|
constructor(options) {
|
|
6
|
+
this.hatchPatternDef = new HatchPatternDef();
|
|
5
7
|
this.chartBlockClass = 'chart-block';
|
|
6
8
|
this.chartGroupClass = 'chart-group';
|
|
7
9
|
this.svgCssClasses = options.svgCssClasses;
|
|
@@ -41,7 +43,7 @@ export class BlockSvg {
|
|
|
41
43
|
}
|
|
42
44
|
renderChartClipPath(margin, blockSize) {
|
|
43
45
|
const attributes = BlockHelper.getClipPathAttributes(blockSize, margin);
|
|
44
|
-
this.
|
|
46
|
+
this.ensureDefsRendered()
|
|
45
47
|
.append('clipPath')
|
|
46
48
|
.attr('id', this.getClipPathId())
|
|
47
49
|
.append('rect')
|
|
@@ -52,7 +54,7 @@ export class BlockSvg {
|
|
|
52
54
|
}
|
|
53
55
|
updateChartClipPath(margin, blockSize) {
|
|
54
56
|
const attributes = BlockHelper.getClipPathAttributes(blockSize, margin);
|
|
55
|
-
this.
|
|
57
|
+
this.ensureDefsRendered()
|
|
56
58
|
.select('clipPath')
|
|
57
59
|
.select('rect')
|
|
58
60
|
.attr('x', attributes.x)
|
|
@@ -60,7 +62,10 @@ export class BlockSvg {
|
|
|
60
62
|
.attr('width', attributes.width)
|
|
61
63
|
.attr('height', attributes.height);
|
|
62
64
|
}
|
|
63
|
-
|
|
65
|
+
renderBarHatchPattern() {
|
|
66
|
+
this.hatchPatternDef.appendToDefsBlock(this.ensureDefsRendered());
|
|
67
|
+
}
|
|
68
|
+
ensureDefsRendered() {
|
|
64
69
|
let defs = this.getBlock().select('defs');
|
|
65
70
|
if (defs.empty())
|
|
66
71
|
defs = this.getBlock().append('defs');
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Selection } from "d3-selection";
|
|
2
|
+
export declare class HatchPatternDef {
|
|
3
|
+
static getMaskValue(): string;
|
|
4
|
+
private static readonly hatchMaskUrl;
|
|
5
|
+
private readonly hatchPattern;
|
|
6
|
+
appendToDefsBlock(defsSelection: Selection<SVGDefsElement, unknown, HTMLElement, unknown>): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export class HatchPatternDef {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.hatchPattern = `
|
|
4
|
+
<pattern id="hatch-pattern" width="4" height="4" patternUnits="userSpaceOnUse"patternTransform="rotate(45)">
|
|
5
|
+
<rect width="2" height="4" transform="translate(0,0)" fill="white"></rect>
|
|
6
|
+
</pattern>
|
|
7
|
+
<mask id="${HatchPatternDef.hatchMaskUrl}">
|
|
8
|
+
<rect x="0" y="0" width="100%" height="100%" fill="url(#hatch-pattern)" />
|
|
9
|
+
</mask>`;
|
|
10
|
+
}
|
|
11
|
+
static getMaskValue() {
|
|
12
|
+
return `url(#${this.hatchMaskUrl})`;
|
|
13
|
+
}
|
|
14
|
+
appendToDefsBlock(defsSelection) {
|
|
15
|
+
defsSelection.append("g").html(this.hatchPattern);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
HatchPatternDef.hatchMaskUrl = "hatch-mask";
|
|
@@ -5,8 +5,8 @@ export class CardServiceClass {
|
|
|
5
5
|
return this.getValueContentFromRow(valueOptions, dataRow);
|
|
6
6
|
}
|
|
7
7
|
getValueContentFromRow(valueOptions, dataRow) {
|
|
8
|
-
const value = dataRow[valueOptions.
|
|
9
|
-
return ValueFormatter.formatField(valueOptions.
|
|
8
|
+
const value = dataRow[valueOptions.name];
|
|
9
|
+
return ValueFormatter.formatField(valueOptions.format, value);
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
export const CardService = new CardServiceClass();
|
|
@@ -7,6 +7,7 @@ import { Donut } from '../polarNotation/donut/donut';
|
|
|
7
7
|
import { MarkDot } from '../features/markDots/markDot';
|
|
8
8
|
import { Helper } from '../helpers/helper';
|
|
9
9
|
import * as chroma from 'chroma-js';
|
|
10
|
+
import { NamesHelper } from '../helpers/namesHelper';
|
|
10
11
|
export class ElementHighlighter {
|
|
11
12
|
static toggleActivityStyle(elementSelection, isActive) {
|
|
12
13
|
elementSelection.classed(this.inactiveElemClass, !isActive);
|
|
@@ -195,4 +196,4 @@ export class ElementHighlighter {
|
|
|
195
196
|
});
|
|
196
197
|
}
|
|
197
198
|
}
|
|
198
|
-
ElementHighlighter.inactiveElemClass =
|
|
199
|
+
ElementHighlighter.inactiveElemClass = NamesHelper.getClassName("opacity-inactive");
|
|
@@ -29,7 +29,7 @@ export class Axis {
|
|
|
29
29
|
.select(`g.${axisCssClass}`);
|
|
30
30
|
}
|
|
31
31
|
static renderAxis(block, scale, scaleOptions, axisOptions, blockSize) {
|
|
32
|
-
const axisGenerator = AxisHelper.getBaseAxisGenerator(axisOptions, scale
|
|
32
|
+
const axisGenerator = AxisHelper.getBaseAxisGenerator(axisOptions, scale);
|
|
33
33
|
if (axisOptions.type === 'value' && (scaleOptions.type === 'linear' || scaleOptions.type === 'datetime'))
|
|
34
34
|
AxisHelper.setLabelsSettings(axisGenerator, scale.range(), scaleOptions);
|
|
35
35
|
const axisElement = block.getSvg()
|
|
@@ -50,11 +50,14 @@ export class Axis {
|
|
|
50
50
|
AxisLabelHelper.alignLabelsInKeyAxis(axisOptions, axisElement);
|
|
51
51
|
AxisLabelsEventManager.setHoverEvents(block, axisElement);
|
|
52
52
|
}
|
|
53
|
+
if (axisOptions.type === "value") {
|
|
54
|
+
AxisLabelHelper.cropLabels(block, scale, scaleOptions, axisOptions, blockSize);
|
|
55
|
+
}
|
|
53
56
|
if (axisOptions.labels.defaultTooltip)
|
|
54
57
|
AxisLabelHelper.setTitles(axisElement);
|
|
55
58
|
}
|
|
56
59
|
static updateValueAxis(block, scaleValue, scaleOptions, axisOptions) {
|
|
57
|
-
const axisGenerator = AxisHelper.getBaseAxisGenerator(axisOptions, scaleValue
|
|
60
|
+
const axisGenerator = AxisHelper.getBaseAxisGenerator(axisOptions, scaleValue);
|
|
58
61
|
AxisHelper.setLabelsSettings(axisGenerator, scaleValue.range(), scaleOptions);
|
|
59
62
|
const axisElement = block.getSvg().select(`g.${axisOptions.cssClass}`);
|
|
60
63
|
AxisDomHelper.updateAxisElement(axisGenerator, axisElement, axisOptions.translate, block.transitionManager.durations.chartUpdate)
|
|
@@ -64,7 +67,7 @@ export class Axis {
|
|
|
64
67
|
});
|
|
65
68
|
}
|
|
66
69
|
static updateKeyAxis(block, scaleKey, scaleOptions, axisOptions, blockSize, domainNotUpdated) {
|
|
67
|
-
const axisGenerator = AxisHelper.getBaseAxisGenerator(axisOptions, scaleKey
|
|
70
|
+
const axisGenerator = AxisHelper.getBaseAxisGenerator(axisOptions, scaleKey);
|
|
68
71
|
if (axisOptions.labels.position === 'rotated') { // Задание координат для перевернутых лейблов (если до этого они не были перевернуты)
|
|
69
72
|
if (axisOptions.orient === 'bottom')
|
|
70
73
|
axisGenerator.tickPadding(-4);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AxisScale, Axis as IAxis } from 'd3-axis';
|
|
2
|
-
import { AxisModelOptions, Orient,
|
|
2
|
+
import { AxisModelOptions, Orient, ScaleValueModel } from "../../../model/model";
|
|
3
3
|
export declare class AxisHelper {
|
|
4
4
|
static getAxisByOrient(orient: Orient, scale: AxisScale<any>): IAxis<any>;
|
|
5
5
|
static setLabelsSettings(axisGenerator: IAxis<any>, range: number[], scaleOptions: ScaleValueModel): void;
|
|
6
|
-
static getBaseAxisGenerator(axisOptions: AxisModelOptions, scale: AxisScale<any
|
|
6
|
+
static getBaseAxisGenerator(axisOptions: AxisModelOptions, scale: AxisScale<any>): IAxis<any>;
|
|
7
7
|
private static removeTicks;
|
|
8
8
|
private static setNumTickFormat;
|
|
9
9
|
}
|
|
@@ -2,7 +2,7 @@ import { axisTop, axisBottom, axisLeft, axisRight } from 'd3-axis';
|
|
|
2
2
|
import { max, min } from 'd3-array';
|
|
3
3
|
import { format } from 'd3-format';
|
|
4
4
|
import { AxisLabelHelper } from './axisLabelDomHelper';
|
|
5
|
-
const MINIMAL_STEP_SIZE =
|
|
5
|
+
const MINIMAL_STEP_SIZE = 60;
|
|
6
6
|
export class AxisHelper {
|
|
7
7
|
static getAxisByOrient(orient, scale) {
|
|
8
8
|
if (orient === 'top')
|
|
@@ -28,26 +28,21 @@ export class AxisHelper {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
if (scaleOptions.type === 'linear') {
|
|
31
|
-
|
|
32
|
-
if (format('~s')(value).indexOf('.') !== -1) {
|
|
33
|
-
this.setNumTickFormat(axisGenerator, '.2s');
|
|
34
|
-
}
|
|
35
|
-
});
|
|
31
|
+
this.setNumTickFormat(axisGenerator, scaleOptions.formatter);
|
|
36
32
|
}
|
|
37
33
|
}
|
|
38
|
-
static getBaseAxisGenerator(axisOptions, scale
|
|
34
|
+
static getBaseAxisGenerator(axisOptions, scale) {
|
|
39
35
|
const axisGenerator = AxisHelper.getAxisByOrient(axisOptions.orient, scale);
|
|
40
36
|
if (!axisOptions.ticks.flag)
|
|
41
37
|
this.removeTicks(axisGenerator);
|
|
42
38
|
AxisLabelHelper.setAxisLabelPaddingByOrient(axisGenerator, axisOptions);
|
|
43
|
-
if (scaleOptions.type === 'linear')
|
|
44
|
-
this.setNumTickFormat(axisGenerator);
|
|
45
39
|
return axisGenerator;
|
|
46
40
|
}
|
|
47
41
|
static removeTicks(axis) {
|
|
48
42
|
axis.tickSize(0);
|
|
49
43
|
}
|
|
50
|
-
static setNumTickFormat(axis,
|
|
51
|
-
|
|
44
|
+
static setNumTickFormat(axis, formatter) {
|
|
45
|
+
const defaultFormatter = format('~s');
|
|
46
|
+
axis.tickFormat(formatter !== null && formatter !== void 0 ? formatter : defaultFormatter);
|
|
52
47
|
}
|
|
53
48
|
}
|
|
@@ -38,17 +38,15 @@ export class AxisLabelHelper {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
static cropLabels(block, scale, scaleOptions, axisOptions, blockSize) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
this.cropAndAlignExtremeLabels(block, maxLabelSize, axisOptions, blockSize);
|
|
51
|
-
}
|
|
41
|
+
const axisTextBlocks = block.getSvg().select(`.${axisOptions.cssClass}`).selectAll('text');
|
|
42
|
+
let maxLabelSize;
|
|
43
|
+
if ((axisOptions.orient === 'left' || axisOptions.orient === 'right') || (axisOptions.type === 'key' && axisOptions.labels.position === 'rotated'))
|
|
44
|
+
maxLabelSize = axisOptions.labels.maxSize;
|
|
45
|
+
else
|
|
46
|
+
maxLabelSize = scale.step() - 4;
|
|
47
|
+
DomHelper.cropSvgLabels(axisTextBlocks, maxLabelSize);
|
|
48
|
+
if (scaleOptions.type === 'point' && axisOptions.labels.position === 'straight' && (axisOptions.orient === 'top' || axisOptions.orient === 'bottom')) {
|
|
49
|
+
this.cropAndAlignExtremeLabels(block, maxLabelSize, axisOptions, blockSize);
|
|
52
50
|
}
|
|
53
51
|
}
|
|
54
52
|
static hideLabels(axisElement) {
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { BaseType, Selection } from "d3-selection";
|
|
2
2
|
import { MdtChartsDataSource } from "../../../config/config";
|
|
3
|
-
import { IntervalOptionsModel, Model, PolarOptionsModel, TwoDimensionalOptionsModel } from "../../../model/model";
|
|
3
|
+
import { IntervalOptionsModel, LegendBlockModel, Model, PolarOptionsModel, TwoDimensionalOptionsModel } from "../../../model/model";
|
|
4
4
|
import { Block } from "../../block/block";
|
|
5
5
|
import { SelectionCondition } from "../../helpers/domHelper";
|
|
6
|
+
import { ChartLegendEngineModel } from "./legendHelper";
|
|
6
7
|
export interface LegendContentRenderingOptions {
|
|
7
8
|
wrapperClasses: string[];
|
|
8
9
|
shouldCropLabels: boolean;
|
|
10
|
+
blockModel: LegendBlockModel;
|
|
9
11
|
itemsOptions: {
|
|
10
12
|
wrapperClasses: string[];
|
|
11
13
|
markerClass: string;
|
|
@@ -13,19 +15,22 @@ export interface LegendContentRenderingOptions {
|
|
|
13
15
|
};
|
|
14
16
|
}
|
|
15
17
|
export declare class Legend {
|
|
18
|
+
static get(): Legend;
|
|
16
19
|
static readonly objectClass = "legend-object";
|
|
17
20
|
static readonly labelClass = "legend-label";
|
|
18
21
|
static readonly itemClass = "legend-item";
|
|
19
|
-
static readonly markerClass = "legend-
|
|
22
|
+
static readonly markerClass = "legend-marker";
|
|
23
|
+
static readonly markerCircle = "legend-circle";
|
|
20
24
|
static readonly legendBlockClass = "legend-block";
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
private
|
|
27
|
-
private
|
|
28
|
-
private
|
|
29
|
-
private
|
|
30
|
-
private
|
|
25
|
+
private readonly markerCreator;
|
|
26
|
+
render(block: Block, data: MdtChartsDataSource, options: TwoDimensionalOptionsModel | PolarOptionsModel, model: Model): void;
|
|
27
|
+
update(block: Block, data: MdtChartsDataSource, model: Model<TwoDimensionalOptionsModel | PolarOptionsModel>): void;
|
|
28
|
+
updateColors(block: Block, options: TwoDimensionalOptionsModel | PolarOptionsModel | IntervalOptionsModel): void;
|
|
29
|
+
static getItemsByKeys(block: Block, keys: string[], condition?: SelectionCondition): Selection<HTMLDivElement, ChartLegendEngineModel, BaseType, unknown>;
|
|
30
|
+
private setContent;
|
|
31
|
+
private renderObject;
|
|
32
|
+
private renderContent;
|
|
33
|
+
private getObject;
|
|
34
|
+
private removeContent;
|
|
35
|
+
private fillCoordinate;
|
|
31
36
|
}
|