mdt-charts 1.24.0 → 1.26.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/lib/config/config.d.ts +13 -3
- package/lib/engine/features/title/title.d.ts +3 -3
- package/lib/engine/features/title/title.js +9 -8
- package/lib/engine/features/valueLabels/valueLabels.d.ts +3 -1
- package/lib/engine/features/valueLabels/valueLabels.js +15 -2
- package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +1 -0
- package/lib/model/featuresModel/otherComponents.d.ts +2 -1
- package/lib/model/featuresModel/otherComponents.js +1 -1
- package/lib/model/featuresModel/titleModel.d.ts +2 -3
- package/lib/model/featuresModel/titleModel.js +3 -9
- package/lib/model/helpers/twoDimensionalModelHelper.d.ts +2 -2
- package/lib/model/helpers/twoDimensionalModelHelper.js +5 -4
- package/lib/model/margin/twoDim/twoDimMarginModel.d.ts +1 -1
- package/lib/model/margin/twoDim/twoDimMarginModel.js +2 -3
- package/lib/model/model.d.ts +11 -1
- package/lib/model/modelBuilder.js +2 -2
- package/lib/model/modelInstance/configReader.d.ts +2 -0
- package/lib/model/modelInstance/configReader.js +8 -0
- package/lib/model/modelInstance/dataModel/dataRepository.js +2 -1
- package/lib/model/modelInstance/titleConfigReader.d.ts +12 -0
- package/lib/model/modelInstance/titleConfigReader.js +33 -0
- package/lib/model/notations/polar/polarModel.js +6 -4
- package/lib/model/notations/twoDimensionalModel.js +7 -4
- package/lib/style/charts-main.css +0 -4
- package/lib/style/charts-main.less +0 -4
- package/package.json +1 -1
package/lib/config/config.d.ts
CHANGED
|
@@ -77,10 +77,14 @@ export interface MdtChartsTwoDimLegend extends Legend {
|
|
|
77
77
|
export interface TitleFunctionParams {
|
|
78
78
|
data: MdtChartsDataRow[];
|
|
79
79
|
}
|
|
80
|
-
export interface
|
|
80
|
+
export interface TitleFunc {
|
|
81
81
|
(params: TitleFunctionParams): string;
|
|
82
82
|
}
|
|
83
|
-
export
|
|
83
|
+
export interface TitleObj {
|
|
84
|
+
text: string | TitleFunc;
|
|
85
|
+
fontSize?: number;
|
|
86
|
+
}
|
|
87
|
+
export declare type Title = string | TitleFunc | TitleObj;
|
|
84
88
|
export interface MdtChartsBasicDataOptions {
|
|
85
89
|
dataSource: string;
|
|
86
90
|
}
|
|
@@ -191,7 +195,8 @@ export interface MdtChartsShowAxisLabelRule {
|
|
|
191
195
|
showTickFn?: ShowTickFn;
|
|
192
196
|
}
|
|
193
197
|
export interface MdtChartsTwoDimensionalValueLabels {
|
|
194
|
-
collision
|
|
198
|
+
collision?: ValueLabelsCollision;
|
|
199
|
+
style?: ValueLabelsStyleOptions;
|
|
195
200
|
}
|
|
196
201
|
export interface ValueLabelsCollision {
|
|
197
202
|
otherValueLabels: OtherValueLabels;
|
|
@@ -199,6 +204,11 @@ export interface ValueLabelsCollision {
|
|
|
199
204
|
export interface OtherValueLabels {
|
|
200
205
|
mode: ValueLabelsCollisionMode;
|
|
201
206
|
}
|
|
207
|
+
export interface ValueLabelsStyleOptions {
|
|
208
|
+
cssClassName?: string;
|
|
209
|
+
fontSize?: number;
|
|
210
|
+
color?: string;
|
|
211
|
+
}
|
|
202
212
|
export interface IntervalAxis {
|
|
203
213
|
key: DiscreteAxisOptions;
|
|
204
214
|
value: DateAxisOptions;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Size } from '../../../config/config';
|
|
2
|
-
import { TitleBlockModel } from "../../../model/model";
|
|
2
|
+
import { OptionsModelTitle, TitleBlockModel } from "../../../model/model";
|
|
3
3
|
import { Block } from "../../block/block";
|
|
4
4
|
export declare class Title {
|
|
5
5
|
private static readonly titleCssClass;
|
|
6
|
-
static render(block: Block,
|
|
7
|
-
static updateData(block: Block,
|
|
6
|
+
static render(block: Block, title: OptionsModelTitle, titleBlockModel: TitleBlockModel, blockSize: Size): void;
|
|
7
|
+
static updateData(block: Block, title: OptionsModelTitle): void;
|
|
8
8
|
private static fillTitleBlockAttributes;
|
|
9
9
|
private static getTitleAttributes;
|
|
10
10
|
private static setTitleTooltip;
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import { DomHelper } from '../../helpers/domHelper';
|
|
2
2
|
export class Title {
|
|
3
|
-
static render(block,
|
|
4
|
-
if (!
|
|
3
|
+
static render(block, title, titleBlockModel, blockSize) {
|
|
4
|
+
if (!title.textContent)
|
|
5
5
|
return;
|
|
6
6
|
const titleBlock = block.getSvg()
|
|
7
7
|
.append('text')
|
|
8
8
|
.attr('class', this.titleCssClass);
|
|
9
9
|
const titleCoordinate = this.getTitleAttributes(blockSize, titleBlockModel);
|
|
10
|
-
this.fillTitleBlockAttributes(titleBlock, titleCoordinate,
|
|
11
|
-
this.setTitleTooltip(titleBlock,
|
|
10
|
+
this.fillTitleBlockAttributes(titleBlock, titleCoordinate, title);
|
|
11
|
+
this.setTitleTooltip(titleBlock, title.textContent);
|
|
12
12
|
}
|
|
13
|
-
static updateData(block,
|
|
14
|
-
block.getSvg().select(`.${this.titleCssClass}`).text(
|
|
13
|
+
static updateData(block, title) {
|
|
14
|
+
block.getSvg().select(`.${this.titleCssClass}`).text(title.textContent);
|
|
15
15
|
}
|
|
16
|
-
static fillTitleBlockAttributes(titleBlock, attributes,
|
|
16
|
+
static fillTitleBlockAttributes(titleBlock, attributes, title) {
|
|
17
17
|
titleBlock
|
|
18
18
|
.attr('x', attributes.x)
|
|
19
19
|
.attr('y', attributes.y)
|
|
20
20
|
.attr('dominant-baseline', attributes.dominantBaseline)
|
|
21
|
-
.text(
|
|
21
|
+
.text(title.textContent)
|
|
22
|
+
.style('font-size', `${title.fontSize}px`);
|
|
22
23
|
DomHelper.cropSvgLabels(titleBlock, attributes.maxWidth);
|
|
23
24
|
}
|
|
24
25
|
static getTitleAttributes(blockSize, titleBlockModel) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Block } from "../../../engine/block/block";
|
|
2
|
-
import { OptionsModelData, Orient, TwoDimensionalChartModel, TwoDimensionalValueLabels, ValueLabelAnchor, ValueLabelDominantBaseline } from "../../../model/model";
|
|
2
|
+
import { OptionsModelData, Orient, TwoDimensionalChartModel, TwoDimensionalValueLabels, ValueLabelAnchor, ValueLabelDominantBaseline, ValueLabelsStyleModel } from "../../../model/model";
|
|
3
3
|
import { MdtChartsDataRow, MdtChartsDataSource } from "../../../config/config";
|
|
4
4
|
import { Scales, ScalesWithSecondary } from "../../../engine/features/scale/scale";
|
|
5
5
|
export interface ValueLabelsOptions {
|
|
@@ -12,6 +12,7 @@ export interface ValueLabelsOptions {
|
|
|
12
12
|
canvas: {
|
|
13
13
|
keyAxisOrient: Orient;
|
|
14
14
|
valueLabels: TwoDimensionalValueLabels;
|
|
15
|
+
style: ValueLabelsStyleModel;
|
|
15
16
|
};
|
|
16
17
|
}
|
|
17
18
|
export interface ValueLabelAttrs {
|
|
@@ -24,6 +25,7 @@ export declare class ChartValueLabels {
|
|
|
24
25
|
private readonly globalOptions;
|
|
25
26
|
private readonly chart;
|
|
26
27
|
private static readonly valueLabelClass;
|
|
28
|
+
private readonly renderPipeline;
|
|
27
29
|
constructor(globalOptions: ValueLabelsOptions, chart: TwoDimensionalChartModel);
|
|
28
30
|
render(scales: Scales, data: MdtChartsDataRow[]): void;
|
|
29
31
|
update(scales: Scales, newData: MdtChartsDataRow[]): Promise<void[]>;
|
|
@@ -5,17 +5,29 @@ import { select } from "d3-selection";
|
|
|
5
5
|
import { DomHelper } from "../../../engine/helpers/domHelper";
|
|
6
6
|
import { CLASSES } from "../../../model/modelBuilder";
|
|
7
7
|
import { ValueLabelsCollision } from "../../../engine/features/valueLabelsCollision/valueLabelsCollision";
|
|
8
|
+
import { Pipeline } from "../../helpers/pipeline/Pipeline";
|
|
8
9
|
export class ChartValueLabels {
|
|
9
10
|
constructor(globalOptions, chart) {
|
|
10
11
|
this.globalOptions = globalOptions;
|
|
11
12
|
this.chart = chart;
|
|
13
|
+
this.renderPipeline = new Pipeline();
|
|
14
|
+
this.renderPipeline.push((valueLabels, { style }) => {
|
|
15
|
+
valueLabels
|
|
16
|
+
.attr('fill', 'currentColor')
|
|
17
|
+
.style('font-size', style.fontSize)
|
|
18
|
+
.style('color', style.color);
|
|
19
|
+
if (style.cssClassName)
|
|
20
|
+
valueLabels.classed(style.cssClassName, true);
|
|
21
|
+
return valueLabels;
|
|
22
|
+
});
|
|
12
23
|
}
|
|
13
24
|
render(scales, data) {
|
|
14
25
|
this.chart.data.valueFields.forEach((valueField, vfIndex) => {
|
|
15
|
-
|
|
26
|
+
let valueLabels = this.getAllValueLabelsOfChart(vfIndex)
|
|
16
27
|
.data(data)
|
|
17
28
|
.enter()
|
|
18
29
|
.append('text');
|
|
30
|
+
valueLabels = this.renderPipeline.execute(valueLabels, { style: this.globalOptions.canvas.style });
|
|
19
31
|
const attrs = ValueLabelsHelper.getValueLabelsAttrs(this.globalOptions, this.chart.valueLabels, scales, valueField);
|
|
20
32
|
this.setAttrs(valueLabels, attrs, valueField.name, this.chart.valueLabels.format);
|
|
21
33
|
this.setClasses(valueLabels, this.chart.cssClasses, vfIndex);
|
|
@@ -29,9 +41,10 @@ export class ChartValueLabels {
|
|
|
29
41
|
.data(newData);
|
|
30
42
|
valueLabels.exit().remove();
|
|
31
43
|
const attrs = ValueLabelsHelper.getValueLabelsAttrs(this.globalOptions, this.chart.valueLabels, scales, valueField);
|
|
32
|
-
|
|
44
|
+
let newValueLabels = valueLabels
|
|
33
45
|
.enter()
|
|
34
46
|
.append('text');
|
|
47
|
+
newValueLabels = this.renderPipeline.execute(newValueLabels, { style: this.globalOptions.canvas.style });
|
|
35
48
|
const mergedValueLabels = newValueLabels.merge(valueLabels);
|
|
36
49
|
this.setAttrs(newValueLabels, attrs, valueField.name, this.chart.valueLabels.format);
|
|
37
50
|
this.setClasses(mergedValueLabels, this.chart.cssClasses, vfIndex);
|
|
@@ -65,6 +65,7 @@ export class TwoDimensionalManager {
|
|
|
65
65
|
canvas: {
|
|
66
66
|
keyAxisOrient: options.axis.key.orient,
|
|
67
67
|
valueLabels: options.valueLabels,
|
|
68
|
+
style: options.valueLabels.style
|
|
68
69
|
}
|
|
69
70
|
});
|
|
70
71
|
this.canvasValueLabels.render(scales, options.charts, engine.data, options.data);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { OtherCommonComponents } from "../model";
|
|
2
2
|
import { ElementsOptions, LegendBlockCanvas } from "../../designer/designerConfig";
|
|
3
3
|
import { ModelInstance } from "../modelInstance/modelInstance";
|
|
4
|
+
import { TitleConfigReader } from "../modelInstance/titleConfigReader";
|
|
4
5
|
interface OtherComponentsModelDependencies {
|
|
5
6
|
elementsOptions: ElementsOptions;
|
|
6
7
|
legendConfig: LegendBlockCanvas;
|
|
7
|
-
|
|
8
|
+
titleConfig: TitleConfigReader;
|
|
8
9
|
}
|
|
9
10
|
export declare class OtherComponentsModel {
|
|
10
11
|
static getOtherComponentsModel(dependencies: OtherComponentsModelDependencies, modelInstance: ModelInstance): OtherCommonComponents;
|
|
@@ -4,7 +4,7 @@ import { TooltipModel } from "./tooltipModel";
|
|
|
4
4
|
export class OtherComponentsModel {
|
|
5
5
|
static getOtherComponentsModel(dependencies, modelInstance) {
|
|
6
6
|
const canvasModel = modelInstance.canvasModel;
|
|
7
|
-
canvasModel.titleCanvas.init(TitleModel.getTitleModel(dependencies.
|
|
7
|
+
canvasModel.titleCanvas.init(TitleModel.getTitleModel(dependencies.titleConfig));
|
|
8
8
|
return {
|
|
9
9
|
legendBlock: LegendModel.getBaseLegendBlockModel(canvasModel, dependencies.legendConfig),
|
|
10
10
|
titleBlock: canvasModel.titleCanvas.getModel(),
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { TitleBlockModel } from "../model";
|
|
2
|
-
import {
|
|
3
|
-
export declare const getResolvedTitle: (title: Title, dataRows: MdtChartsDataRow[]) => string;
|
|
2
|
+
import { TitleConfigReader } from "../modelInstance/titleConfigReader";
|
|
4
3
|
export declare class TitleModel {
|
|
5
|
-
static getTitleModel(
|
|
4
|
+
static getTitleModel(titleConfig: TitleConfigReader): TitleBlockModel;
|
|
6
5
|
}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import { ModelHelper } from "../helpers/modelHelper";
|
|
2
|
-
export const getResolvedTitle = (title, dataRows) => {
|
|
3
|
-
return typeof title === 'function'
|
|
4
|
-
? title({ data: dataRows })
|
|
5
|
-
: title;
|
|
6
|
-
};
|
|
7
1
|
export class TitleModel {
|
|
8
|
-
static getTitleModel(
|
|
9
|
-
const defaultPads =
|
|
10
|
-
const pad =
|
|
2
|
+
static getTitleModel(titleConfig) {
|
|
3
|
+
const defaultPads = titleConfig.getFontSize();
|
|
4
|
+
const pad = titleConfig.getTextContent() ? defaultPads : 0;
|
|
11
5
|
return {
|
|
12
6
|
margin: {
|
|
13
7
|
bottom: 5,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ChartOrientation, MdtChartsDataRow, MdtChartsTwoDimensionalChart, MdtChartsTwoDimensionalValueLabels } from "../../config/config";
|
|
2
|
-
import { GradientDef, MarkDotDatumItem, Orient, TwoDimensionalChartModel, TwoDimensionalValueLabels } from "../model";
|
|
2
|
+
import { GradientDef, MarkDotDatumItem, Orient, TwoDimensionalChartModel, TwoDimensionalValueLabels, ValueLabelsStyleModel } from "../model";
|
|
3
3
|
import { CanvasModel } from "../modelInstance/canvasModel/canvasModel";
|
|
4
4
|
export declare class TwoDimensionalModelHelper {
|
|
5
5
|
static shouldMarkerShow(chart: MdtChartsTwoDimensionalChart, dataRows: MdtChartsDataRow[], valueFieldName: string, currentRow: MarkDotDatumItem, keyFieldName: string): boolean;
|
|
@@ -7,6 +7,6 @@ export declare class TwoDimensionalModelHelper {
|
|
|
7
7
|
private static getGradientItems;
|
|
8
8
|
private static calculateOpacityItem;
|
|
9
9
|
private static getGradientItemColor;
|
|
10
|
-
static getValueLabels(valueLabels: MdtChartsTwoDimensionalValueLabels, canvasModel: CanvasModel, chartOrientation: ChartOrientation): TwoDimensionalValueLabels;
|
|
10
|
+
static getValueLabels(valueLabels: MdtChartsTwoDimensionalValueLabels, canvasModel: CanvasModel, chartOrientation: ChartOrientation, styleModel: ValueLabelsStyleModel): TwoDimensionalValueLabels;
|
|
11
11
|
private static getChartBlockSidesOptions;
|
|
12
12
|
}
|
|
@@ -62,8 +62,8 @@ export class TwoDimensionalModelHelper {
|
|
|
62
62
|
else
|
|
63
63
|
return itemIndex === 0 ? minColor : maxColor;
|
|
64
64
|
}
|
|
65
|
-
static getValueLabels(valueLabels, canvasModel, chartOrientation) {
|
|
66
|
-
var _a;
|
|
65
|
+
static getValueLabels(valueLabels, canvasModel, chartOrientation, styleModel) {
|
|
66
|
+
var _a, _b;
|
|
67
67
|
const blockSidesOptions = this.getChartBlockSidesOptions(canvasModel);
|
|
68
68
|
const chartBlockConfig = {
|
|
69
69
|
vertical: {
|
|
@@ -105,11 +105,12 @@ export class TwoDimensionalModelHelper {
|
|
|
105
105
|
};
|
|
106
106
|
return {
|
|
107
107
|
collision: {
|
|
108
|
-
otherValueLables: (_a = valueLabels === null || valueLabels === void 0 ? void 0 : valueLabels.collision.otherValueLabels) !== null &&
|
|
108
|
+
otherValueLables: (_b = (_a = valueLabels === null || valueLabels === void 0 ? void 0 : valueLabels.collision) === null || _a === void 0 ? void 0 : _a.otherValueLabels) !== null && _b !== void 0 ? _b : {
|
|
109
109
|
mode: 'none'
|
|
110
110
|
},
|
|
111
111
|
chartBlock: chartBlockConfig[chartOrientation]
|
|
112
|
-
}
|
|
112
|
+
},
|
|
113
|
+
style: styleModel
|
|
113
114
|
};
|
|
114
115
|
}
|
|
115
116
|
static getChartBlockSidesOptions(canvasModel) {
|
|
@@ -2,7 +2,7 @@ import { DesignerConfig } from "../../../designer/designerConfig";
|
|
|
2
2
|
import { OtherCommonComponents } from "../../model";
|
|
3
3
|
import { TwoDimConfigReader } from "../../modelInstance/configReader";
|
|
4
4
|
import { ModelInstance } from "../../modelInstance/modelInstance";
|
|
5
|
-
export declare const AXIS_HORIZONTAL_LABEL_PADDING =
|
|
5
|
+
export declare const AXIS_HORIZONTAL_LABEL_PADDING = 12;
|
|
6
6
|
export declare const AXIS_VERTICAL_LABEL_PADDING = 8;
|
|
7
7
|
export declare class TwoDimMarginModel {
|
|
8
8
|
private designerConfig;
|
|
@@ -3,9 +3,8 @@ import { TwoDimLegendModel } from "../../featuresModel/legendModel/twoDimLegendM
|
|
|
3
3
|
import { keyAxisLabelHorizontalLog, keyAxisLabelVerticalLog } from "../../featuresModel/scaleModel/scaleAxisRecalcer";
|
|
4
4
|
import { AxisType } from "../../modelBuilder";
|
|
5
5
|
import { TwoDimensionalModel } from "../../notations/twoDimensionalModel";
|
|
6
|
-
import { ModelHelper } from "../../helpers/modelHelper";
|
|
7
6
|
import { OFFSET_SIZE_PX } from "../../featuresModel/valueLabelsModel/valueLabelsModel";
|
|
8
|
-
export const AXIS_HORIZONTAL_LABEL_PADDING =
|
|
7
|
+
export const AXIS_HORIZONTAL_LABEL_PADDING = 12;
|
|
9
8
|
export const AXIS_VERTICAL_LABEL_PADDING = 8;
|
|
10
9
|
export class TwoDimMarginModel {
|
|
11
10
|
constructor(designerConfig, configReader) {
|
|
@@ -108,7 +107,7 @@ export class TwoDimMarginModel {
|
|
|
108
107
|
}
|
|
109
108
|
recalcVerticalMarginWithValueLabelsOn(canvasModel) {
|
|
110
109
|
const keyAxisOrient = AxisModel.getAxisOrient(AxisType.Key, this.configReader.options.orientation, this.configReader.options.axis.key.position);
|
|
111
|
-
const valueLabelFontSize =
|
|
110
|
+
const valueLabelFontSize = this.configReader.getValueLabelsStyleModel().fontSize;
|
|
112
111
|
const axisMarginMapping = {
|
|
113
112
|
top: "bottom",
|
|
114
113
|
bottom: "top"
|
package/lib/model/model.d.ts
CHANGED
|
@@ -42,7 +42,7 @@ interface BasicOptionsModel {
|
|
|
42
42
|
interface GraphicNotationOptionsModel extends BasicOptionsModel {
|
|
43
43
|
legend: ILegendModel;
|
|
44
44
|
data: OptionsModelData;
|
|
45
|
-
title:
|
|
45
|
+
title: OptionsModelTitle;
|
|
46
46
|
selectable: boolean;
|
|
47
47
|
defs: OptionsModelGradients;
|
|
48
48
|
}
|
|
@@ -83,6 +83,10 @@ export interface Field {
|
|
|
83
83
|
name: string;
|
|
84
84
|
format: DataType;
|
|
85
85
|
}
|
|
86
|
+
export interface OptionsModelTitle {
|
|
87
|
+
textContent: string;
|
|
88
|
+
fontSize: number;
|
|
89
|
+
}
|
|
86
90
|
export interface OptionsModelGradients {
|
|
87
91
|
gradients: GradientDef[];
|
|
88
92
|
}
|
|
@@ -225,6 +229,7 @@ interface SegmentedBarBorderRadius {
|
|
|
225
229
|
}
|
|
226
230
|
export interface TwoDimensionalValueLabels {
|
|
227
231
|
collision: ValueLabelsCollision;
|
|
232
|
+
style: ValueLabelsStyleModel;
|
|
228
233
|
}
|
|
229
234
|
export interface ValueLabelsCollision {
|
|
230
235
|
otherValueLables: OtherValueLables;
|
|
@@ -233,6 +238,11 @@ export interface ValueLabelsCollision {
|
|
|
233
238
|
export interface OtherValueLables {
|
|
234
239
|
mode: ValueLabelsCollisionMode;
|
|
235
240
|
}
|
|
241
|
+
export interface ValueLabelsStyleModel {
|
|
242
|
+
cssClassName?: string;
|
|
243
|
+
fontSize: number;
|
|
244
|
+
color: string;
|
|
245
|
+
}
|
|
236
246
|
export interface ValueLabelsChartBlock {
|
|
237
247
|
left: ValueLabelsChartBlockSide;
|
|
238
248
|
right: ValueLabelsChartBlockSide;
|
|
@@ -6,7 +6,7 @@ import { OtherComponentsModel } from './featuresModel/otherComponents';
|
|
|
6
6
|
import { ConfigValidator } from './configsValidator/configValidator';
|
|
7
7
|
import { ModelInstance } from './modelInstance/modelInstance';
|
|
8
8
|
import { TwoDimConfigReader } from './modelInstance/configReader';
|
|
9
|
-
import {
|
|
9
|
+
import { TitleConfigReader } from "./modelInstance/titleConfigReader";
|
|
10
10
|
export var AxisType;
|
|
11
11
|
(function (AxisType) {
|
|
12
12
|
AxisType[AxisType["Key"] = 0] = "Key";
|
|
@@ -79,7 +79,7 @@ export function assembleModel(config, data, designerConfig) {
|
|
|
79
79
|
const otherComponents = OtherComponentsModel.getOtherComponentsModel({
|
|
80
80
|
elementsOptions: designerConfig.elementsOptions,
|
|
81
81
|
legendConfig: designerConfig.canvas.legendBlock,
|
|
82
|
-
|
|
82
|
+
titleConfig: TitleConfigReader.create(config.options.title, modelInstance)
|
|
83
83
|
}, modelInstance);
|
|
84
84
|
const marginModel = new MarginModel(designerConfig, config);
|
|
85
85
|
marginModel.initMargin(otherComponents, modelInstance);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AxisLabelFormatter, MdtChartsConfig, MdtChartsField, MdtChartsFieldName, MdtChartsTwoDimensionalOptions, TwoDimensionalChartType, TwoDimensionalValueGroup, ValueLabelsFormatter } from "../../config/config";
|
|
2
2
|
import { DesignerConfig } from "../../designer/designerConfig";
|
|
3
3
|
import { DataRepositoryModel } from "../../model/modelInstance/dataModel/dataRepository";
|
|
4
|
+
import { ValueLabelsStyleModel } from "../model";
|
|
4
5
|
interface BaseConfigReader {
|
|
5
6
|
getValueFields(): MdtChartsField[];
|
|
6
7
|
}
|
|
@@ -23,6 +24,7 @@ export declare class TwoDimConfigReader implements BaseConfigReader {
|
|
|
23
24
|
getValueLabelFormatterForChart(chartIndex: number): ValueLabelsFormatter;
|
|
24
25
|
calculateDefaultAxisLabelFormatter(): AxisLabelFormatter;
|
|
25
26
|
isValueLabelsOn(): boolean;
|
|
27
|
+
getValueLabelsStyleModel(): ValueLabelsStyleModel;
|
|
26
28
|
private calculateBiggestValueAndDecremented;
|
|
27
29
|
private calculateAxisLabelFormatter;
|
|
28
30
|
}
|
|
@@ -78,6 +78,14 @@ export class TwoDimConfigReader {
|
|
|
78
78
|
isValueLabelsOn() {
|
|
79
79
|
return this.options.charts.some(chart => { var _a; return (_a = chart.valueLabels) === null || _a === void 0 ? void 0 : _a.on; });
|
|
80
80
|
}
|
|
81
|
+
getValueLabelsStyleModel() {
|
|
82
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
83
|
+
return {
|
|
84
|
+
fontSize: (_c = (_b = (_a = this.options.valueLabels) === null || _a === void 0 ? void 0 : _a.style) === null || _b === void 0 ? void 0 : _b.fontSize) !== null && _c !== void 0 ? _c : 10,
|
|
85
|
+
color: (_f = (_e = (_d = this.options.valueLabels) === null || _d === void 0 ? void 0 : _d.style) === null || _e === void 0 ? void 0 : _e.color) !== null && _f !== void 0 ? _f : "rgba(68, 68, 68, 0.5)",
|
|
86
|
+
cssClassName: (_h = (_g = this.options.valueLabels) === null || _g === void 0 ? void 0 : _g.style) === null || _h === void 0 ? void 0 : _h.cssClassName
|
|
87
|
+
};
|
|
88
|
+
}
|
|
81
89
|
calculateBiggestValueAndDecremented(repository, domain, fields) {
|
|
82
90
|
const resolvedDomain = getResolvedDomain(domain, repository.getRawRows());
|
|
83
91
|
if (resolvedDomain && resolvedDomain.end !== -1) {
|
|
@@ -20,7 +20,8 @@ export class DataRepositoryModel {
|
|
|
20
20
|
});
|
|
21
21
|
});
|
|
22
22
|
const biggest = Math.max(...values);
|
|
23
|
-
|
|
23
|
+
const biggestDecremented = Math.abs(biggest) > 1 ? (biggest - 1) : (biggest - 0.1);
|
|
24
|
+
return [biggest, biggestDecremented];
|
|
24
25
|
}
|
|
25
26
|
initRawFullSource(rawSource) {
|
|
26
27
|
this.rawFullSource = rawSource;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ModelInstance } from "./modelInstance";
|
|
2
|
+
import { MdtChartsDataRow, Title } from "../../config/config";
|
|
3
|
+
export declare class TitleConfigReader {
|
|
4
|
+
private readonly config;
|
|
5
|
+
private readonly dataGetter;
|
|
6
|
+
private readonly defaultCssUnitReader;
|
|
7
|
+
static create(config: Title, modelInstance: ModelInstance): TitleConfigReader;
|
|
8
|
+
constructor(config: Title, dataGetter: () => MdtChartsDataRow[], defaultCssUnitReader: () => number);
|
|
9
|
+
getTextContent(): string;
|
|
10
|
+
getFontSize(): number;
|
|
11
|
+
private getResolvedTitle;
|
|
12
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ModelHelper } from "../helpers/modelHelper";
|
|
2
|
+
export class TitleConfigReader {
|
|
3
|
+
constructor(config, dataGetter, defaultCssUnitReader) {
|
|
4
|
+
this.config = config;
|
|
5
|
+
this.dataGetter = dataGetter;
|
|
6
|
+
this.defaultCssUnitReader = defaultCssUnitReader;
|
|
7
|
+
}
|
|
8
|
+
static create(config, modelInstance) {
|
|
9
|
+
return new TitleConfigReader(config, () => modelInstance.dataModel.repository.getRawRows(), () => ModelHelper.getFontSizeCssValue('--chart-title-font-size', 16));
|
|
10
|
+
}
|
|
11
|
+
getTextContent() {
|
|
12
|
+
return this.getResolvedTitle();
|
|
13
|
+
}
|
|
14
|
+
getFontSize() {
|
|
15
|
+
var _a;
|
|
16
|
+
return typeof this.config === 'object'
|
|
17
|
+
? (_a = this.config.fontSize) !== null && _a !== void 0 ? _a : this.defaultCssUnitReader() : this.defaultCssUnitReader();
|
|
18
|
+
}
|
|
19
|
+
getResolvedTitle() {
|
|
20
|
+
switch (typeof this.config) {
|
|
21
|
+
case 'string':
|
|
22
|
+
return this.config;
|
|
23
|
+
case "function":
|
|
24
|
+
return this.config({ data: this.dataGetter() });
|
|
25
|
+
case "object":
|
|
26
|
+
return typeof this.config.text === 'function'
|
|
27
|
+
? this.config.text({ data: this.dataGetter() })
|
|
28
|
+
: this.config.text;
|
|
29
|
+
default:
|
|
30
|
+
return '';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { ChartStyleModelService } from "../../chartStyleModel/chartStyleModel";
|
|
2
2
|
import { DonutModel } from "./donut/donutModel";
|
|
3
|
-
import {
|
|
3
|
+
import { TitleConfigReader } from "../../modelInstance/titleConfigReader";
|
|
4
4
|
export const MIN_DONUT_BLOCK_SIZE = 120;
|
|
5
5
|
export class PolarModel {
|
|
6
6
|
static getOptions(options, designerConfig, modelInstance) {
|
|
7
|
-
const
|
|
8
|
-
const resolvedTitle = getResolvedTitle(options.title, dataRows);
|
|
7
|
+
const titleConfig = TitleConfigReader.create(options.title, modelInstance);
|
|
9
8
|
return {
|
|
10
9
|
type: options.type,
|
|
11
10
|
selectable: !!options.selectable,
|
|
12
|
-
title:
|
|
11
|
+
title: {
|
|
12
|
+
textContent: titleConfig.getTextContent(),
|
|
13
|
+
fontSize: titleConfig.getFontSize(),
|
|
14
|
+
},
|
|
13
15
|
data: Object.assign({}, options.data),
|
|
14
16
|
charts: this.getChartsModel(options.chart, modelInstance.dataModel.repository.getScopedRows().length, designerConfig.chartStyle),
|
|
15
17
|
legend: modelInstance.canvasModel.legendCanvas.getModel(),
|
|
@@ -4,14 +4,15 @@ import { AxisModel } from "../featuresModel/axisModel";
|
|
|
4
4
|
import { ScaleAxisRecalcer } from "../featuresModel/scaleModel/scaleAxisRecalcer";
|
|
5
5
|
import { ScaleModel } from "../featuresModel/scaleModel/scaleModel";
|
|
6
6
|
import { getAreaViewOptions, getBarViewOptions, getLegendMarkerOptions, LINE_CHART_DEFAULT_WIDTH, parseDashStyles, parseShape } from "./twoDimensional/styles";
|
|
7
|
-
import { getResolvedTitle } from "../../model/featuresModel/titleModel";
|
|
8
7
|
import { calculateValueLabelAlignment, getValueLabelX, getValueLabelY } from "../../model/featuresModel/valueLabelsModel/valueLabelsModel";
|
|
9
8
|
import { TwoDimensionalModelHelper } from "../helpers/twoDimensionalModelHelper";
|
|
9
|
+
import { TitleConfigReader } from "../modelInstance/titleConfigReader";
|
|
10
10
|
export class TwoDimensionalModel {
|
|
11
11
|
static getOptions(configReader, designerConfig, modelInstance) {
|
|
12
12
|
const options = configReader.options;
|
|
13
13
|
const canvasModel = modelInstance.canvasModel;
|
|
14
14
|
const scaleModel = new ScaleModel();
|
|
15
|
+
const titleConfig = TitleConfigReader.create(options.title, modelInstance);
|
|
15
16
|
const scaleMarginRecalcer = new ScaleAxisRecalcer(() => scaleModel.getScaleLinear(options, modelInstance.dataModel.repository.getScopedRows(), canvasModel, configReader));
|
|
16
17
|
scaleMarginRecalcer.recalculateMargin(canvasModel, options.orientation, options.axis.key);
|
|
17
18
|
const scaleValueInfo = scaleMarginRecalcer.getScaleValue();
|
|
@@ -26,7 +27,10 @@ export class TwoDimensionalModel {
|
|
|
26
27
|
const defaultFormatter = configReader.calculateDefaultAxisLabelFormatter();
|
|
27
28
|
return {
|
|
28
29
|
legend: canvasModel.legendCanvas.getModel(),
|
|
29
|
-
title:
|
|
30
|
+
title: {
|
|
31
|
+
textContent: titleConfig.getTextContent(),
|
|
32
|
+
fontSize: titleConfig.getFontSize(),
|
|
33
|
+
},
|
|
30
34
|
selectable: !!options.selectable,
|
|
31
35
|
orient: options.orientation,
|
|
32
36
|
scale: Object.assign({ key: scaleModel.getScaleKey(modelInstance.dataModel.getAllowableKeys(), options.orientation, canvasModel, options.charts, this.getChartsByTypes(options.charts, ['bar', 'dot'])), value: scaleValueInfo.scale }, (configReader.containsSecondaryAxis() && { valueSecondary: secondaryScaleValueInfo.scale })),
|
|
@@ -37,7 +41,7 @@ export class TwoDimensionalModel {
|
|
|
37
41
|
additionalElements: this.getAdditionalElements(options),
|
|
38
42
|
tooltip: options.tooltip,
|
|
39
43
|
chartSettings: this.getChartsSettings(designerConfig.canvas.chartOptions, options.orientation),
|
|
40
|
-
valueLabels: TwoDimensionalModelHelper.getValueLabels(options.valueLabels, canvasModel, options.orientation),
|
|
44
|
+
valueLabels: TwoDimensionalModelHelper.getValueLabels(options.valueLabels, canvasModel, options.orientation, configReader.getValueLabelsStyleModel()),
|
|
41
45
|
defs: {
|
|
42
46
|
gradients: TwoDimensionalModelHelper.getGradientDefs(charts, keyAxis.orient, options.orientation)
|
|
43
47
|
}
|
|
@@ -67,7 +71,6 @@ export class TwoDimensionalModel {
|
|
|
67
71
|
}
|
|
68
72
|
static getChartsModel(charts, configReader, chartOrientation, designerConfig, dataModelRep, keyAxisOrient, canvasModel, keyFieldName) {
|
|
69
73
|
const styleModel = new TwoDimensionalChartStyleModel(charts, designerConfig.chartStyle);
|
|
70
|
-
this.sortCharts(charts);
|
|
71
74
|
const chartsModel = [];
|
|
72
75
|
charts.forEach((chart, index) => {
|
|
73
76
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
:root {
|
|
2
2
|
--chart-base-font-size: 12px;
|
|
3
|
-
--value-label-font-size: 10px;
|
|
4
3
|
--chart-title-font-size: 16px;
|
|
5
4
|
}
|
|
6
5
|
|
|
@@ -273,7 +272,6 @@
|
|
|
273
272
|
font-family: "Roboto", sans-serif;
|
|
274
273
|
font-style: normal;
|
|
275
274
|
font-weight: 500;
|
|
276
|
-
font-size: var(--chart-title-font-size);
|
|
277
275
|
line-height: 140.62%;
|
|
278
276
|
cursor: default;
|
|
279
277
|
}
|
|
@@ -291,7 +289,5 @@
|
|
|
291
289
|
|
|
292
290
|
/* Value Labels */
|
|
293
291
|
.mdt-charts-value-label {
|
|
294
|
-
opacity: 0.5;
|
|
295
|
-
font-size: var(--value-label-font-size);
|
|
296
292
|
letter-spacing: -0.4px;
|
|
297
293
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
:root {
|
|
2
2
|
--chart-base-font-size: 12px;
|
|
3
|
-
--value-label-font-size: 10px;
|
|
4
3
|
--chart-title-font-size: 16px;
|
|
5
4
|
}
|
|
6
5
|
|
|
@@ -273,7 +272,6 @@
|
|
|
273
272
|
font-family: "Roboto", sans-serif;
|
|
274
273
|
font-style: normal;
|
|
275
274
|
font-weight: 500;
|
|
276
|
-
font-size: var(--chart-title-font-size);
|
|
277
275
|
line-height: 140.62%;
|
|
278
276
|
cursor: default;
|
|
279
277
|
}
|
|
@@ -291,7 +289,5 @@
|
|
|
291
289
|
|
|
292
290
|
/* Value Labels */
|
|
293
291
|
.mdt-charts-value-label {
|
|
294
|
-
opacity: 0.5;
|
|
295
|
-
font-size: var(--value-label-font-size);
|
|
296
292
|
letter-spacing: -0.4px;
|
|
297
293
|
}
|