mdt-charts 1.12.1 → 1.12.5
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 +9 -7
- package/lib/engine/features/aggregator/aggregator.js +51 -37
- package/lib/engine/features/scale/scale.d.ts +2 -0
- package/lib/engine/features/scale/scale.js +6 -3
- package/lib/engine/polarNotation/donut/donut.js +1 -1
- package/lib/engine/polarNotation/polarManager.js +1 -1
- package/lib/engine/twoDimensionalNotation/area/areaHelper.js +2 -2
- package/lib/engine/twoDimensionalNotation/bar/bar.js +3 -3
- package/lib/engine/twoDimensionalNotation/bar/barHelper.js +8 -8
- package/lib/model/chartStyleModel/TwoDimensionalChartStyleModel.d.ts +4 -4
- package/lib/model/dataManagerModel/dataManagerModel.js +1 -1
- package/lib/model/featuresModel/axisModel.d.ts +2 -1
- package/lib/model/featuresModel/axisModel.js +20 -5
- package/lib/model/featuresModel/legendModel/legendModel.js +3 -3
- package/lib/model/featuresModel/legendModel/polarMarginCalculator.js +1 -1
- package/lib/model/featuresModel/scaleModel.d.ts +7 -6
- package/lib/model/featuresModel/scaleModel.js +19 -4
- package/lib/model/featuresModel/titleModel.js +4 -4
- package/lib/model/marginModel.d.ts +1 -3
- package/lib/model/marginModel.js +0 -25
- package/lib/model/model.d.ts +18 -6
- package/lib/model/modelBuilder.js +8 -9
- package/lib/model/modelInstance/dataModel/dataModel.d.ts +14 -0
- package/lib/model/modelInstance/dataModel/dataModel.js +26 -0
- package/lib/model/modelInstance/dataModel/dataRepository.d.ts +12 -0
- package/lib/model/modelInstance/dataModel/dataRepository.js +20 -0
- package/lib/model/modelInstance/modelInstance.d.ts +3 -3
- package/lib/model/modelInstance/modelInstance.js +6 -4
- 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 +15 -0
- package/lib/model/notations/polar/polarModel.js +53 -0
- package/lib/model/notations/twoDimensionalModel.d.ts +6 -6
- package/lib/model/notations/twoDimensionalModel.js +11 -5
- package/lib/style/charts-main.css +6 -4
- package/lib/style/charts-main.less +6 -4
- 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
|
+
marginInPercent: 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,76 +1,90 @@
|
|
|
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
|
+
marginInPercent: 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 > 30) {
|
|
26
23
|
const aggregatorObject = this.renderAggregatorObject(block, innerRadius, translate);
|
|
27
24
|
const wrapper = this.renderWrapper(aggregatorObject);
|
|
28
25
|
wrapper
|
|
29
26
|
.append('div')
|
|
30
27
|
.attr('class', this.aggregatorValueClass)
|
|
28
|
+
.attr('title', this.formatValue(aggregatorInfo.format, aggregatorInfo.value))
|
|
31
29
|
.style('text-align', 'center')
|
|
32
30
|
.style('font-size', `${fontSize}px`)
|
|
33
|
-
.text(
|
|
34
|
-
wrapper
|
|
31
|
+
.text(this.formatValue(aggregatorInfo.format, aggregatorInfo.value));
|
|
32
|
+
const titleBlock = wrapper
|
|
35
33
|
.append('div')
|
|
36
|
-
.attr('class', this.
|
|
34
|
+
.attr('class', this.aggregatorTitleClass)
|
|
37
35
|
.attr('title', aggregatorInfo.name)
|
|
38
36
|
.style('text-align', 'center')
|
|
39
|
-
.style('font-size', '18px')
|
|
40
37
|
.text(aggregatorInfo.name);
|
|
41
|
-
this.
|
|
38
|
+
this.setTitleFontSize(titleBlock, innerRadius);
|
|
39
|
+
this.reCalculateAggregatorFontSize(aggregatorObject.node().getBoundingClientRect().width, block, aggregatorInfo.marginInPercent);
|
|
42
40
|
}
|
|
43
41
|
}
|
|
44
|
-
static
|
|
42
|
+
static formatValue(format, value) {
|
|
43
|
+
if (typeof value === "string")
|
|
44
|
+
return value;
|
|
45
|
+
return ValueFormatter.formatField(format, value);
|
|
46
|
+
}
|
|
47
|
+
static updateText(block, newAggregator, withoutAnimation) {
|
|
45
48
|
const aggregatorObject = block.getSvg()
|
|
46
49
|
.select(`.${this.aggregatorObjectClass}`);
|
|
47
50
|
const thisClass = this;
|
|
48
|
-
block.getSvg()
|
|
49
|
-
.select(`.${this.aggregatorValueClass}`)
|
|
51
|
+
const valueBlock = block.getSvg()
|
|
52
|
+
.select(`.${this.aggregatorValueClass}`);
|
|
53
|
+
if (withoutAnimation) {
|
|
54
|
+
valueBlock.text(this.formatValue(newAggregator.format, newAggregator.value));
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
valueBlock
|
|
50
58
|
.interrupt()
|
|
51
59
|
.transition()
|
|
52
60
|
.duration(block.transitionManager.durations.chartUpdate)
|
|
53
61
|
.tween("text", function () {
|
|
62
|
+
const newValue = typeof newAggregator.value === "string" ? parseFloat(newAggregator.value) : newAggregator.value;
|
|
54
63
|
const oldValue = Helper.parseFormattedToNumber(this.textContent, ',');
|
|
55
|
-
const precision = Helper.calcDigitsAfterDot(
|
|
56
|
-
const interpolateFunc = interpolateNumber(oldValue,
|
|
64
|
+
const precision = Helper.calcDigitsAfterDot(newValue);
|
|
65
|
+
const interpolateFunc = interpolateNumber(oldValue, newValue);
|
|
57
66
|
return t => {
|
|
58
|
-
this.textContent =
|
|
59
|
-
thisClass.reCalculateAggregatorFontSize(aggregatorObject.node().getBoundingClientRect().width, block, newAggregator.
|
|
67
|
+
this.textContent = thisClass.formatValue(newAggregator.format, parseFloat((interpolateFunc(t)).toFixed(precision)));
|
|
68
|
+
thisClass.reCalculateAggregatorFontSize(aggregatorObject.node().getBoundingClientRect().width, block, newAggregator.marginInPercent);
|
|
60
69
|
};
|
|
61
70
|
});
|
|
62
71
|
}
|
|
63
72
|
static reCalculateAggregatorFontSize(wrapperSize, block, pad) {
|
|
64
|
-
const
|
|
73
|
+
const aggregatorValue = block.getSvg()
|
|
65
74
|
.select(`.${this.aggregatorValueClass}`);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
while (
|
|
71
|
-
|
|
75
|
+
const sizeCoefficient = 0.25;
|
|
76
|
+
let fontSize = wrapperSize * sizeCoefficient;
|
|
77
|
+
aggregatorValue.style('font-size', `${fontSize}px`);
|
|
78
|
+
const margin = pad / 100 * wrapperSize;
|
|
79
|
+
while (aggregatorValue.node().getBoundingClientRect().width > wrapperSize - margin * 2 && fontSize > 12) {
|
|
80
|
+
aggregatorValue.style('font-size', `${fontSize -= 2}px`);
|
|
72
81
|
}
|
|
73
82
|
}
|
|
83
|
+
static setTitleFontSize(aggregatorTitle, innerRadius) {
|
|
84
|
+
const sizeCoefficient = 0.15;
|
|
85
|
+
aggregatorTitle.style('font-size', `${Math.round(innerRadius * sizeCoefficient)}px`);
|
|
86
|
+
aggregatorTitle.style('max-height', `${sizeCoefficient * 100}%`);
|
|
87
|
+
}
|
|
74
88
|
static renderAggregatorObject(block, innerRadius, translate) {
|
|
75
89
|
return block.getSvg()
|
|
76
90
|
.append('foreignObject')
|
|
@@ -94,5 +108,5 @@ export class Aggregator {
|
|
|
94
108
|
}
|
|
95
109
|
}
|
|
96
110
|
Aggregator.aggregatorValueClass = 'aggregator-value';
|
|
97
|
-
Aggregator.
|
|
111
|
+
Aggregator.aggregatorTitleClass = 'aggregator-name';
|
|
98
112
|
Aggregator.aggregatorObjectClass = 'aggregator-object';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ScaleLinear, ScaleTime } from 'd3-scale';
|
|
1
2
|
import { AxisScale } from 'd3-axis';
|
|
2
3
|
import { BarChartSettings, ScaleKeyModel, ScaleValueModel } from '../../../model/model';
|
|
3
4
|
export interface Scales {
|
|
@@ -6,6 +7,7 @@ export interface Scales {
|
|
|
6
7
|
}
|
|
7
8
|
export declare class Scale {
|
|
8
9
|
static getScales(scaleKey: ScaleKeyModel, scaleValue: ScaleValueModel, bandSettings: BarChartSettings): Scales;
|
|
10
|
+
static getScaleValue(scaleValue: ScaleValueModel): ScaleLinear<number, number, never> | ScaleTime<number, number, never>;
|
|
9
11
|
static getScaleBandWidth(scale: AxisScale<any>): number;
|
|
10
12
|
static getScaleStep(scale: AxisScale<any>): number;
|
|
11
13
|
static getScaledValue(scale: AxisScale<any>, value: any): number;
|
|
@@ -9,11 +9,14 @@ export class Scale {
|
|
|
9
9
|
scales.key = this.getScaleBand(scaleKey.domain, scaleKey.range, bandSettings, scaleKey.elementsAmount);
|
|
10
10
|
else if (scaleKey.type === 'point')
|
|
11
11
|
scales.key = this.getScalePoint(scaleKey.domain, scaleKey.range);
|
|
12
|
+
scales.value = this.getScaleValue(scaleValue);
|
|
13
|
+
return scales;
|
|
14
|
+
}
|
|
15
|
+
static getScaleValue(scaleValue) {
|
|
12
16
|
if (scaleValue.type === 'linear')
|
|
13
|
-
|
|
17
|
+
return this.getScaleLinear(scaleValue.domain, scaleValue.range);
|
|
14
18
|
else if (scaleValue.type === 'datetime')
|
|
15
|
-
|
|
16
|
-
return scales;
|
|
19
|
+
return this.getScaleTime(scaleValue.domain, scaleValue.range);
|
|
17
20
|
}
|
|
18
21
|
static getScaleBandWidth(scale) {
|
|
19
22
|
if (scale.bandwidth && scale.bandwidth() !== 0) {
|
|
@@ -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,
|
|
@@ -5,11 +5,11 @@ export class AreaHelper {
|
|
|
5
5
|
if (keyAxisOrient === 'bottom' || keyAxisOrient === 'top')
|
|
6
6
|
return area()
|
|
7
7
|
.x(d => Scale.getScaledValue(scales.key, d[keyFieldName]) + margin.left)
|
|
8
|
-
.y0(d =>
|
|
8
|
+
.y0(d => scales.value(0) + margin.top)
|
|
9
9
|
.y1(d => scales.value(d[valueFieldName]) + margin.top);
|
|
10
10
|
if (keyAxisOrient === 'left' || keyAxisOrient === 'right')
|
|
11
11
|
return area()
|
|
12
|
-
.x0(d =>
|
|
12
|
+
.x0(d => scales.value(0) + margin.left)
|
|
13
13
|
.x1(d => scales.value(d[valueFieldName]) + margin.left)
|
|
14
14
|
.y(d => Scale.getScaledValue(scales.key, d[keyFieldName]) + margin.top);
|
|
15
15
|
}
|
|
@@ -171,15 +171,15 @@ export class Bar {
|
|
|
171
171
|
resolve('');
|
|
172
172
|
return;
|
|
173
173
|
}
|
|
174
|
-
let
|
|
174
|
+
let barsHandler = bars;
|
|
175
175
|
if (transitionDuration > 0) {
|
|
176
|
-
|
|
176
|
+
barsHandler = barsHandler
|
|
177
177
|
.interrupt()
|
|
178
178
|
.transition()
|
|
179
179
|
.duration(transitionDuration)
|
|
180
180
|
.on('end', () => resolve(''));
|
|
181
181
|
}
|
|
182
|
-
|
|
182
|
+
barsHandler.attr('x', d => barAttrs.x(d))
|
|
183
183
|
.attr('y', d => barAttrs.y(d))
|
|
184
184
|
.attr('height', d => barAttrs.height(d))
|
|
185
185
|
.attr('width', d => barAttrs.width(d));
|
|
@@ -66,20 +66,20 @@ export class BarHelper {
|
|
|
66
66
|
}
|
|
67
67
|
static setGroupedBarAttrsByValue(attrs, keyAxisOrient, margin, scaleValue, valueFieldName, blockSize) {
|
|
68
68
|
if (keyAxisOrient === 'top') {
|
|
69
|
-
attrs.y = d => margin.top;
|
|
70
|
-
attrs.height = d =>
|
|
69
|
+
attrs.y = d => scaleValue(Math.min(d[valueFieldName], 0)) + margin.top;
|
|
70
|
+
attrs.height = d => Math.abs(scaleValue(d[valueFieldName]) - scaleValue(0));
|
|
71
71
|
}
|
|
72
72
|
if (keyAxisOrient === 'bottom') {
|
|
73
|
-
attrs.y = d => scaleValue(d[valueFieldName]) + margin.top;
|
|
74
|
-
attrs.height = d =>
|
|
73
|
+
attrs.y = d => scaleValue(Math.max(d[valueFieldName], 0)) + margin.top;
|
|
74
|
+
attrs.height = d => Math.abs(scaleValue(d[valueFieldName]) - scaleValue(0));
|
|
75
75
|
}
|
|
76
76
|
if (keyAxisOrient === 'left') {
|
|
77
|
-
attrs.x = d =>
|
|
78
|
-
attrs.width = d =>
|
|
77
|
+
attrs.x = d => scaleValue(Math.min(d[valueFieldName], 0)) + margin.left;
|
|
78
|
+
attrs.width = d => Math.abs(scaleValue(d[valueFieldName]) - scaleValue(0));
|
|
79
79
|
}
|
|
80
80
|
if (keyAxisOrient === 'right') {
|
|
81
|
-
attrs.x = d => scaleValue(d[valueFieldName]) + margin.left;
|
|
82
|
-
attrs.width = d =>
|
|
81
|
+
attrs.x = d => scaleValue(Math.max(d[valueFieldName], 0)) + margin.left;
|
|
82
|
+
attrs.width = d => Math.abs(scaleValue(d[valueFieldName]) - scaleValue(0));
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
static setSegmentedBarAttrsByValue(attrs, keyAxisOrient, scaleValue, margin, blockSize) {
|
|
@@ -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) {
|
|
@@ -9,7 +9,7 @@ export interface LabelSize {
|
|
|
9
9
|
}
|
|
10
10
|
export declare class AxisModel {
|
|
11
11
|
private static service;
|
|
12
|
-
static getKeyAxis(options: MdtChartsTwoDimensionalOptions, data: MdtChartsDataSource, labelConfig: AxisLabelCanvas, canvasModel: CanvasModel, tooltipSettings: TooltipSettings): AxisModelOptions;
|
|
12
|
+
static getKeyAxis(options: MdtChartsTwoDimensionalOptions, data: MdtChartsDataSource, labelConfig: AxisLabelCanvas, canvasModel: CanvasModel, tooltipSettings: TooltipSettings, getZeroCoordinate?: () => number): AxisModelOptions;
|
|
13
13
|
static getValueAxis(orient: ChartOrientation, axisConfig: NumberAxisOptions, labelConfig: AxisLabelCanvas, canvasModel: CanvasModel): AxisModelOptions;
|
|
14
14
|
static getAxisLength(chartOrientation: ChartOrientation, canvasModel: CanvasModel): number;
|
|
15
15
|
static getAxisOrient(axisType: AxisType, chartOrientation: ChartOrientation, axisPosition: AxisPosition): Orient;
|
|
@@ -17,4 +17,5 @@ export declare class AxisModel {
|
|
|
17
17
|
static getAxisTranslateY(axisType: AxisType, chartOrientation: ChartOrientation, axisPosition: AxisPosition, canvasModel: CanvasModel): number;
|
|
18
18
|
static getKeyAxisLabelPosition(canvasModel: CanvasModel, scopedDataLength: number, axisConfig?: DiscreteAxisOptions): AxisLabelPosition;
|
|
19
19
|
static getLabelSize(labelMaxWidth: number, labelTexts: any[]): LabelSize;
|
|
20
|
+
private static getKeyAxisTranslateModel;
|
|
20
21
|
}
|
|
@@ -4,16 +4,14 @@ import { DataManagerModel } from "../dataManagerModel/dataManagerModel";
|
|
|
4
4
|
import { TwoDimensionalModel } from "../notations/twoDimensionalModel";
|
|
5
5
|
import { AxisModelService } from "./axisModelService";
|
|
6
6
|
export class AxisModel {
|
|
7
|
-
static getKeyAxis(options, data, labelConfig, canvasModel, tooltipSettings) {
|
|
7
|
+
static getKeyAxis(options, data, labelConfig, canvasModel, tooltipSettings, getZeroCoordinate) {
|
|
8
8
|
const { charts, orientation, data: dataOptions } = options;
|
|
9
9
|
const axisConfig = options.axis.key;
|
|
10
|
+
const translate = this.getKeyAxisTranslateModel(orientation, axisConfig.position, canvasModel, getZeroCoordinate);
|
|
10
11
|
return {
|
|
11
12
|
type: 'key',
|
|
12
13
|
orient: AxisModel.getAxisOrient(AxisType.Key, orientation, axisConfig.position),
|
|
13
|
-
translate
|
|
14
|
-
translateX: AxisModel.getAxisTranslateX(AxisType.Key, orientation, axisConfig.position, canvasModel),
|
|
15
|
-
translateY: AxisModel.getAxisTranslateY(AxisType.Key, orientation, axisConfig.position, canvasModel)
|
|
16
|
-
},
|
|
14
|
+
translate,
|
|
17
15
|
cssClass: 'key-axis',
|
|
18
16
|
ticks: axisConfig.ticks,
|
|
19
17
|
labels: {
|
|
@@ -109,5 +107,22 @@ export class AxisModel {
|
|
|
109
107
|
textBlock.remove();
|
|
110
108
|
return labelSize;
|
|
111
109
|
}
|
|
110
|
+
static getKeyAxisTranslateModel(chartOrientation, axisPosition, canvasModel, getZeroCoordinate) {
|
|
111
|
+
let translateY;
|
|
112
|
+
let translateX;
|
|
113
|
+
if (chartOrientation === "vertical") {
|
|
114
|
+
translateY = getZeroCoordinate() + canvasModel.getMarginSide("top");
|
|
115
|
+
translateX = AxisModel.getAxisTranslateX(AxisType.Key, chartOrientation, axisPosition, canvasModel);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
translateX = getZeroCoordinate() + canvasModel.getMarginSide("left");
|
|
119
|
+
translateY = AxisModel.getAxisTranslateY(AxisType.Key, chartOrientation, axisPosition, canvasModel);
|
|
120
|
+
}
|
|
121
|
+
console.log(translateX, translateY);
|
|
122
|
+
return {
|
|
123
|
+
translateX,
|
|
124
|
+
translateY
|
|
125
|
+
};
|
|
126
|
+
}
|
|
112
127
|
}
|
|
113
128
|
AxisModel.service = new AxisModelService();
|
|
@@ -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) {
|
|
@@ -30,12 +30,12 @@ export class LegendModel {
|
|
|
30
30
|
},
|
|
31
31
|
right: {
|
|
32
32
|
size: 0,
|
|
33
|
-
margin: { top: canvasModel.titleCanvas.getAllNeededSpace(), bottom: mb, left:
|
|
33
|
+
margin: { top: canvasModel.titleCanvas.getAllNeededSpace(), bottom: mb, left: 5, right: 0 },
|
|
34
34
|
pad: 0
|
|
35
35
|
},
|
|
36
36
|
top: {
|
|
37
37
|
size: 0,
|
|
38
|
-
margin: { top:
|
|
38
|
+
margin: { top: 5, bottom: 10, left: 0, right: 0 },
|
|
39
39
|
pad: canvasModel.titleCanvas.getAllNeededSpace()
|
|
40
40
|
}
|
|
41
41
|
},
|
|
@@ -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,19 @@
|
|
|
1
1
|
import { ScaleKeyModel, ScaleKeyType, ScaleValueModel, ScaleValueType } from "../model";
|
|
2
|
-
import { AxisPosition, NumberDomain, IntervalChart,
|
|
2
|
+
import { AxisPosition, NumberDomain, IntervalChart, MdtChartsTwoDimensionalChart, MdtChartsTwoDimensionalOptions, ChartOrientation, MdtChartsDataSource, MdtChartsDataRow } 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[], dataRows: MdtChartsDataRow[]): number;
|
|
18
|
+
static getScaleMinValue(charts: MdtChartsTwoDimensionalChart[], dataRows: MdtChartsDataRow[]): number;
|
|
18
19
|
}
|
|
@@ -47,11 +47,11 @@ export class ScaleModel {
|
|
|
47
47
|
let domainPeekMin;
|
|
48
48
|
let domainPeekMax;
|
|
49
49
|
if (configDomain.start === -1)
|
|
50
|
-
domainPeekMin =
|
|
50
|
+
domainPeekMin = this.getScaleMinValue(configOptions.charts, data[configOptions.data.dataSource]);
|
|
51
51
|
else
|
|
52
52
|
domainPeekMin = configDomain.start;
|
|
53
53
|
if (configDomain.end === -1)
|
|
54
|
-
domainPeekMax = this.getScaleMaxValue(configOptions.charts, configOptions.data.dataSource
|
|
54
|
+
domainPeekMax = this.getScaleMaxValue(configOptions.charts, data[configOptions.data.dataSource]);
|
|
55
55
|
else
|
|
56
56
|
domainPeekMax = configDomain.end;
|
|
57
57
|
if (configOptions.axis.key.position === 'start')
|
|
@@ -80,10 +80,10 @@ export class ScaleModel {
|
|
|
80
80
|
});
|
|
81
81
|
return barsAmount;
|
|
82
82
|
}
|
|
83
|
-
static getScaleMaxValue(charts,
|
|
83
|
+
static getScaleMaxValue(charts, dataRows) {
|
|
84
84
|
let max = 0;
|
|
85
85
|
charts.forEach(chart => {
|
|
86
|
-
|
|
86
|
+
dataRows.forEach(dataRow => {
|
|
87
87
|
let sumInRow = 0;
|
|
88
88
|
chart.data.valueFields.forEach(field => {
|
|
89
89
|
if (chart.isSegmented)
|
|
@@ -97,4 +97,19 @@ export class ScaleModel {
|
|
|
97
97
|
});
|
|
98
98
|
return max;
|
|
99
99
|
}
|
|
100
|
+
static getScaleMinValue(charts, dataRows) {
|
|
101
|
+
let min = 0;
|
|
102
|
+
charts.forEach(chart => {
|
|
103
|
+
dataRows.forEach(dataRow => {
|
|
104
|
+
let sumInRow = 0;
|
|
105
|
+
chart.data.valueFields.forEach(field => {
|
|
106
|
+
if (dataRow[field.name] < sumInRow)
|
|
107
|
+
sumInRow = dataRow[field.name];
|
|
108
|
+
});
|
|
109
|
+
if (min > sumInRow)
|
|
110
|
+
min = sumInRow;
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
return min;
|
|
114
|
+
}
|
|
100
115
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { MdtChartsConfig, MdtChartsDataSource } from "../config/config";
|
|
2
2
|
import { DesignerConfig } from "../designer/designerConfig";
|
|
3
|
-
import { DataScope, LegendBlockModel, Orient, OtherCommonComponents
|
|
3
|
+
import { DataScope, LegendBlockModel, Orient, OtherCommonComponents } from "./model";
|
|
4
4
|
import { ModelInstance } from "./modelInstance/modelInstance";
|
|
5
5
|
import { CanvasModel } from "./modelInstance/canvasModel/canvasModel";
|
|
6
6
|
export declare const AXIS_HORIZONTAL_LABEL_PADDING = 15;
|
|
7
7
|
export declare const AXIS_VERTICAL_LABEL_PADDING = 10;
|
|
8
8
|
export declare class MarginModel {
|
|
9
9
|
static initMargin(designerConfig: DesignerConfig, config: MdtChartsConfig, otherComponents: OtherCommonComponents, data: MdtChartsDataSource, modelInstance: ModelInstance): void;
|
|
10
|
-
static recalcPolarMarginWithScopedData(modelInstance: ModelInstance, designerConfig: DesignerConfig, config: MdtChartsConfig, legendBlockModel: LegendBlockModel, dataScope: DataScope, options: PolarOptionsModel): void;
|
|
11
10
|
static recalcMarginByVerticalAxisLabel(modelInstance: ModelInstance, config: MdtChartsConfig, designerConfig: DesignerConfig, dataScope: DataScope): void;
|
|
12
11
|
private static getHorizontalMarginByAxisLabels;
|
|
13
12
|
private static recalcVerticalMarginByAxisLabelHeight;
|
|
@@ -15,6 +14,5 @@ export declare class MarginModel {
|
|
|
15
14
|
private static recalcMarginWithLegend;
|
|
16
15
|
private static getLegendItemsContent;
|
|
17
16
|
static appendToGlobalMarginValuesLegendMargin(canvasModel: CanvasModel, position: Orient, legendBlockModel: LegendBlockModel): void;
|
|
18
|
-
private static clearMarginByLegendBlockPosition;
|
|
19
17
|
private static recalcMarginByTitle;
|
|
20
18
|
}
|