mdt-charts 1.12.2 → 1.12.3
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 +19 -12
- package/lib/designer/designerConfig.d.ts +3 -5
- package/lib/engine/features/aggregator/aggregator.d.ts +8 -6
- package/lib/engine/features/aggregator/aggregator.js +45 -32
- package/lib/engine/polarNotation/donut/donut.js +1 -1
- package/lib/engine/polarNotation/polarManager.js +1 -1
- package/lib/model/chartStyleModel/TwoDimensionalChartStyleModel.d.ts +4 -4
- package/lib/model/dataManagerModel/dataManagerModel.js +1 -1
- package/lib/model/featuresModel/legendModel/legendModel.js +1 -1
- package/lib/model/featuresModel/legendModel/polarMarginCalculator.js +1 -1
- package/lib/model/featuresModel/scaleModel.d.ts +6 -6
- package/lib/model/featuresModel/titleModel.js +3 -3
- package/lib/model/marginModel.js +1 -1
- package/lib/model/model.d.ts +18 -6
- package/lib/model/modelBuilder.js +1 -1
- package/lib/model/notations/intervalModel.d.ts +2 -2
- package/lib/model/notations/polar/donut/donutAggregatorService.d.ts +12 -0
- package/lib/model/notations/polar/donut/donutAggregatorService.js +25 -0
- package/lib/model/notations/polar/donut/donutModel.d.ts +10 -0
- package/lib/model/notations/polar/donut/donutModel.js +32 -0
- package/lib/model/notations/polar/donut/donutThicknessService.d.ts +9 -0
- package/lib/model/notations/polar/donut/donutThicknessService.js +30 -0
- package/lib/model/notations/polar/polarModel.d.ts +16 -0
- package/lib/model/notations/polar/polarModel.js +55 -0
- package/lib/model/notations/twoDimensionalModel.d.ts +4 -4
- package/lib/style/charts-main.css +5 -2
- package/lib/style/charts-main.less +5 -2
- package/package.json +1 -1
package/lib/config/config.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export interface MdtChartsDataSource {
|
|
|
17
17
|
export declare type AxisLabelPosition = "straight" | "rotated";
|
|
18
18
|
export interface MdtChartsConfig {
|
|
19
19
|
canvas: ChartBlockCanvas;
|
|
20
|
-
options: MdtChartsPolarOptions | MdtChartsTwoDimensionalOptions |
|
|
20
|
+
options: MdtChartsPolarOptions | MdtChartsTwoDimensionalOptions | MdtChartsIntervalOptions;
|
|
21
21
|
}
|
|
22
22
|
export interface ChartBlockCanvas {
|
|
23
23
|
size: Size;
|
|
@@ -42,14 +42,14 @@ export interface MdtChartsTwoDimensionalOptions extends Options {
|
|
|
42
42
|
type: '2d';
|
|
43
43
|
axis: TwoDimensionalAxis;
|
|
44
44
|
additionalElements: AdditionalElements;
|
|
45
|
-
charts:
|
|
45
|
+
charts: MdtChartsTwoDimensionalChart[];
|
|
46
46
|
orientation: ChartOrientation;
|
|
47
47
|
}
|
|
48
48
|
export interface MdtChartsPolarOptions extends Options {
|
|
49
49
|
type: 'polar';
|
|
50
50
|
chart: PolarChart;
|
|
51
51
|
}
|
|
52
|
-
export interface
|
|
52
|
+
export interface MdtChartsIntervalOptions extends Options {
|
|
53
53
|
type: 'interval';
|
|
54
54
|
axis: IntervalAxis;
|
|
55
55
|
chart: IntervalChart;
|
|
@@ -68,10 +68,10 @@ export interface MdtChartsField {
|
|
|
68
68
|
name: string;
|
|
69
69
|
format: DataType;
|
|
70
70
|
}
|
|
71
|
-
export interface
|
|
71
|
+
export interface MdtChartsValueField extends MdtChartsField {
|
|
72
72
|
title: string;
|
|
73
73
|
}
|
|
74
|
-
export interface TwoDimValueField extends
|
|
74
|
+
export interface TwoDimValueField extends MdtChartsValueField {
|
|
75
75
|
color?: string;
|
|
76
76
|
}
|
|
77
77
|
export interface TooltipOptions {
|
|
@@ -124,7 +124,7 @@ interface ChartSettings {
|
|
|
124
124
|
interface Tooltip {
|
|
125
125
|
show: boolean;
|
|
126
126
|
}
|
|
127
|
-
export interface
|
|
127
|
+
export interface MdtChartsTwoDimensionalChart extends ChartSettings {
|
|
128
128
|
type: TwoDimensionalChartType;
|
|
129
129
|
data: TwoDimensionalChartData;
|
|
130
130
|
embeddedLabels: EmbeddedLabelType;
|
|
@@ -134,7 +134,7 @@ export interface TwoDimensionalChart extends ChartSettings {
|
|
|
134
134
|
export interface PolarChart extends ChartSettings {
|
|
135
135
|
type: PolarChartType;
|
|
136
136
|
data: PolarChartData;
|
|
137
|
-
aggregator
|
|
137
|
+
aggregator?: MdtChartsDonutAggregator;
|
|
138
138
|
}
|
|
139
139
|
export interface IntervalChart extends ChartSettings {
|
|
140
140
|
type: IntervalChartType;
|
|
@@ -148,14 +148,21 @@ interface MarkersOptions {
|
|
|
148
148
|
}
|
|
149
149
|
export declare type MdtChartsColorField = string;
|
|
150
150
|
export interface PolarChartData {
|
|
151
|
-
valueField:
|
|
151
|
+
valueField: MdtChartsValueField;
|
|
152
152
|
colorField?: MdtChartsColorField;
|
|
153
153
|
}
|
|
154
|
-
export interface
|
|
155
|
-
|
|
154
|
+
export interface MdtChartsDonutAggregator {
|
|
155
|
+
content?: (model: MdtChartsAggregatorModel) => MdtChartsAggregatorContent;
|
|
156
|
+
}
|
|
157
|
+
export interface MdtChartsAggregatorModel {
|
|
158
|
+
data: MdtChartsDataRow[];
|
|
159
|
+
}
|
|
160
|
+
export interface MdtChartsAggregatorContent {
|
|
161
|
+
value: string | number;
|
|
162
|
+
title: string;
|
|
156
163
|
}
|
|
157
164
|
interface IntervalChartData {
|
|
158
|
-
valueField1:
|
|
159
|
-
valueField2:
|
|
165
|
+
valueField1: MdtChartsValueField;
|
|
166
|
+
valueField2: MdtChartsValueField;
|
|
160
167
|
}
|
|
161
168
|
export {};
|
|
@@ -4,7 +4,6 @@ export declare type DataTypeOptions = {
|
|
|
4
4
|
};
|
|
5
5
|
export declare type Formatter = (value: any, options?: any) => string;
|
|
6
6
|
export declare type TooltipPosition = 'followCursor' | 'fixed';
|
|
7
|
-
export declare type MdtChartsDonutThicknessUnit = "px" | "%";
|
|
8
7
|
export interface DesignerConfig {
|
|
9
8
|
canvas: Canvas;
|
|
10
9
|
dataFormat: DataFormat;
|
|
@@ -50,10 +49,9 @@ export interface DonutOptionsCanvas {
|
|
|
50
49
|
thickness: MdtChartsDonutThicknessOptions;
|
|
51
50
|
}
|
|
52
51
|
export interface MdtChartsDonutThicknessOptions {
|
|
53
|
-
min: number;
|
|
54
|
-
max: number;
|
|
55
|
-
value
|
|
56
|
-
unit: MdtChartsDonutThicknessUnit;
|
|
52
|
+
min: number | string;
|
|
53
|
+
max: number | string;
|
|
54
|
+
value?: number | string;
|
|
57
55
|
}
|
|
58
56
|
interface DataFormat {
|
|
59
57
|
formatters: Formatter;
|
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
import { MdtChartsDataRow } from '../../../config/config';
|
|
2
1
|
import { DataType } from '../../../designer/designerConfig';
|
|
3
|
-
import {
|
|
2
|
+
import { DonutAggregatorModel, Field } from "../../../model/model";
|
|
4
3
|
import { Block } from "../../block/block";
|
|
5
4
|
import { Translate } from "../../polarNotation/donut/donut";
|
|
6
5
|
export interface AggregatorInfo {
|
|
7
6
|
name: string;
|
|
8
|
-
value: number;
|
|
7
|
+
value: number | string;
|
|
9
8
|
format: DataType;
|
|
10
9
|
margin: number;
|
|
11
10
|
}
|
|
12
11
|
export declare class Aggregator {
|
|
13
12
|
static readonly aggregatorValueClass = "aggregator-value";
|
|
14
|
-
private static readonly
|
|
13
|
+
private static readonly aggregatorTitleClass;
|
|
15
14
|
private static readonly aggregatorObjectClass;
|
|
16
|
-
static render(block: Block,
|
|
17
|
-
static update(block: Block,
|
|
15
|
+
static render(block: Block, valueField: Field, innerRadius: number, translate: Translate, fontSize: number, settings: DonutAggregatorModel): void;
|
|
16
|
+
static update(block: Block, valueField: Field, settings: DonutAggregatorModel): void;
|
|
17
|
+
private static buildConfig;
|
|
18
18
|
private static renderText;
|
|
19
|
+
private static formatValue;
|
|
19
20
|
private static updateText;
|
|
20
21
|
private static reCalculateAggregatorFontSize;
|
|
22
|
+
private static setTitleFontSize;
|
|
21
23
|
private static renderAggregatorObject;
|
|
22
24
|
private static renderWrapper;
|
|
23
25
|
}
|
|
@@ -1,28 +1,25 @@
|
|
|
1
|
-
import { sum } from 'd3-array';
|
|
2
1
|
import { interpolateNumber } from 'd3-interpolate';
|
|
3
2
|
import { Helper } from '../../helpers/helper';
|
|
4
3
|
import { ValueFormatter } from '../../valueFormatter';
|
|
5
4
|
export class Aggregator {
|
|
6
|
-
static render(block,
|
|
7
|
-
const aggregator =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
this.renderText(block, innerRadius, aggregator, translate, fontSize);
|
|
5
|
+
static render(block, valueField, innerRadius, translate, fontSize, settings) {
|
|
6
|
+
const aggregator = this.buildConfig(valueField, settings);
|
|
7
|
+
this.renderText(block, innerRadius, aggregator, fontSize, translate);
|
|
8
|
+
}
|
|
9
|
+
static update(block, valueField, settings) {
|
|
10
|
+
const aggregator = this.buildConfig(valueField, settings);
|
|
11
|
+
this.updateText(block, aggregator, typeof aggregator.value === "string");
|
|
14
12
|
}
|
|
15
|
-
static
|
|
16
|
-
|
|
17
|
-
name:
|
|
18
|
-
value:
|
|
13
|
+
static buildConfig(valueField, settings) {
|
|
14
|
+
return {
|
|
15
|
+
name: settings.content.title,
|
|
16
|
+
value: settings.content.value,
|
|
19
17
|
format: valueField.format,
|
|
20
18
|
margin: settings.margin
|
|
21
19
|
};
|
|
22
|
-
this.updateText(block, aggregator);
|
|
23
20
|
}
|
|
24
|
-
static renderText(block, innerRadius, aggregatorInfo,
|
|
25
|
-
if (innerRadius >
|
|
21
|
+
static renderText(block, innerRadius, aggregatorInfo, fontSize, translate) {
|
|
22
|
+
if (innerRadius > 40) {
|
|
26
23
|
const aggregatorObject = this.renderAggregatorObject(block, innerRadius, translate);
|
|
27
24
|
const wrapper = this.renderWrapper(aggregatorObject);
|
|
28
25
|
wrapper
|
|
@@ -30,46 +27,62 @@ export class Aggregator {
|
|
|
30
27
|
.attr('class', this.aggregatorValueClass)
|
|
31
28
|
.style('text-align', 'center')
|
|
32
29
|
.style('font-size', `${fontSize}px`)
|
|
33
|
-
.text(
|
|
30
|
+
.text(this.formatValue(aggregatorInfo.format, aggregatorInfo.value));
|
|
34
31
|
wrapper
|
|
35
32
|
.append('div')
|
|
36
|
-
.attr('class', this.
|
|
33
|
+
.attr('class', this.aggregatorTitleClass)
|
|
37
34
|
.attr('title', aggregatorInfo.name)
|
|
38
35
|
.style('text-align', 'center')
|
|
39
|
-
.style('font-size', '18px')
|
|
40
36
|
.text(aggregatorInfo.name);
|
|
41
37
|
this.reCalculateAggregatorFontSize(aggregatorObject.node().getBoundingClientRect().width, block, aggregatorInfo.margin);
|
|
42
38
|
}
|
|
43
39
|
}
|
|
44
|
-
static
|
|
40
|
+
static formatValue(format, value) {
|
|
41
|
+
if (typeof value === "string")
|
|
42
|
+
return value;
|
|
43
|
+
return ValueFormatter.formatField(format, value);
|
|
44
|
+
}
|
|
45
|
+
static updateText(block, newAggregator, withoutAnimation) {
|
|
45
46
|
const aggregatorObject = block.getSvg()
|
|
46
47
|
.select(`.${this.aggregatorObjectClass}`);
|
|
47
48
|
const thisClass = this;
|
|
48
|
-
block.getSvg()
|
|
49
|
-
.select(`.${this.aggregatorValueClass}`)
|
|
49
|
+
const valueBlock = block.getSvg()
|
|
50
|
+
.select(`.${this.aggregatorValueClass}`);
|
|
51
|
+
if (withoutAnimation) {
|
|
52
|
+
valueBlock.text(this.formatValue(newAggregator.format, newAggregator.value));
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
valueBlock
|
|
50
56
|
.interrupt()
|
|
51
57
|
.transition()
|
|
52
58
|
.duration(block.transitionManager.durations.chartUpdate)
|
|
53
59
|
.tween("text", function () {
|
|
60
|
+
const newValue = typeof newAggregator.value === "string" ? parseFloat(newAggregator.value) : newAggregator.value;
|
|
54
61
|
const oldValue = Helper.parseFormattedToNumber(this.textContent, ',');
|
|
55
|
-
const precision = Helper.calcDigitsAfterDot(
|
|
56
|
-
const interpolateFunc = interpolateNumber(oldValue,
|
|
62
|
+
const precision = Helper.calcDigitsAfterDot(newValue);
|
|
63
|
+
const interpolateFunc = interpolateNumber(oldValue, newValue);
|
|
57
64
|
return t => {
|
|
58
|
-
this.textContent =
|
|
65
|
+
this.textContent = thisClass.formatValue(newAggregator.format, parseFloat((interpolateFunc(t)).toFixed(precision)));
|
|
59
66
|
thisClass.reCalculateAggregatorFontSize(aggregatorObject.node().getBoundingClientRect().width, block, newAggregator.margin);
|
|
60
67
|
};
|
|
61
68
|
});
|
|
62
69
|
}
|
|
63
70
|
static reCalculateAggregatorFontSize(wrapperSize, block, pad) {
|
|
64
|
-
const
|
|
71
|
+
const aggregatorValue = block.getSvg()
|
|
65
72
|
.select(`.${this.aggregatorValueClass}`);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
73
|
+
const aggregatorTitle = block.getSvg()
|
|
74
|
+
.select(`.${this.aggregatorTitleClass}`);
|
|
75
|
+
let fontSize = parseInt(aggregatorValue.style('font-size'));
|
|
76
|
+
while (aggregatorValue.node().getBoundingClientRect().width > wrapperSize - pad * 2 && fontSize > 12) {
|
|
77
|
+
aggregatorValue.style('font-size', `${fontSize -= 2}px`);
|
|
69
78
|
}
|
|
70
|
-
while (
|
|
71
|
-
|
|
79
|
+
while (aggregatorValue.node().getBoundingClientRect().width < wrapperSize - pad * 2 && fontSize < 60) {
|
|
80
|
+
aggregatorValue.style('font-size', `${fontSize += 2}px`);
|
|
72
81
|
}
|
|
82
|
+
this.setTitleFontSize(aggregatorTitle, fontSize);
|
|
83
|
+
}
|
|
84
|
+
static setTitleFontSize(aggregatorTitle, valueFontSize) {
|
|
85
|
+
aggregatorTitle.style('font-size', `${Math.round(valueFontSize * 0.5)}px`);
|
|
73
86
|
}
|
|
74
87
|
static renderAggregatorObject(block, innerRadius, translate) {
|
|
75
88
|
return block.getSvg()
|
|
@@ -94,5 +107,5 @@ export class Aggregator {
|
|
|
94
107
|
}
|
|
95
108
|
}
|
|
96
109
|
Aggregator.aggregatorValueClass = 'aggregator-value';
|
|
97
|
-
Aggregator.
|
|
110
|
+
Aggregator.aggregatorTitleClass = 'aggregator-name';
|
|
98
111
|
Aggregator.aggregatorObjectClass = 'aggregator-object';
|
|
@@ -11,7 +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,
|
|
14
|
+
Aggregator.render(block, chart.data.valueField, innerRadius, translateAttr, thickness, settings.aggregator);
|
|
15
15
|
const donutBlock = block.getSvg()
|
|
16
16
|
.append('g')
|
|
17
17
|
.attr('class', this.donutBlockClass)
|
|
@@ -39,7 +39,7 @@ export class PolarManager {
|
|
|
39
39
|
Tooltip.render(block, model, data, model.otherComponents.tooltipBlock);
|
|
40
40
|
block.filterEventManager.setListenerPolar(model.chartBlock.margin, model.blockCanvas.size, options);
|
|
41
41
|
});
|
|
42
|
-
Aggregator.update(block,
|
|
42
|
+
Aggregator.update(block, options.charts[0].data.valueField, options.chartCanvas.aggregator);
|
|
43
43
|
Legend.update(block, data, model);
|
|
44
44
|
PolarRecordOverflowAlert.update(block, {
|
|
45
45
|
hidedRecordsAmount: model.dataSettings.scope.hidedRecordsAmount,
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MdtChartsTwoDimensionalChart, TwoDimensionalChartType } from "../../config/config";
|
|
2
2
|
import { ChartStyleConfig } from "../../designer/designerConfig";
|
|
3
3
|
import { ChartStyle } from "../model";
|
|
4
4
|
export declare class TwoDimensionalChartStyleModel {
|
|
5
5
|
private charts;
|
|
6
6
|
private chartStyleConfig;
|
|
7
7
|
private service;
|
|
8
|
-
constructor(charts:
|
|
9
|
-
getChartStyle(chart:
|
|
8
|
+
constructor(charts: MdtChartsTwoDimensionalChart[], chartStyleConfig: ChartStyleConfig);
|
|
9
|
+
getChartStyle(chart: MdtChartsTwoDimensionalChart, chartIndex: number): ChartStyle;
|
|
10
10
|
private getChartsValueFieldsAmounts;
|
|
11
11
|
}
|
|
12
12
|
export declare class TwoDimensionalChartStyleService {
|
|
13
|
-
getChartColors(chart:
|
|
13
|
+
getChartColors(chart: MdtChartsTwoDimensionalChart, styleConfig: ChartStyleConfig, chartsFieldsAmounts: number[], chartIndex: number): string[];
|
|
14
14
|
getChartOpacity(chartsLength: number, chartType: TwoDimensionalChartType, chartsValueFieldAmount: number, isChartSegmented: boolean): number;
|
|
15
15
|
private generateNewChartColors;
|
|
16
16
|
private isMoreThanOneValueFieldOnCanvas;
|
|
@@ -2,7 +2,7 @@ import { AxisModel } from "../featuresModel/axisModel";
|
|
|
2
2
|
import { LegendCanvasModel } from "../featuresModel/legendModel/legendCanvasModel";
|
|
3
3
|
import { LegendPolarMarginCalculator } from "../featuresModel/legendModel/polarMarginCalculator";
|
|
4
4
|
import { ModelHelper } from "../modelHelper";
|
|
5
|
-
import { MIN_DONUT_BLOCK_SIZE, PolarModel } from "../notations/polarModel";
|
|
5
|
+
import { MIN_DONUT_BLOCK_SIZE, PolarModel } from "../notations/polar/polarModel";
|
|
6
6
|
import { DataManagerModelService } from "./dataManagerModelService";
|
|
7
7
|
export class DataManagerModel {
|
|
8
8
|
static getPreparedData(data, allowableKeys, config) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ModelHelper } from "../../modelHelper";
|
|
2
|
-
import { PolarModel } from "../../notations/polarModel";
|
|
2
|
+
import { PolarModel } from "../../notations/polar/polarModel";
|
|
3
3
|
import { LegendCanvasModel } from "./legendCanvasModel";
|
|
4
4
|
export class LegendModel {
|
|
5
5
|
static getLegendSize(chartNotation, position, texts, legendMaxWidth, blockSize, legendBlockModel) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DataManagerModel } from "../../dataManagerModel/dataManagerModel";
|
|
2
2
|
import { MarginModel } from "../../marginModel";
|
|
3
|
-
import { MIN_DONUT_BLOCK_SIZE } from "../../notations/polarModel";
|
|
3
|
+
import { MIN_DONUT_BLOCK_SIZE } from "../../notations/polar/polarModel";
|
|
4
4
|
import { LegendModel } from "./legendModel";
|
|
5
5
|
export class LegendPolarMarginCalculator {
|
|
6
6
|
recalcMargin(modelInstance, options, legendMaxWidth, legendBlockModel, data) {
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { ScaleKeyModel, ScaleKeyType, ScaleValueModel, ScaleValueType } from "../model";
|
|
2
|
-
import { AxisPosition, NumberDomain, IntervalChart,
|
|
2
|
+
import { AxisPosition, NumberDomain, IntervalChart, MdtChartsTwoDimensionalChart, MdtChartsTwoDimensionalOptions, ChartOrientation, MdtChartsDataSource } from "../../config/config";
|
|
3
3
|
import { CanvasModel } from "../modelInstance/canvasModel/canvasModel";
|
|
4
4
|
export declare enum ScaleType {
|
|
5
5
|
Key = 0,
|
|
6
6
|
Value = 1
|
|
7
7
|
}
|
|
8
8
|
export declare class ScaleModel {
|
|
9
|
-
static getScaleKey(allowableKeys: string[], orient: ChartOrientation, canvasModel: CanvasModel, charts:
|
|
9
|
+
static getScaleKey(allowableKeys: string[], orient: ChartOrientation, canvasModel: CanvasModel, charts: MdtChartsTwoDimensionalChart[], barCharts: MdtChartsTwoDimensionalChart[]): ScaleKeyModel;
|
|
10
10
|
static getScaleLinear(options: MdtChartsTwoDimensionalOptions, data: MdtChartsDataSource, canvasModel: CanvasModel): ScaleValueModel;
|
|
11
11
|
static getRangePeek(scaleType: ScaleType, chartOrientation: string, canvasModel: CanvasModel): number;
|
|
12
12
|
static getDateValueDomain(data: MdtChartsDataSource, chart: IntervalChart, keyAxisPosition: AxisPosition, dataSource: string): [Date, Date];
|
|
13
13
|
static getLinearDomain(configDomain: NumberDomain, data: MdtChartsDataSource, configOptions: MdtChartsTwoDimensionalOptions): [number, number];
|
|
14
|
-
static getScaleKeyType(charts:
|
|
15
|
-
static getScaleValueType(charts:
|
|
16
|
-
static getElementsAmount(barCharts:
|
|
17
|
-
static getScaleMaxValue(charts:
|
|
14
|
+
static getScaleKeyType(charts: MdtChartsTwoDimensionalChart[]): ScaleKeyType;
|
|
15
|
+
static getScaleValueType(charts: MdtChartsTwoDimensionalChart[] | IntervalChart[]): ScaleValueType;
|
|
16
|
+
static getElementsAmount(barCharts: MdtChartsTwoDimensionalChart[]): number;
|
|
17
|
+
static getScaleMaxValue(charts: MdtChartsTwoDimensionalChart[], dataSource: string, data: MdtChartsDataSource): number;
|
|
18
18
|
}
|
package/lib/model/marginModel.js
CHANGED
|
@@ -3,7 +3,7 @@ import { DataManagerModel } from "./dataManagerModel/dataManagerModel";
|
|
|
3
3
|
import { LegendModel } from "./featuresModel/legendModel/legendModel";
|
|
4
4
|
import { AxisType } from "./modelBuilder";
|
|
5
5
|
import { TwoDimensionalModel } from "./notations/twoDimensionalModel";
|
|
6
|
-
import { PolarModel } from "./notations/polarModel";
|
|
6
|
+
import { PolarModel } from "./notations/polar/polarModel";
|
|
7
7
|
export const AXIS_HORIZONTAL_LABEL_PADDING = 15;
|
|
8
8
|
export const AXIS_VERTICAL_LABEL_PADDING = 10;
|
|
9
9
|
export class MarginModel {
|
package/lib/model/model.d.ts
CHANGED
|
@@ -9,10 +9,10 @@ export declare type EmbeddedLabelTypeModel = "none" | "key" | "value";
|
|
|
9
9
|
export declare type DataOptions = {
|
|
10
10
|
[option: string]: any;
|
|
11
11
|
};
|
|
12
|
-
export interface Model {
|
|
12
|
+
export interface Model<O = TwoDimensionalOptionsModel | PolarOptionsModel | IntervalOptionsModel> {
|
|
13
13
|
blockCanvas: BlockCanvas;
|
|
14
14
|
chartBlock: ChartBlockModel;
|
|
15
|
-
options:
|
|
15
|
+
options: O;
|
|
16
16
|
otherComponents: OtherCommonComponents;
|
|
17
17
|
dataSettings: DataSettings;
|
|
18
18
|
transitions?: Transitions;
|
|
@@ -136,12 +136,24 @@ export interface BarChartSettings {
|
|
|
136
136
|
maxBarWidth: number;
|
|
137
137
|
minBarWidth: number;
|
|
138
138
|
}
|
|
139
|
-
export interface DonutChartSettings extends Omit<DonutOptionsCanvas, "aggregatorPad"> {
|
|
140
|
-
aggregator:
|
|
139
|
+
export interface DonutChartSettings extends Omit<DonutOptionsCanvas, "aggregatorPad" | "thickness"> {
|
|
140
|
+
aggregator: DonutAggregatorModel;
|
|
141
|
+
thickness: DonutThicknessOptions;
|
|
141
142
|
}
|
|
142
|
-
export interface
|
|
143
|
+
export interface DonutAggregatorModel {
|
|
143
144
|
margin: number;
|
|
144
|
-
|
|
145
|
+
content: DonutAggregatorContent;
|
|
146
|
+
}
|
|
147
|
+
export interface DonutAggregatorContent {
|
|
148
|
+
value: string | number;
|
|
149
|
+
title: string;
|
|
150
|
+
}
|
|
151
|
+
export declare type DonutThicknessUnit = "px" | "%";
|
|
152
|
+
export interface DonutThicknessOptions {
|
|
153
|
+
min: number;
|
|
154
|
+
max: number;
|
|
155
|
+
value: number;
|
|
156
|
+
unit: DonutThicknessUnit;
|
|
145
157
|
}
|
|
146
158
|
interface ChartModel {
|
|
147
159
|
tooltip: TooltipModel;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MarginModel } from './marginModel';
|
|
2
2
|
import { TwoDimensionalModel } from './notations/twoDimensionalModel';
|
|
3
|
-
import { PolarModel } from './notations/polarModel';
|
|
3
|
+
import { PolarModel } from './notations/polar/polarModel';
|
|
4
4
|
import { DataManagerModel } from './dataManagerModel/dataManagerModel';
|
|
5
5
|
import { IntervalModel } from './notations/intervalModel';
|
|
6
6
|
import { OtherComponentsModel } from './featuresModel/otherComponents';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { MdtChartsConfig, MdtChartsDataSource,
|
|
1
|
+
import { MdtChartsConfig, MdtChartsDataSource, MdtChartsIntervalOptions } from "../../config/config";
|
|
2
2
|
import { DesignerConfig } from "../../designer/designerConfig";
|
|
3
3
|
import { AdditionalElementsOptions, BlockMargin, DataScope, IntervalOptionsModel } from "../model";
|
|
4
4
|
import { ModelInstance } from "../modelInstance/modelInstance";
|
|
5
5
|
export declare class IntervalModel {
|
|
6
6
|
static getOptions(config: MdtChartsConfig, designerConfig: DesignerConfig, margin: BlockMargin, dataScope: DataScope, data: MdtChartsDataSource, modelInstance: ModelInstance): IntervalOptionsModel;
|
|
7
|
-
static getAdditionalElements(options:
|
|
7
|
+
static getAdditionalElements(options: MdtChartsIntervalOptions): AdditionalElementsOptions;
|
|
8
8
|
private static getChartsModel;
|
|
9
9
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { MdtChartsDataRow, MdtChartsDonutAggregator } from "../../../../config/config";
|
|
2
|
+
import { DonutAggregatorContent } from "../../../model";
|
|
3
|
+
export declare const AGGREGATOR_DEFAULT_TITLE = "\u0421\u0443\u043C\u043C\u0430";
|
|
4
|
+
export interface AggregatorServiceDataOptions {
|
|
5
|
+
rows: MdtChartsDataRow[];
|
|
6
|
+
valueFieldName: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class DonutAggregatorService {
|
|
9
|
+
getContent(aggregatorOptions: MdtChartsDonutAggregator, dataOptions: AggregatorServiceDataOptions): DonutAggregatorContent;
|
|
10
|
+
private doesValueExist;
|
|
11
|
+
private generateDefaultContent;
|
|
12
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const AGGREGATOR_DEFAULT_TITLE = "Сумма";
|
|
2
|
+
export class DonutAggregatorService {
|
|
3
|
+
getContent(aggregatorOptions, dataOptions) {
|
|
4
|
+
if (!(aggregatorOptions === null || aggregatorOptions === void 0 ? void 0 : aggregatorOptions.content))
|
|
5
|
+
return this.generateDefaultContent(dataOptions);
|
|
6
|
+
const content = aggregatorOptions.content({ data: dataOptions.rows });
|
|
7
|
+
if (this.doesValueExist(content.value) && content.title)
|
|
8
|
+
return content;
|
|
9
|
+
if (!content.title && this.doesValueExist(content.value))
|
|
10
|
+
return {
|
|
11
|
+
value: content.value,
|
|
12
|
+
title: AGGREGATOR_DEFAULT_TITLE
|
|
13
|
+
};
|
|
14
|
+
return this.generateDefaultContent(dataOptions);
|
|
15
|
+
}
|
|
16
|
+
doesValueExist(content) {
|
|
17
|
+
return content != null;
|
|
18
|
+
}
|
|
19
|
+
generateDefaultContent(dataOptions) {
|
|
20
|
+
return {
|
|
21
|
+
title: AGGREGATOR_DEFAULT_TITLE,
|
|
22
|
+
value: dataOptions.rows.reduce((acc, row) => acc + row[dataOptions.valueFieldName], 0)
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MdtChartsDataRow, PolarChart } from "../../../../config/config";
|
|
2
|
+
import { DonutOptionsCanvas } from "../../../../designer/designerConfig";
|
|
3
|
+
import { DonutChartSettings } from "../../../model";
|
|
4
|
+
export declare class DonutModel {
|
|
5
|
+
private thicknessService;
|
|
6
|
+
private aggregatorService;
|
|
7
|
+
getSettings(settingsFromConfig: DonutOptionsCanvas, chartOptions: PolarChart, dataRows: MdtChartsDataRow[]): DonutChartSettings;
|
|
8
|
+
private getThicknessOptions;
|
|
9
|
+
private getAggregatorOptions;
|
|
10
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { DonutAggregatorService } from "./donutAggregatorService";
|
|
2
|
+
import { DonutThicknessService } from "./donutThicknessService";
|
|
3
|
+
export class DonutModel {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.thicknessService = new DonutThicknessService();
|
|
6
|
+
this.aggregatorService = new DonutAggregatorService();
|
|
7
|
+
}
|
|
8
|
+
getSettings(settingsFromConfig, chartOptions, dataRows) {
|
|
9
|
+
return {
|
|
10
|
+
padAngle: settingsFromConfig.padAngle,
|
|
11
|
+
thickness: this.getThicknessOptions(settingsFromConfig.thickness),
|
|
12
|
+
aggregator: this.getAggregatorOptions(settingsFromConfig, chartOptions, dataRows)
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
getThicknessOptions(settingsFromConfig) {
|
|
16
|
+
return {
|
|
17
|
+
unit: this.thicknessService.getUnit(settingsFromConfig),
|
|
18
|
+
max: this.thicknessService.valueToNumber(settingsFromConfig.max),
|
|
19
|
+
min: this.thicknessService.valueToNumber(settingsFromConfig.min),
|
|
20
|
+
value: this.thicknessService.valueToNumber(settingsFromConfig.value),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
getAggregatorOptions(settingsFromConfig, chartOptions, dataRows) {
|
|
24
|
+
return {
|
|
25
|
+
margin: settingsFromConfig.aggregatorPad,
|
|
26
|
+
content: this.aggregatorService.getContent(chartOptions.aggregator, {
|
|
27
|
+
rows: dataRows,
|
|
28
|
+
valueFieldName: chartOptions.data.valueField.name
|
|
29
|
+
})
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MdtChartsDonutThicknessOptions } from "../../../../designer/designerConfig";
|
|
2
|
+
import { DonutThicknessUnit } from "../../../model";
|
|
3
|
+
export declare class DonutThicknessService {
|
|
4
|
+
private defaultUnit;
|
|
5
|
+
getUnit(settingsFromConfig: MdtChartsDonutThicknessOptions): DonutThicknessUnit;
|
|
6
|
+
valueToNumber(value: string | number): number;
|
|
7
|
+
private getUnitByValue;
|
|
8
|
+
private getLastUnitFromString;
|
|
9
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export class DonutThicknessService {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.defaultUnit = "px";
|
|
4
|
+
}
|
|
5
|
+
getUnit(settingsFromConfig) {
|
|
6
|
+
if (settingsFromConfig.value)
|
|
7
|
+
return this.getUnitByValue(settingsFromConfig.value);
|
|
8
|
+
const minUnit = this.getUnitByValue(settingsFromConfig.min);
|
|
9
|
+
const maxUnit = this.getUnitByValue(settingsFromConfig.max);
|
|
10
|
+
return minUnit === maxUnit ? minUnit : this.defaultUnit;
|
|
11
|
+
}
|
|
12
|
+
valueToNumber(value) {
|
|
13
|
+
if (typeof value === "number")
|
|
14
|
+
return value;
|
|
15
|
+
return parseInt(value);
|
|
16
|
+
}
|
|
17
|
+
getUnitByValue(value) {
|
|
18
|
+
if (typeof value !== "string")
|
|
19
|
+
return this.defaultUnit;
|
|
20
|
+
return this.getLastUnitFromString(value);
|
|
21
|
+
}
|
|
22
|
+
getLastUnitFromString(value) {
|
|
23
|
+
let resultUnit = this.defaultUnit;
|
|
24
|
+
["%", "px"].forEach(unit => {
|
|
25
|
+
if (value.endsWith(unit))
|
|
26
|
+
resultUnit = unit;
|
|
27
|
+
});
|
|
28
|
+
return resultUnit;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { MdtChartsDataSource, MdtChartsPolarOptions } from "../../../config/config";
|
|
2
|
+
import { DesignerConfig } from "../../../designer/designerConfig";
|
|
3
|
+
import { PolarOptionsModel, LegendCoordinate } from "../../model";
|
|
4
|
+
import { CanvasModel } from "../../modelInstance/canvasModel/canvasModel";
|
|
5
|
+
import { ModelInstance } from "../../modelInstance/modelInstance";
|
|
6
|
+
/** If donut block has width less than this const, legend change postion from "right" to "bottom" */
|
|
7
|
+
export declare const MIN_DONUT_BLOCK_SIZE = 120;
|
|
8
|
+
export declare class PolarModel {
|
|
9
|
+
private static donutModel;
|
|
10
|
+
static getOptions(options: MdtChartsPolarOptions, data: MdtChartsDataSource, designerConfig: DesignerConfig, modelInstance: ModelInstance): PolarOptionsModel;
|
|
11
|
+
static getLegendPositionByBlockSize(canvasModel: CanvasModel): "bottom" | "right";
|
|
12
|
+
static doesChartBlockHasEnoughWidthForContainsLegend(chartBlockWidth: number, legendWidth: number, legendCoordinate: LegendCoordinate): boolean;
|
|
13
|
+
static doesChartBlockHasEnoughHeightForContainsLegend(chartBlockHeight: number, legendCoordinate: LegendCoordinate): boolean;
|
|
14
|
+
private static getDonutSettings;
|
|
15
|
+
private static getChartsModel;
|
|
16
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ChartStyleModelService } from "../../chartStyleModel/chartStyleModel";
|
|
2
|
+
import { DonutModel } from "./donut/donutModel";
|
|
3
|
+
/** If donut block has width less than this const, legend change postion from "right" to "bottom" */
|
|
4
|
+
export const MIN_DONUT_BLOCK_SIZE = 120;
|
|
5
|
+
export class PolarModel {
|
|
6
|
+
static getOptions(options, data, designerConfig, modelInstance) {
|
|
7
|
+
const dataRows = data[options.data.dataSource];
|
|
8
|
+
return {
|
|
9
|
+
type: options.type,
|
|
10
|
+
selectable: !!options.selectable,
|
|
11
|
+
title: options.title,
|
|
12
|
+
data: Object.assign({}, options.data),
|
|
13
|
+
charts: this.getChartsModel(options.chart, dataRows.length, designerConfig.chartStyle),
|
|
14
|
+
legend: modelInstance.canvasModel.legendCanvas.getModel(),
|
|
15
|
+
tooltip: options.tooltip,
|
|
16
|
+
chartCanvas: this.getDonutSettings(designerConfig.canvas.chartOptions.donut, options.chart, dataRows)
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//TODO: type for returned value
|
|
20
|
+
static getLegendPositionByBlockSize(canvasModel) {
|
|
21
|
+
const widthCoefficientWhenLegendShouldInBottom = 1.5;
|
|
22
|
+
const avgLegendWidth = 100;
|
|
23
|
+
const blockWidth = canvasModel.getBlockSize().width;
|
|
24
|
+
const blockHeight = canvasModel.getBlockSize().height;
|
|
25
|
+
return canvasModel.getChartBlockWidth() < MIN_DONUT_BLOCK_SIZE + avgLegendWidth
|
|
26
|
+
&& blockWidth * widthCoefficientWhenLegendShouldInBottom < blockHeight
|
|
27
|
+
? 'bottom'
|
|
28
|
+
: 'right';
|
|
29
|
+
}
|
|
30
|
+
static doesChartBlockHasEnoughWidthForContainsLegend(chartBlockWidth, legendWidth, legendCoordinate) {
|
|
31
|
+
const rightLegendMargin = legendCoordinate.right.margin;
|
|
32
|
+
return chartBlockWidth - legendWidth - rightLegendMargin.left - rightLegendMargin.right >= MIN_DONUT_BLOCK_SIZE;
|
|
33
|
+
}
|
|
34
|
+
static doesChartBlockHasEnoughHeightForContainsLegend(chartBlockHeight, legendCoordinate) {
|
|
35
|
+
const minHeightForLegend = 30;
|
|
36
|
+
const bottomLegendMargin = legendCoordinate.bottom.margin;
|
|
37
|
+
const heightForLegend = chartBlockHeight - bottomLegendMargin.bottom - bottomLegendMargin.top - MIN_DONUT_BLOCK_SIZE;
|
|
38
|
+
return heightForLegend >= minHeightForLegend;
|
|
39
|
+
}
|
|
40
|
+
static getDonutSettings(settings, chartOptions, dataRows) {
|
|
41
|
+
return this.donutModel.getSettings(settings, chartOptions, dataRows);
|
|
42
|
+
}
|
|
43
|
+
static getChartsModel(chart, dataLength, chartStyleConfig) {
|
|
44
|
+
const chartsModel = [];
|
|
45
|
+
chartsModel.push({
|
|
46
|
+
type: chart.type,
|
|
47
|
+
data: Object.assign({}, chart.data),
|
|
48
|
+
tooltip: chart.tooltip,
|
|
49
|
+
cssClasses: ChartStyleModelService.getCssClasses(0),
|
|
50
|
+
style: ChartStyleModelService.getChartStyle(dataLength, chartStyleConfig)
|
|
51
|
+
});
|
|
52
|
+
return chartsModel;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
PolarModel.donutModel = new DonutModel();
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { ChartOrientation, MdtChartsDataSource,
|
|
1
|
+
import { ChartOrientation, MdtChartsDataSource, MdtChartsTwoDimensionalChart, MdtChartsTwoDimensionalOptions } from "../../config/config";
|
|
2
2
|
import { BarOptionsCanvas, DesignerConfig } from "../../designer/designerConfig";
|
|
3
3
|
import { DataScope, TwoDimensionalOptionsModel, TwoDimChartElementsSettings } from "../model";
|
|
4
4
|
import { ModelInstance } from "../modelInstance/modelInstance";
|
|
5
5
|
export declare class TwoDimensionalModel {
|
|
6
6
|
static getOptions(options: MdtChartsTwoDimensionalOptions, designerConfig: DesignerConfig, dataScope: DataScope, data: MdtChartsDataSource, modelInstance: ModelInstance): TwoDimensionalOptionsModel;
|
|
7
|
-
static getChartsEmbeddedLabelsFlag(charts:
|
|
7
|
+
static getChartsEmbeddedLabelsFlag(charts: MdtChartsTwoDimensionalChart[], chartOrientation: ChartOrientation): boolean;
|
|
8
8
|
/**
|
|
9
9
|
* Сортирует список чартов в порядке: area - bar - line.
|
|
10
10
|
* Используется для того, чтобы при рендере графики с наибольшей площадью (area) не перекрывали графики с меньшей площадью (bar, line).
|
|
11
11
|
* @param charts Чарты из конфига
|
|
12
12
|
*/
|
|
13
|
-
static sortCharts(charts:
|
|
13
|
+
static sortCharts(charts: MdtChartsTwoDimensionalChart[]): void;
|
|
14
14
|
static getChartsSettings(barSettings: BarOptionsCanvas): TwoDimChartElementsSettings;
|
|
15
15
|
private static getChartsModel;
|
|
16
16
|
private static findChartsWithEmbeddedKeyLabels;
|
|
17
17
|
private static getEmbeddedLabelType;
|
|
18
18
|
private static getAdditionalElements;
|
|
19
19
|
private static getChartsByType;
|
|
20
|
-
static getChartsValueFieldsAmount(charts:
|
|
20
|
+
static getChartsValueFieldsAmount(charts: MdtChartsTwoDimensionalChart[]): number[];
|
|
21
21
|
}
|
|
@@ -200,12 +200,15 @@
|
|
|
200
200
|
line-height: 1;
|
|
201
201
|
}
|
|
202
202
|
.aggregator-value {
|
|
203
|
-
margin-top:
|
|
203
|
+
margin-top: 0.5em;
|
|
204
204
|
pointer-events: auto;
|
|
205
205
|
}
|
|
206
206
|
.aggregator-name {
|
|
207
|
-
margin-top:
|
|
207
|
+
margin-top: 0.5em;
|
|
208
208
|
pointer-events: auto;
|
|
209
|
+
max-width: 90%;
|
|
210
|
+
overflow: hidden;
|
|
211
|
+
text-overflow: ellipsis;
|
|
209
212
|
}
|
|
210
213
|
|
|
211
214
|
/* Grid */
|
|
@@ -200,12 +200,15 @@
|
|
|
200
200
|
line-height: 1;
|
|
201
201
|
}
|
|
202
202
|
.aggregator-value {
|
|
203
|
-
margin-top:
|
|
203
|
+
margin-top: 0.5em;
|
|
204
204
|
pointer-events: auto;
|
|
205
205
|
}
|
|
206
206
|
.aggregator-name {
|
|
207
|
-
margin-top:
|
|
207
|
+
margin-top: 0.5em;
|
|
208
208
|
pointer-events: auto;
|
|
209
|
+
max-width: 90%;
|
|
210
|
+
overflow: hidden;
|
|
211
|
+
text-overflow: ellipsis;
|
|
209
212
|
}
|
|
210
213
|
|
|
211
214
|
/* Grid */
|