mdt-charts 1.25.0 → 1.26.1
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/bar/bar.d.ts +2 -2
- package/lib/engine/twoDimensionalNotation/bar/bar.js +8 -8
- package/lib/engine/twoDimensionalNotation/bar/barHelper.d.ts +0 -7
- package/lib/engine/twoDimensionalNotation/bar/barHelper.js +0 -17
- package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +3 -2
- 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 +12 -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/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/twoDimensional/styles.d.ts +2 -1
- package/lib/model/notations/twoDimensional/styles.js +9 -2
- package/lib/model/notations/twoDimensionalModel.js +9 -5
- 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);
|
|
@@ -21,8 +21,8 @@ export declare class Bar {
|
|
|
21
21
|
private createBarPipeline;
|
|
22
22
|
private createSegmentGroupBarsPipeline;
|
|
23
23
|
constructor();
|
|
24
|
-
render(block: Block, scales: Scales, data: MdtChartsDataRow[], keyField: Field, margin: BlockMargin, keyAxisOrient: Orient, chart: TwoDimensionalChartModel, blockSize: Size, barSettings: BarChartSettings, barsAmounts: number[],
|
|
25
|
-
update(block: Block, newData: MdtChartsDataRow[], scales: Scales, margin: BlockMargin, keyAxisOrient: Orient, chart: TwoDimensionalChartModel, blockSize: Size, barsAmounts: number[], keyField: Field, firstBarIndex: number, barSettings: BarChartSettings
|
|
24
|
+
render(block: Block, scales: Scales, data: MdtChartsDataRow[], keyField: Field, margin: BlockMargin, keyAxisOrient: Orient, chart: TwoDimensionalChartModel, blockSize: Size, barSettings: BarChartSettings, barsAmounts: number[], firstBarIndex: number): void;
|
|
25
|
+
update(block: Block, newData: MdtChartsDataRow[], scales: Scales, margin: BlockMargin, keyAxisOrient: Orient, chart: TwoDimensionalChartModel, blockSize: Size, barsAmounts: number[], keyField: Field, firstBarIndex: number, barSettings: BarChartSettings): Promise<any>[];
|
|
26
26
|
updateColors(block: Block, chart: TwoDimensionalChartModel): void;
|
|
27
27
|
getAllBarsForChart(block: Block, chartCssClasses: string[]): Selection<BaseType, MdtChartsDataRow, BaseType, unknown>;
|
|
28
28
|
private renderGrouped;
|
|
@@ -18,15 +18,15 @@ export class Bar {
|
|
|
18
18
|
static get() {
|
|
19
19
|
return new Bar();
|
|
20
20
|
}
|
|
21
|
-
render(block, scales, data, keyField, margin, keyAxisOrient, chart, blockSize, barSettings, barsAmounts,
|
|
22
|
-
if (isSegmented)
|
|
21
|
+
render(block, scales, data, keyField, margin, keyAxisOrient, chart, blockSize, barSettings, barsAmounts, firstBarIndex) {
|
|
22
|
+
if (chart.isSegmented)
|
|
23
23
|
this.renderSegmented(block, scales, data, keyField, margin, keyAxisOrient, chart, barsAmounts, firstBarIndex, barSettings);
|
|
24
24
|
else
|
|
25
25
|
this.renderGrouped(block, scales, data, keyField, margin, keyAxisOrient, chart, barsAmounts, blockSize, firstBarIndex, barSettings);
|
|
26
26
|
}
|
|
27
|
-
update(block, newData, scales, margin, keyAxisOrient, chart, blockSize, barsAmounts, keyField, firstBarIndex, barSettings
|
|
27
|
+
update(block, newData, scales, margin, keyAxisOrient, chart, blockSize, barsAmounts, keyField, firstBarIndex, barSettings) {
|
|
28
28
|
let promises;
|
|
29
|
-
if (isSegmented) {
|
|
29
|
+
if (chart.isSegmented) {
|
|
30
30
|
promises = this.updateSegmented(block, newData, scales, margin, keyAxisOrient, chart, blockSize, barsAmounts, keyField, firstBarIndex, barSettings);
|
|
31
31
|
}
|
|
32
32
|
else {
|
|
@@ -54,7 +54,7 @@ export class Bar {
|
|
|
54
54
|
.attr('class', this.barItemClass)
|
|
55
55
|
.style('clip-path', `url(#${block.svg.getClipPathId()})`);
|
|
56
56
|
bars = this.createBarPipeline.execute(bars, chart);
|
|
57
|
-
const barAttrs = BarHelper.getGroupedBarAttrs(keyAxisOrient, scales, margin, keyField.name, field.name,
|
|
57
|
+
const barAttrs = BarHelper.getGroupedBarAttrs(keyAxisOrient, scales, margin, keyField.name, field.name, chart.barViewOptions.barIndexes[index], sum(barsAmounts), barSettings);
|
|
58
58
|
this.fillBarAttrs(bars, barAttrs);
|
|
59
59
|
DomHelper.setCssClasses(bars, Helper.getCssClassesWithElementIndex(chart.cssClasses, index));
|
|
60
60
|
DomHelper.setChartStyle(bars, chart.style, index, 'fill');
|
|
@@ -82,7 +82,7 @@ export class Bar {
|
|
|
82
82
|
.attr('class', this.barItemClass)
|
|
83
83
|
.style('clip-path', `url(#${block.svg.getClipPathId()})`);
|
|
84
84
|
bars = this.createBarPipeline.execute(bars, chart);
|
|
85
|
-
const barAttrs = BarHelper.getStackedBarAttr(keyAxisOrient, scales, margin, keyField.name,
|
|
85
|
+
const barAttrs = BarHelper.getStackedBarAttr(keyAxisOrient, scales, margin, keyField.name, chart.barViewOptions.barIndexes[0], sum(barsAmounts), barSettings);
|
|
86
86
|
this.fillBarAttrs(bars, barAttrs);
|
|
87
87
|
this.setInitialAttrsInfo(bars, keyAxisOrient, barSettings);
|
|
88
88
|
DomHelper.setCssClasses(groups, chart.cssClasses);
|
|
@@ -123,7 +123,7 @@ export class Bar {
|
|
|
123
123
|
.attr('class', this.barItemClass)
|
|
124
124
|
.style('clip-path', `url(#${block.svg.getClipPathId()})`);
|
|
125
125
|
newBars = this.createBarPipeline.execute(newBars, chart);
|
|
126
|
-
const barAttrs = BarHelper.getGroupedBarAttrs(keyAxisOrient, scales, margin, keyField.name, valueField.name,
|
|
126
|
+
const barAttrs = BarHelper.getGroupedBarAttrs(keyAxisOrient, scales, margin, keyField.name, valueField.name, chart.barViewOptions.barIndexes[index], sum(barsAmounts), barSettings);
|
|
127
127
|
const prom = this.fillBarAttrs(bars, barAttrs, block.transitionManager.durations.chartUpdate)
|
|
128
128
|
.then(() => {
|
|
129
129
|
bars.style('opacity', null);
|
|
@@ -166,7 +166,7 @@ export class Bar {
|
|
|
166
166
|
.attr('class', this.barItemClass)
|
|
167
167
|
.style('clip-path', `url(#${block.svg.getClipPathId()})`);
|
|
168
168
|
newBars = this.createBarPipeline.execute(newBars, chart);
|
|
169
|
-
const barAttrs = BarHelper.getStackedBarAttr(keyAxisOrient, scales, margin, keyField.name,
|
|
169
|
+
const barAttrs = BarHelper.getStackedBarAttr(keyAxisOrient, scales, margin, keyField.name, chart.barViewOptions.barIndexes[0], sum(barsAmounts), barSettings);
|
|
170
170
|
const prom = this.fillBarAttrs(bars, barAttrs, block.transitionManager.durations.chartUpdate)
|
|
171
171
|
.then(() => {
|
|
172
172
|
this.setInitialAttrsInfo(bars, keyAxisOrient, barSettings);
|
|
@@ -41,13 +41,6 @@ export declare class BarHelper {
|
|
|
41
41
|
static getGroupedBarAttrs(keyAxisOrient: Orient, scales: Scales, margin: BlockMargin, keyField: string, valueFieldName: string, barIndex: number, barsAmount: number, barSettings: BarChartSettings): BarAttrsHelper;
|
|
42
42
|
static getStackedBarAttr(keyAxisOrient: Orient, scales: Scales, margin: BlockMargin, keyField: string, barIndex: number, barsAmount: number, barSettings: BarChartSettings): BarAttrsHelper;
|
|
43
43
|
static getBarsInGroupAmount(charts: TwoDimensionalChartModel[]): number[];
|
|
44
|
-
/**
|
|
45
|
-
* Получение индекса бара среди всх графиков и value-филдов. Используется для того, чтобы узнать, какой по счету в группе
|
|
46
|
-
* этот бар идет (сегментированный всегда один, группированный - количество value-филдов).
|
|
47
|
-
* @param barsAmounts
|
|
48
|
-
* @param chartIndex
|
|
49
|
-
*/
|
|
50
|
-
static getBarIndex(barsAmounts: number[], chartIndex: number): number;
|
|
51
44
|
static setBarAttrsByKey(attrs: BarAttrsHelper, keyAxisOrient: Orient, scaleKey: AxisScale<any>, margin: BlockMargin, keyField: string, barIndex: number, settingsStore: BandLikeChartSettingsStore, isSegmented: boolean): void;
|
|
52
45
|
private static setGroupedBarAttrsByValue;
|
|
53
46
|
static getBandItemValueStretch(scaleValue: AxisScale<any>, valueFieldName: string): (dataRow: MdtChartsDataRow) => number;
|
|
@@ -63,23 +63,6 @@ export class BarHelper {
|
|
|
63
63
|
});
|
|
64
64
|
return amounts;
|
|
65
65
|
}
|
|
66
|
-
/**
|
|
67
|
-
* Получение индекса бара среди всх графиков и value-филдов. Используется для того, чтобы узнать, какой по счету в группе
|
|
68
|
-
* этот бар идет (сегментированный всегда один, группированный - количество value-филдов).
|
|
69
|
-
* @param barsAmounts
|
|
70
|
-
* @param chartIndex
|
|
71
|
-
*/
|
|
72
|
-
static getBarIndex(barsAmounts, chartIndex) {
|
|
73
|
-
if (barsAmounts.length < 2)
|
|
74
|
-
return 0;
|
|
75
|
-
let index = 0;
|
|
76
|
-
barsAmounts.forEach((chartBars, i) => {
|
|
77
|
-
if (i < chartIndex) {
|
|
78
|
-
index += chartBars;
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
return index;
|
|
82
|
-
}
|
|
83
66
|
static setBarAttrsByKey(attrs, keyAxisOrient, scaleKey, margin, keyField, barIndex, settingsStore, isSegmented) {
|
|
84
67
|
if (keyAxisOrient === 'top' || keyAxisOrient === 'bottom') {
|
|
85
68
|
attrs.x = d => scaleKey(Helper.getKeyFieldValue(d, keyField, isSegmented)) + margin.left + settingsStore.getBandItemPad(barIndex);
|
|
@@ -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);
|
|
@@ -123,7 +124,7 @@ export class TwoDimensionalManager {
|
|
|
123
124
|
charts.forEach((chart) => {
|
|
124
125
|
const chartScales = { key: scales.key, value: chart.data.valueGroup === "secondary" ? scales.valueSecondary : scales.value };
|
|
125
126
|
if (chart.type === 'bar')
|
|
126
|
-
Bar.get().render(block, chartScales, data[dataOptions.dataSource], dataOptions.keyField, margin, keyAxisOrient, chart, blockSize, chartSettings.bar, BarHelper.getBarsInGroupAmount(charts),
|
|
127
|
+
Bar.get().render(block, chartScales, data[dataOptions.dataSource], dataOptions.keyField, margin, keyAxisOrient, chart, blockSize, chartSettings.bar, BarHelper.getBarsInGroupAmount(charts), charts.findIndex(ch => ch.type === 'bar'));
|
|
127
128
|
else if (chart.type === 'line')
|
|
128
129
|
Line.get({ staticSettings: chartSettings.lineLike }).render(block, chartScales, data[dataOptions.dataSource], dataOptions.keyField, margin, keyAxisOrient, chart);
|
|
129
130
|
else if (chart.type === 'area')
|
|
@@ -140,7 +141,7 @@ export class TwoDimensionalManager {
|
|
|
140
141
|
const chartScales = { key: scales.key, value: chart.data.valueGroup === "secondary" ? scales.valueSecondary : scales.value };
|
|
141
142
|
let proms;
|
|
142
143
|
if (chart.type === 'bar') {
|
|
143
|
-
proms = Bar.get().update(block, data[dataOptions.dataSource], chartScales, margin, keyAxisOrient, chart, blockSize, BarHelper.getBarsInGroupAmount(charts), dataOptions.keyField, charts.findIndex(ch => ch.type === 'bar'), chartSettings.bar
|
|
144
|
+
proms = Bar.get().update(block, data[dataOptions.dataSource], chartScales, margin, keyAxisOrient, chart, blockSize, BarHelper.getBarsInGroupAmount(charts), dataOptions.keyField, charts.findIndex(ch => ch.type === 'bar'), chartSettings.bar);
|
|
144
145
|
}
|
|
145
146
|
else if (chart.type === 'line') {
|
|
146
147
|
proms = Line.get({ staticSettings: chartSettings.lineLike }).update(block, chartScales, data[dataOptions.dataSource], dataOptions.keyField, margin, keyAxisOrient, chart);
|
|
@@ -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;
|
|
@@ -307,6 +317,7 @@ interface TwoDimensionalBarLikeChartModel {
|
|
|
307
317
|
export interface TwoDimensionalBarLikeChartViewModel {
|
|
308
318
|
hatch: BarLikeChartHatchOptions;
|
|
309
319
|
borderRadius: BarLikeChartBorderRadius;
|
|
320
|
+
barIndexes: number[];
|
|
310
321
|
}
|
|
311
322
|
interface TwoDimensionalAreaChartModel {
|
|
312
323
|
areaViewOptions: AreaChartViewOptions;
|
|
@@ -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) {
|
|
@@ -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,7 +4,8 @@ import { MdtChartsLineLikeChartShape } from "../../../designer/designerConfig";
|
|
|
4
4
|
export declare const LINE_CHART_DEFAULT_WIDTH = 2;
|
|
5
5
|
export declare function parseShape(chartOrientation: ChartOrientation, configOptions?: MdtChartsLineLikeChartShape): LineLikeChartShapeOptions;
|
|
6
6
|
export declare function parseDashStyles(configOptions?: MdtChartsLineLikeChartDashedStyles): LineLikeChartDashOptions;
|
|
7
|
-
export declare function getBarViewOptions(chart: MdtChartsTwoDimensionalChart, keyAxisOrient: Orient): TwoDimensionalBarLikeChartViewModel;
|
|
7
|
+
export declare function getBarViewOptions(chart: MdtChartsTwoDimensionalChart, keyAxisOrient: Orient, barIndexes: number[]): TwoDimensionalBarLikeChartViewModel;
|
|
8
|
+
export declare function calculateBarIndexes(allCharts: Pick<MdtChartsTwoDimensionalChart, "isSegmented" | "data" | "type">[], currentChart: Pick<MdtChartsTwoDimensionalChart, "isSegmented" | "data" | "type">, currentChartIndex: number): number[];
|
|
8
9
|
export declare function getSegmentedRadiusValues(segmentsLength: number, segmentIndex: number, keyAxisOrient: Orient, defaultRadius: number): BarBorderRadius;
|
|
9
10
|
export declare function getLegendMarkerOptions(chart: MdtChartsTwoDimensionalChart): ChartLegendModel;
|
|
10
11
|
export declare function getLineViewOptions(chart: MdtChartsTwoDimensionalChart): TwoDimensionalChartLegendLineModel;
|
|
@@ -29,7 +29,7 @@ export function parseDashStyles(configOptions) {
|
|
|
29
29
|
gapSize: (_c = configOptions === null || configOptions === void 0 ? void 0 : configOptions.gapSize) !== null && _c !== void 0 ? _c : DEFAULT_GAP_SIZE_PX
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
export function getBarViewOptions(chart, keyAxisOrient) {
|
|
32
|
+
export function getBarViewOptions(chart, keyAxisOrient, barIndexes) {
|
|
33
33
|
var _a, _b, _c, _d, _e, _f;
|
|
34
34
|
const hatch = { on: (_c = (_b = (_a = chart.barStyles) === null || _a === void 0 ? void 0 : _a.hatch) === null || _b === void 0 ? void 0 : _b.on) !== null && _c !== void 0 ? _c : false };
|
|
35
35
|
const defaultRadius = (_f = (_e = (_d = chart.barStyles) === null || _d === void 0 ? void 0 : _d.borderRadius) === null || _e === void 0 ? void 0 : _e.value) !== null && _f !== void 0 ? _f : BAR_CHART_BORDER_RADIUS_DEFAULT;
|
|
@@ -39,7 +39,14 @@ export function getBarViewOptions(chart, keyAxisOrient) {
|
|
|
39
39
|
handle: (valueIndex) => getSegmentedRadiusValues(chart.data.valueFields.length, valueIndex, keyAxisOrient, defaultRadius),
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
|
-
return { hatch, borderRadius };
|
|
42
|
+
return { hatch, borderRadius, barIndexes };
|
|
43
|
+
}
|
|
44
|
+
export function calculateBarIndexes(allCharts, currentChart, currentChartIndex) {
|
|
45
|
+
const prevBarCharts = allCharts.slice(0, currentChartIndex).filter(ch => ch.type === "bar");
|
|
46
|
+
const startBarIndex = prevBarCharts.reduce((acc, ch) => acc + (ch.isSegmented ? 1 : ch.data.valueFields.length), 0);
|
|
47
|
+
if (currentChart.isSegmented)
|
|
48
|
+
return [startBarIndex];
|
|
49
|
+
return currentChart.data.valueFields.map((_, index) => startBarIndex + index);
|
|
43
50
|
}
|
|
44
51
|
function getRadiusValues(defaultRadius) {
|
|
45
52
|
return {
|
|
@@ -3,15 +3,16 @@ import { TwoDimensionalChartStyleModel } from "../chartStyleModel/twoDimensional
|
|
|
3
3
|
import { AxisModel } from "../featuresModel/axisModel";
|
|
4
4
|
import { ScaleAxisRecalcer } from "../featuresModel/scaleModel/scaleAxisRecalcer";
|
|
5
5
|
import { ScaleModel } from "../featuresModel/scaleModel/scaleModel";
|
|
6
|
-
import { getAreaViewOptions, getBarViewOptions, getLegendMarkerOptions, LINE_CHART_DEFAULT_WIDTH, parseDashStyles, parseShape } from "./twoDimensional/styles";
|
|
7
|
-
import { getResolvedTitle } from "../../model/featuresModel/titleModel";
|
|
6
|
+
import { calculateBarIndexes, getAreaViewOptions, getBarViewOptions, getLegendMarkerOptions, LINE_CHART_DEFAULT_WIDTH, parseDashStyles, parseShape } from "./twoDimensional/styles";
|
|
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
|
}
|
|
@@ -98,7 +102,7 @@ export class TwoDimensionalModel {
|
|
|
98
102
|
strokeWidth: (_m = (_l = chart.lineStyles) === null || _l === void 0 ? void 0 : _l.width) !== null && _m !== void 0 ? _m : LINE_CHART_DEFAULT_WIDTH,
|
|
99
103
|
renderForKey: (dataRow, valueFieldName) => dataRow[valueFieldName] !== null && dataRow[valueFieldName] !== undefined
|
|
100
104
|
},
|
|
101
|
-
barViewOptions: getBarViewOptions(chart, keyAxisOrient),
|
|
105
|
+
barViewOptions: getBarViewOptions(chart, keyAxisOrient, calculateBarIndexes(charts, chart, index)),
|
|
102
106
|
legend: getLegendMarkerOptions(chart),
|
|
103
107
|
index,
|
|
104
108
|
valueLabels: {
|
|
@@ -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
|
}
|