mdt-charts 1.30.2 → 1.31.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 +12 -1
- package/lib/engine/features/legend/legendHelper.d.ts +3 -3
- package/lib/engine/features/legend/legendMarkerCreator.d.ts +6 -6
- package/lib/engine/features/legend/legendMarkerCreator.js +2 -2
- package/lib/engine/features/tolltip/tooltip.d.ts +1 -2
- package/lib/engine/features/tolltip/tooltip.js +14 -17
- package/lib/engine/features/tolltip/tooltipDomHelper.d.ts +2 -14
- package/lib/engine/features/tolltip/tooltipDomHelper.js +30 -107
- package/lib/engine/polarNotation/polarManager.js +2 -2
- package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +2 -2
- package/lib/model/dataManagerModel/dataManagerModel.js +1 -1
- package/lib/model/featuresModel/{axisModel.d.ts → axis/axisModel.d.ts} +5 -5
- package/lib/model/featuresModel/{axisModel.js → axis/axisModel.js} +4 -4
- package/lib/model/featuresModel/{axisModelService.d.ts → axis/axisModelService.d.ts} +1 -1
- package/lib/model/featuresModel/otherComponents.js +2 -2
- package/lib/model/featuresModel/tooltipModel/contentByNotations/polarInitialRowsProvider.d.ts +14 -0
- package/lib/model/featuresModel/tooltipModel/contentByNotations/polarInitialRowsProvider.js +16 -0
- package/lib/model/featuresModel/tooltipModel/contentByNotations/tooltipContentInitialRowsProvider.d.ts +13 -0
- package/lib/model/featuresModel/tooltipModel/contentByNotations/tooltipContentInitialRowsProvider.js +1 -0
- package/lib/model/featuresModel/tooltipModel/contentByNotations/twoDimInitialRowsProvider.d.ts +10 -0
- package/lib/model/featuresModel/tooltipModel/contentByNotations/twoDimInitialRowsProvider.js +17 -0
- package/lib/model/featuresModel/tooltipModel/tooltipCanvasModel.d.ts +4 -0
- package/lib/model/featuresModel/{tooltipModel.js → tooltipModel/tooltipCanvasModel.js} +2 -2
- package/lib/model/featuresModel/tooltipModel/tooltipContentModel.d.ts +18 -0
- package/lib/model/featuresModel/tooltipModel/tooltipContentModel.js +87 -0
- package/lib/model/margin/twoDim/twoDimMarginModel.js +1 -1
- package/lib/model/model.d.ts +36 -12
- package/lib/model/notations/polar/modelConstants/polarLegendMarker.d.ts +2 -0
- package/lib/model/notations/polar/modelConstants/polarLegendMarker.js +3 -0
- package/lib/model/notations/polar/polarModel.js +25 -20
- package/lib/model/notations/twoDimensional/styles.d.ts +2 -2
- package/lib/model/notations/twoDimensionalModel.js +15 -3
- package/lib/style/charts-main.css +2 -2
- package/lib/style/charts-main.less +2 -2
- package/package.json +1 -1
- package/lib/model/featuresModel/tooltipModel.d.ts +0 -4
- /package/lib/model/featuresModel/{axisModelService.js → axis/axisModelService.js} +0 -0
package/lib/config/config.d.ts
CHANGED
|
@@ -111,12 +111,16 @@ export interface TooltipOptions {
|
|
|
111
111
|
html?: TooltipHtml;
|
|
112
112
|
aggregator?: TooltipAggregator;
|
|
113
113
|
formatValue?: TooltipFormatValue;
|
|
114
|
+
rows?: {
|
|
115
|
+
filterPredicate?: (row: TooltipPublicDataRow) => boolean;
|
|
116
|
+
sortCompareFn?: (aRow: TooltipPublicDataRow, bRow: TooltipPublicDataRow) => number;
|
|
117
|
+
};
|
|
114
118
|
}
|
|
115
119
|
export declare type TooltipHtml = (dataRow: MdtChartsDataRow) => string;
|
|
116
120
|
export interface TooltipAggregator {
|
|
117
121
|
content: (options: {
|
|
118
122
|
row: MdtChartsDataRow;
|
|
119
|
-
}) => TooltipAggregatorContent;
|
|
123
|
+
}) => TooltipAggregatorContent | TooltipAggregatorContent[];
|
|
120
124
|
position?: "underKey" | "underValues";
|
|
121
125
|
}
|
|
122
126
|
export declare type TooltipAggregatorContent = {
|
|
@@ -131,6 +135,13 @@ export declare type TooltipFormatValue = (params: {
|
|
|
131
135
|
rawValue: number | null | undefined;
|
|
132
136
|
autoFormattedValue: string;
|
|
133
137
|
}) => string;
|
|
138
|
+
export interface TooltipPublicDataRow {
|
|
139
|
+
textContent: {
|
|
140
|
+
caption: string;
|
|
141
|
+
value?: number;
|
|
142
|
+
};
|
|
143
|
+
valueField: MdtChartsValueField;
|
|
144
|
+
}
|
|
134
145
|
export interface AdditionalElements {
|
|
135
146
|
gridLine: GridLineOptions;
|
|
136
147
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ChartNotation, MdtChartsDataRow, MdtChartsDataSource, Size } from "../../../config/config";
|
|
2
2
|
import { LegendItemsDirection } from "../../../model/featuresModel/legendModel/legendCanvasModel";
|
|
3
|
-
import {
|
|
3
|
+
import { ChartLegendMarkerModel, LegendBlockModel, LegendPosition, Orient, PolarOptionsModel, TwoDimensionalOptionsModel } from "../../../model/model";
|
|
4
4
|
import { LegendContentRenderingOptions } from "./legend";
|
|
5
5
|
import { LegendHelperService } from "./legendHelperService";
|
|
6
6
|
export interface LegendCoordinate {
|
|
@@ -9,9 +9,9 @@ export interface LegendCoordinate {
|
|
|
9
9
|
height: number;
|
|
10
10
|
width: number;
|
|
11
11
|
}
|
|
12
|
-
export
|
|
12
|
+
export declare type ChartLegendEngineModel = ChartLegendMarkerModel & {
|
|
13
13
|
textContent: string;
|
|
14
|
-
}
|
|
14
|
+
};
|
|
15
15
|
export declare class LegendHelper {
|
|
16
16
|
static service: LegendHelperService;
|
|
17
17
|
static getLegendItemsContent(options: TwoDimensionalOptionsModel | PolarOptionsModel, data: MdtChartsDataSource): ChartLegendEngineModel[];
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { BaseType, Selection } from "d3-selection";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { ChartLegendMarkerModel } from "../../../model/model";
|
|
3
|
+
declare type MarkerCreationOptions = ChartLegendMarkerModel & {
|
|
4
4
|
color: string;
|
|
5
|
-
}
|
|
5
|
+
};
|
|
6
6
|
declare type MarkerParentSelection = Selection<BaseType, any, BaseType, any>;
|
|
7
7
|
export declare class LegendMarkerCreator {
|
|
8
|
-
create(selection: MarkerParentSelection, options: MarkerCreationOptions): Selection<BaseType,
|
|
8
|
+
create(selection: MarkerParentSelection, options: MarkerCreationOptions): Selection<BaseType, ChartLegendMarkerModel, BaseType, unknown>;
|
|
9
9
|
updateColorForItem(selection: MarkerParentSelection, options: MarkerCreationOptions): void;
|
|
10
10
|
}
|
|
11
11
|
export interface MarkerCreator {
|
|
12
|
-
renderMarker(selection: MarkerParentSelection, color: string): Selection<BaseType,
|
|
12
|
+
renderMarker(selection: MarkerParentSelection, color: string): Selection<BaseType, ChartLegendMarkerModel, BaseType, unknown>;
|
|
13
13
|
updateColors(selection: MarkerParentSelection, color: string): void;
|
|
14
14
|
}
|
|
15
15
|
interface MakerCreatorCustomOptions {
|
|
@@ -17,5 +17,5 @@ interface MakerCreatorCustomOptions {
|
|
|
17
17
|
cssClass: string;
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
-
export declare function getMarkerCreator(options:
|
|
20
|
+
export declare function getMarkerCreator(options: ChartLegendMarkerModel, customOptions?: MakerCreatorCustomOptions): MarkerCreator;
|
|
21
21
|
export {};
|
|
@@ -18,9 +18,9 @@ export function getMarkerCreator(options, customOptions) {
|
|
|
18
18
|
return new BarMarkerCreator(options.barViewOptions);
|
|
19
19
|
if (options.markerShape === "line")
|
|
20
20
|
return new LineMarkerCreator(options.lineViewOptions);
|
|
21
|
-
return new
|
|
21
|
+
return new CircleMarkerCreator((_a = customOptions === null || customOptions === void 0 ? void 0 : customOptions.default) === null || _a === void 0 ? void 0 : _a.cssClass);
|
|
22
22
|
}
|
|
23
|
-
class
|
|
23
|
+
class CircleMarkerCreator {
|
|
24
24
|
constructor(cssClass = Legend.markerCircle) {
|
|
25
25
|
this.cssClass = cssClass;
|
|
26
26
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Model, PolarOptionsModel, TwoDimensionalOptionsModel } from "../../../model/model";
|
|
2
2
|
import { Block } from "../../block/block";
|
|
3
|
-
import { MdtChartsDataSource } from "../../../config/config";
|
|
4
3
|
import { Scales } from "../scale/scale";
|
|
5
4
|
import { TooltipSettings } from "../../../designer/designerConfig";
|
|
6
5
|
export declare class Tooltip {
|
|
@@ -9,7 +8,7 @@ export declare class Tooltip {
|
|
|
9
8
|
static readonly tooltipWrapperClass = "mdt-charts-tooltip-wrapper";
|
|
10
9
|
static readonly tooltipContentClass = "mdt-charts-tooltip-content";
|
|
11
10
|
static readonly tooltipArrowClass = "mdt-charts-tooltip-arrow";
|
|
12
|
-
static render(block: Block, model: Model<TwoDimensionalOptionsModel | PolarOptionsModel>,
|
|
11
|
+
static render(block: Block, model: Model<TwoDimensionalOptionsModel | PolarOptionsModel>, tooltipOptions: TooltipSettings, scales?: Scales): void;
|
|
13
12
|
static hide(block: Block): void;
|
|
14
13
|
private static renderTooltipFor2DCharts;
|
|
15
14
|
private static renderTooltipForPolar;
|
|
@@ -13,23 +13,20 @@ import { NewTooltip } from "./newTooltip/newTooltip";
|
|
|
13
13
|
import { MarkDot } from "../../../engine/features/markDots/markDot";
|
|
14
14
|
import { DonutThicknessCalculator } from "../../../model/notations/polar/donut/donutThicknessService";
|
|
15
15
|
export class Tooltip {
|
|
16
|
-
static render(block, model,
|
|
16
|
+
static render(block, model, tooltipOptions, scales) {
|
|
17
17
|
TooltipComponentsManager.renderTooltipWrapper(block);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
else if (model.options.type === "polar") {
|
|
24
|
-
this.renderTooltipForPolar(block, model.options, data, model.blockCanvas.size, model.chartBlock.margin, DonutThicknessCalculator.getThickness(model.options.chartCanvas, model.blockCanvas.size, model.chartBlock.margin), model.otherComponents.tooltipBlock);
|
|
25
|
-
}
|
|
18
|
+
if (model.options.type === "2d") {
|
|
19
|
+
this.renderTooltipFor2DCharts(block, model.blockCanvas.size, model.chartBlock.margin, scales, model.options, tooltipOptions);
|
|
20
|
+
}
|
|
21
|
+
else if (model.options.type === "polar") {
|
|
22
|
+
this.renderTooltipForPolar(block, model.options, model.blockCanvas.size, model.chartBlock.margin, DonutThicknessCalculator.getThickness(model.options.chartCanvas, model.blockCanvas.size, model.chartBlock.margin), model.otherComponents.tooltipBlock);
|
|
26
23
|
}
|
|
27
24
|
}
|
|
28
25
|
static hide(block) {
|
|
29
26
|
TooltipComponentsManager.hideComponent(block.getWrapper().select(`.${this.tooltipBlockClass}`));
|
|
30
27
|
TooltipComponentsManager.hideComponent(block.getSvg().select(`.${this.tooltipLineClass}`));
|
|
31
28
|
}
|
|
32
|
-
static renderTooltipFor2DCharts(block,
|
|
29
|
+
static renderTooltipFor2DCharts(block, blockSize, margin, scales, options, tooltipOptions) {
|
|
33
30
|
if (scales.key.domain().length === 0)
|
|
34
31
|
return;
|
|
35
32
|
const tooltipParams = {
|
|
@@ -45,15 +42,15 @@ export class Tooltip {
|
|
|
45
42
|
tooltipSettings: tooltipOptions,
|
|
46
43
|
tooltipOptions: options.tooltip
|
|
47
44
|
};
|
|
48
|
-
this.renderLineTooltip(block,
|
|
45
|
+
this.renderLineTooltip(block, tooltipParams);
|
|
49
46
|
}
|
|
50
|
-
static renderTooltipForPolar(block, options,
|
|
47
|
+
static renderTooltipForPolar(block, options, blockSize, margin, chartThickness, tooltipOptions) {
|
|
51
48
|
const attrTransform = block.getSvg().select(`.${Donut.donutBlockClass}`).attr("transform");
|
|
52
49
|
const translateNums = Helper.getTranslateNumbers(attrTransform);
|
|
53
50
|
const arcItems = Donut.getAllArcGroups(block);
|
|
54
|
-
this.renderTooltipForDonut(block, arcItems,
|
|
51
|
+
this.renderTooltipForDonut(block, arcItems, options.data, blockSize, margin, chartThickness, tooltipOptions, options.tooltip, { x: translateNums[0], y: translateNums[1] });
|
|
55
52
|
}
|
|
56
|
-
static renderLineTooltip(block,
|
|
53
|
+
static renderLineTooltip(block, args) {
|
|
57
54
|
const tooltipBlock = TooltipComponentsManager.renderTooltipBlock(block);
|
|
58
55
|
const tooltipContent = TooltipComponentsManager.renderTooltipContentBlock(tooltipBlock);
|
|
59
56
|
const tooltipLine = TooltipComponentsManager.renderTooltipLine(block);
|
|
@@ -69,7 +66,7 @@ export class Tooltip {
|
|
|
69
66
|
if (!currentKey || currentKey !== keyValue) {
|
|
70
67
|
TooltipComponentsManager.showComponent(tooltipBlock.getEl());
|
|
71
68
|
if (args.type === "2d")
|
|
72
|
-
TooltipDomHelper.
|
|
69
|
+
TooltipDomHelper.fillContent(tooltipContent, keyValue, args.tooltipOptions);
|
|
73
70
|
if (args.tooltipSettings.position === "fixed") {
|
|
74
71
|
const tooltipCoordinate = TooltipHelper.getTooltipFixedCoordinate(args.scales.key, args.margin, keyValue, block.getSvg().node().getBoundingClientRect(), tooltipContent.node().getBoundingClientRect(), args.keyAxisOrient, window.innerWidth, window.innerHeight);
|
|
75
72
|
TooltipComponentsManager.setLineTooltipCoordinate(tooltipBlock, tooltipCoordinate, args.chartOrientation, block.transitionManager.durations.tooltipSlide);
|
|
@@ -110,7 +107,7 @@ export class Tooltip {
|
|
|
110
107
|
currentKey = null;
|
|
111
108
|
});
|
|
112
109
|
}
|
|
113
|
-
static renderTooltipForDonut(block, elements,
|
|
110
|
+
static renderTooltipForDonut(block, elements, dataOptions, blockSize, margin, donutThickness, tooltipSettings, tooltipOptions, translate) {
|
|
114
111
|
const tooltipBlock = TooltipComponentsManager.renderTooltipBlock(block);
|
|
115
112
|
const tooltipContent = TooltipComponentsManager.renderTooltipContentBlock(tooltipBlock);
|
|
116
113
|
let tooltipArrow;
|
|
@@ -127,7 +124,7 @@ export class Tooltip {
|
|
|
127
124
|
}
|
|
128
125
|
elements.on("mouseover", function (e, dataRow) {
|
|
129
126
|
TooltipComponentsManager.showComponent(tooltipBlock.getEl());
|
|
130
|
-
TooltipDomHelper.
|
|
127
|
+
TooltipDomHelper.fillContent(tooltipContent, dataRow.data[dataOptions.keyField.name], tooltipOptions);
|
|
131
128
|
if (tooltipSettings.position === "fixed") {
|
|
132
129
|
const coordinatePointer = TooltipDomHelper.getRecalcedCoordinateByArrow(DonutHelper.getArcCentroid(blockSize, margin, dataRow, donutThickness), tooltipBlock.getEl(), blockSize, tooltipArrow, translate.x, translate.y);
|
|
133
130
|
coordinatePointer[0] = coordinatePointer[0] + translate.x;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Selection, BaseType } from "d3-selection";
|
|
2
|
-
import {
|
|
3
|
-
import { OptionsModelData, PolarChartModel, TwoDimensionalChartModel } from "../../../model/model";
|
|
2
|
+
import { TooltipBasicModel } from "../../../model/model";
|
|
4
3
|
import { Size } from "../../../config/config";
|
|
5
4
|
export interface TooltipLineAttributes {
|
|
6
5
|
x1: number;
|
|
@@ -14,20 +13,9 @@ export declare const TOOLTIP_ARROW_PADDING_X: number;
|
|
|
14
13
|
export declare const TOOLTIP_ARROW_PADDING_Y = 13;
|
|
15
14
|
export declare class TooltipDomHelper {
|
|
16
15
|
private static readonly groupClass;
|
|
17
|
-
private static readonly headClass;
|
|
18
16
|
private static readonly textItemClass;
|
|
19
17
|
private static readonly tooltipLegendDefaultMarker;
|
|
20
|
-
static
|
|
21
|
-
static fillForPolarChart(contentBlock: Selection<HTMLElement, unknown, BaseType, unknown>, chart: PolarChartModel, data: MdtChartsDataSource, dataOptions: OptionsModelData, keyValue: string, markColor: string, tooltipOptions?: TooltipOptions): void;
|
|
18
|
+
static fillContent(contentBlock: Selection<HTMLElement, unknown, BaseType, unknown>, keyValue: string, tooltipOptions: TooltipBasicModel): void;
|
|
22
19
|
static getRecalcedCoordinateByArrow(coordinate: [number, number], tooltipBlock: Selection<HTMLElement, unknown, HTMLElement, any>, blockSize: Size, tooltipArrow: Selection<BaseType, unknown, HTMLElement, any>, translateX?: number, translateY?: number): [number, number];
|
|
23
|
-
private static renderHead;
|
|
24
|
-
private static fillValuesContent;
|
|
25
|
-
private static getTooltipItemHtml;
|
|
26
|
-
private static getTooltipContentItemHtml;
|
|
27
20
|
private static setTooltipArrowCoordinate;
|
|
28
|
-
private static fillContentByFunction;
|
|
29
|
-
private static setWhiteSpaceForTextBlocks;
|
|
30
|
-
private static getMarkerCreator;
|
|
31
|
-
private static addAggregatorTooltipItem;
|
|
32
|
-
private static fillCharts;
|
|
33
21
|
}
|
|
@@ -1,34 +1,41 @@
|
|
|
1
|
-
import { ValueFormatter } from "../../valueFormatter";
|
|
2
1
|
import { TooltipHelper } from "./tooltipHelper";
|
|
3
|
-
import { Helper } from "../../helpers/helper";
|
|
4
2
|
import { getMarkerCreator } from "../legend/legendMarkerCreator";
|
|
5
3
|
export const ARROW_SIZE = 20;
|
|
6
4
|
export const ARROW_DEFAULT_POSITION = 9;
|
|
7
5
|
export const TOOLTIP_ARROW_PADDING_X = ARROW_DEFAULT_POSITION - (ARROW_SIZE * Math.sqrt(2) - ARROW_SIZE) / 2 + 14;
|
|
8
6
|
export const TOOLTIP_ARROW_PADDING_Y = 13;
|
|
9
7
|
export class TooltipDomHelper {
|
|
10
|
-
static
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
static fillContent(contentBlock, keyValue, tooltipOptions) {
|
|
9
|
+
const content = tooltipOptions.getContent(keyValue);
|
|
10
|
+
contentBlock.html("");
|
|
11
|
+
if (content.type === "html") {
|
|
12
|
+
contentBlock.html(content.htmlContent);
|
|
13
|
+
contentBlock.selectAll(`.${this.textItemClass}`).style("white-space", "pre-wrap");
|
|
14
|
+
contentBlock.selectAll(".tooltip-text-item").style("display", "block");
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
content.rows.forEach((row) => {
|
|
18
|
+
var _a;
|
|
19
|
+
const group = contentBlock.append("div").attr("class", this.groupClass);
|
|
20
|
+
if ((_a = row.wrapper) === null || _a === void 0 ? void 0 : _a.cssClassName) {
|
|
21
|
+
group.classed(row.wrapper.cssClassName, true);
|
|
22
|
+
}
|
|
23
|
+
if (row.marker) {
|
|
24
|
+
const colorBlock = group.append("div").attr("class", "tooltip-color");
|
|
25
|
+
getMarkerCreator(row.marker, {
|
|
26
|
+
default: { cssClass: TooltipDomHelper.tooltipLegendDefaultMarker }
|
|
27
|
+
}).renderMarker(colorBlock, row.marker.color);
|
|
28
|
+
}
|
|
29
|
+
const rowTextBlock = group
|
|
30
|
+
.append("div")
|
|
31
|
+
.attr("class", "tooltip-texts")
|
|
32
|
+
.append("div")
|
|
33
|
+
.attr("class", this.textItemClass);
|
|
34
|
+
rowTextBlock.append("span").attr("class", "tooltip-field-title").text(row.textContent.caption);
|
|
35
|
+
if (row.textContent.value)
|
|
36
|
+
rowTextBlock.append("span").attr("class", "tooltip-field-value").text(row.textContent.value);
|
|
19
37
|
});
|
|
20
|
-
}
|
|
21
|
-
this.fillCharts(contentBlock, chartDataRows, data, dataOptions, keyValue, tooltipOptions);
|
|
22
|
-
}
|
|
23
|
-
static fillForPolarChart(contentBlock, chart, data, dataOptions, keyValue, markColor, tooltipOptions) {
|
|
24
|
-
const chartDataRows = [
|
|
25
|
-
{
|
|
26
|
-
field: chart.data.valueField,
|
|
27
|
-
markColor,
|
|
28
|
-
markerCreator: this.getMarkerCreator(chart.legend)
|
|
29
|
-
}
|
|
30
|
-
];
|
|
31
|
-
this.fillCharts(contentBlock, chartDataRows, data, dataOptions, keyValue, tooltipOptions);
|
|
38
|
+
}
|
|
32
39
|
}
|
|
33
40
|
static getRecalcedCoordinateByArrow(coordinate, tooltipBlock, blockSize, tooltipArrow, translateX = 0, translateY = 0) {
|
|
34
41
|
const tooltipBlockNode = tooltipBlock.node();
|
|
@@ -40,97 +47,13 @@ export class TooltipDomHelper {
|
|
|
40
47
|
coordinate[1] - TOOLTIP_ARROW_PADDING_Y - tooltipBlockNode.getBoundingClientRect().height - verticalPad
|
|
41
48
|
];
|
|
42
49
|
}
|
|
43
|
-
static renderHead(contentBlock, keyValue) {
|
|
44
|
-
contentBlock.append("div").attr("class", `${this.groupClass} ${this.headClass}`).text(keyValue);
|
|
45
|
-
}
|
|
46
|
-
static fillValuesContent(contentBlock, { markColor, tooltipHtml, markerCreator }) {
|
|
47
|
-
const group = contentBlock.append("div").attr("class", this.groupClass);
|
|
48
|
-
if (markColor) {
|
|
49
|
-
const colorBlock = group.append("div").attr("class", "tooltip-color");
|
|
50
|
-
markerCreator === null || markerCreator === void 0 ? void 0 : markerCreator.renderMarker(colorBlock, markColor);
|
|
51
|
-
}
|
|
52
|
-
group
|
|
53
|
-
.append("div")
|
|
54
|
-
.attr("class", "tooltip-texts")
|
|
55
|
-
.append("div")
|
|
56
|
-
.attr("class", this.textItemClass)
|
|
57
|
-
.html(tooltipHtml);
|
|
58
|
-
}
|
|
59
|
-
static getTooltipItemHtml(row, valueField, tooltipOptions) {
|
|
60
|
-
const formattedValueByDefault = ValueFormatter.formatField(valueField.format, row[valueField.name]);
|
|
61
|
-
const formattedValue = (tooltipOptions === null || tooltipOptions === void 0 ? void 0 : tooltipOptions.formatValue)
|
|
62
|
-
? tooltipOptions.formatValue({
|
|
63
|
-
rawValue: row[valueField.name],
|
|
64
|
-
autoFormattedValue: formattedValueByDefault
|
|
65
|
-
})
|
|
66
|
-
: formattedValueByDefault;
|
|
67
|
-
const text = this.getTooltipContentItemHtml(valueField.title, formattedValue);
|
|
68
|
-
return text;
|
|
69
|
-
}
|
|
70
|
-
static getTooltipContentItemHtml(fieldTitle, fieldValue) {
|
|
71
|
-
return `<span class="tooltip-field-title">${fieldTitle}</span>
|
|
72
|
-
<span class="tooltip-field-value">${fieldValue}</span>`;
|
|
73
|
-
}
|
|
74
50
|
static setTooltipArrowCoordinate(tooltipArrow, horizontalPad) {
|
|
75
51
|
if (horizontalPad !== 0)
|
|
76
52
|
tooltipArrow.style("left", `${ARROW_DEFAULT_POSITION + Math.floor(horizontalPad)}px`);
|
|
77
53
|
else
|
|
78
54
|
tooltipArrow.style("left", `${ARROW_DEFAULT_POSITION}px`);
|
|
79
55
|
}
|
|
80
|
-
static fillContentByFunction(contentBlock, data, dataOptions, keyValue, htmlHandler) {
|
|
81
|
-
const row = Helper.getRowsByKeys([keyValue], dataOptions.keyField.name, data[dataOptions.dataSource])[0];
|
|
82
|
-
contentBlock.html(htmlHandler(row));
|
|
83
|
-
this.setWhiteSpaceForTextBlocks(contentBlock);
|
|
84
|
-
contentBlock.selectAll(".tooltip-text-item").style("display", "block");
|
|
85
|
-
}
|
|
86
|
-
static setWhiteSpaceForTextBlocks(contentBlock) {
|
|
87
|
-
contentBlock.selectAll(`.${this.textItemClass}`).style("white-space", "pre-wrap");
|
|
88
|
-
}
|
|
89
|
-
static getMarkerCreator(options) {
|
|
90
|
-
return getMarkerCreator(options, { default: { cssClass: TooltipDomHelper.tooltipLegendDefaultMarker } });
|
|
91
|
-
}
|
|
92
|
-
static addAggregatorTooltipItem(tooltipOptions, data, tooltipItems) {
|
|
93
|
-
if (tooltipOptions === null || tooltipOptions === void 0 ? void 0 : tooltipOptions.aggregator) {
|
|
94
|
-
const aggregatorContent = tooltipOptions.aggregator.content({ row: data });
|
|
95
|
-
const aggregatorHtml = aggregatorContent.type === "plainText"
|
|
96
|
-
? aggregatorContent.textContent
|
|
97
|
-
: this.getTooltipContentItemHtml(aggregatorContent.caption, aggregatorContent.value);
|
|
98
|
-
const tooltipAggregatorItem = {
|
|
99
|
-
markColor: undefined,
|
|
100
|
-
tooltipHtml: aggregatorHtml,
|
|
101
|
-
markerCreator: undefined
|
|
102
|
-
};
|
|
103
|
-
if (tooltipOptions.aggregator.position === "underValues")
|
|
104
|
-
tooltipItems.push(tooltipAggregatorItem);
|
|
105
|
-
else
|
|
106
|
-
tooltipItems.unshift(tooltipAggregatorItem);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
static fillCharts(contentBlock, chartDataRows, data, dataOptions, keyValue, tooltipOptions) {
|
|
110
|
-
const row = data[dataOptions.dataSource].find((d) => d[dataOptions.keyField.name] === keyValue);
|
|
111
|
-
contentBlock.html("");
|
|
112
|
-
if (!(tooltipOptions === null || tooltipOptions === void 0 ? void 0 : tooltipOptions.html)) {
|
|
113
|
-
const tooltipItems = [];
|
|
114
|
-
this.renderHead(contentBlock, keyValue);
|
|
115
|
-
chartDataRows.forEach((dataRow) => {
|
|
116
|
-
const html = this.getTooltipItemHtml(row, dataRow.field, tooltipOptions);
|
|
117
|
-
tooltipItems.push({
|
|
118
|
-
markColor: dataRow.markColor,
|
|
119
|
-
tooltipHtml: html,
|
|
120
|
-
markerCreator: dataRow.markerCreator
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
this.addAggregatorTooltipItem(tooltipOptions, row, tooltipItems);
|
|
124
|
-
tooltipItems.forEach((item) => {
|
|
125
|
-
this.fillValuesContent(contentBlock, item);
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
this.fillContentByFunction(contentBlock, data, dataOptions, keyValue, tooltipOptions.html);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
56
|
}
|
|
133
57
|
TooltipDomHelper.groupClass = "tooltip-group";
|
|
134
|
-
TooltipDomHelper.headClass = "tooltip-head";
|
|
135
58
|
TooltipDomHelper.textItemClass = "tooltip-text-item";
|
|
136
59
|
TooltipDomHelper.tooltipLegendDefaultMarker = "tooltip-circle";
|
|
@@ -12,7 +12,7 @@ export class PolarManager {
|
|
|
12
12
|
this.renderCharts(engine.block, options.charts, engine.data, options.data.dataSource, model.chartBlock.margin, model.blockCanvas.size, options.chartCanvas);
|
|
13
13
|
Title.render(engine.block, options.title, model.otherComponents.titleBlock, model.blockCanvas.size);
|
|
14
14
|
Legend.get().render(engine.block, engine.data, options, model);
|
|
15
|
-
Tooltip.render(engine.block, model,
|
|
15
|
+
Tooltip.render(engine.block, model, model.otherComponents.tooltipBlock);
|
|
16
16
|
engine.block.filterEventManager.setListenerPolar(model.chartBlock.margin, model.blockCanvas.size, options);
|
|
17
17
|
if (model.dataSettings.scope.hidedRecordsAmount !== 0)
|
|
18
18
|
RecordOverflowAlertCore.render(engine.block, options.recordOverflowAlert);
|
|
@@ -32,7 +32,7 @@ export class PolarManager {
|
|
|
32
32
|
Tooltip.hide(block);
|
|
33
33
|
const options = model.options;
|
|
34
34
|
Donut.update(block, data[options.data.dataSource], model.chartBlock.margin, options.charts[0], model.blockCanvas.size, options.chartCanvas, options.data.keyField.name).then(() => {
|
|
35
|
-
Tooltip.render(block, model,
|
|
35
|
+
Tooltip.render(block, model, model.otherComponents.tooltipBlock);
|
|
36
36
|
block.filterEventManager.setListenerPolar(model.chartBlock.margin, model.blockCanvas.size, options);
|
|
37
37
|
});
|
|
38
38
|
Aggregator.update(block, options.charts[0].data.valueField, options.chartCanvas.aggregator);
|
|
@@ -44,7 +44,7 @@ export class TwoDimensionalManager {
|
|
|
44
44
|
engine.block.filterEventManager.event2DUpdate(options);
|
|
45
45
|
Title.render(engine.block, options.title, model.otherComponents.titleBlock, model.blockCanvas.size);
|
|
46
46
|
Legend.get().render(engine.block, engine.data, options, model);
|
|
47
|
-
Tooltip.render(engine.block, model,
|
|
47
|
+
Tooltip.render(engine.block, model, model.otherComponents.tooltipBlock, scales);
|
|
48
48
|
if (model.dataSettings.scope.hidedRecordsAmount !== 0)
|
|
49
49
|
RecordOverflowAlertCore.render(engine.block, options.recordOverflowAlert);
|
|
50
50
|
engine.block.getSvg().on("click", (e) => {
|
|
@@ -87,7 +87,7 @@ export class TwoDimensionalManager {
|
|
|
87
87
|
Promise.all(promises).then(() => {
|
|
88
88
|
block.filterEventManager.event2DUpdate(options);
|
|
89
89
|
block.filterEventManager.registerEventFor2D(scales.key, model.chartBlock.margin, model.blockCanvas.size, options);
|
|
90
|
-
Tooltip.render(block, model,
|
|
90
|
+
Tooltip.render(block, model, model.otherComponents.tooltipBlock, scales);
|
|
91
91
|
});
|
|
92
92
|
RecordOverflowAlertCore.update(block, options.recordOverflowAlert);
|
|
93
93
|
if (this.canvasValueLabels)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AxisModel } from "../featuresModel/axisModel";
|
|
1
|
+
import { AxisModel } from "../featuresModel/axis/axisModel";
|
|
2
2
|
import { LegendCanvasModel } from "../featuresModel/legendModel/legendCanvasModel";
|
|
3
3
|
import { ModelHelper } from "../helpers/modelHelper";
|
|
4
4
|
import { MIN_DONUT_BLOCK_SIZE, PolarModel } from "../notations/polar/polarModel";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { AxisPosition, ChartOrientation, MdtChartsDataSource, NumberAxisOptions, AxisLabelPosition, MdtChartsTwoDimensionalOptions, DiscreteAxisOptions, NumberSecondaryAxisOptions, AxisLabelFormatter } from "
|
|
2
|
-
import { AxisModelOptions, Orient, ScaleValueModel, TickAmountPolicy } from "
|
|
3
|
-
import { AxisType } from "
|
|
4
|
-
import { AxisLabelCanvas, TooltipSettings } from "
|
|
5
|
-
import { CanvasModel } from "
|
|
1
|
+
import { AxisPosition, ChartOrientation, MdtChartsDataSource, NumberAxisOptions, AxisLabelPosition, MdtChartsTwoDimensionalOptions, DiscreteAxisOptions, NumberSecondaryAxisOptions, AxisLabelFormatter } from "../../../config/config";
|
|
2
|
+
import { AxisModelOptions, Orient, ScaleValueModel, TickAmountPolicy } from "../../model";
|
|
3
|
+
import { AxisType } from "../../modelBuilder";
|
|
4
|
+
import { AxisLabelCanvas, TooltipSettings } from "../../../designer/designerConfig";
|
|
5
|
+
import { CanvasModel } from "../../modelInstance/canvasModel/canvasModel";
|
|
6
6
|
export interface LabelSize {
|
|
7
7
|
width: number;
|
|
8
8
|
height: number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ModelHelper } from "
|
|
2
|
-
import { AxisType } from "
|
|
3
|
-
import { DataManagerModel } from "
|
|
4
|
-
import { TwoDimensionalModel } from "
|
|
1
|
+
import { ModelHelper } from "../../helpers/modelHelper";
|
|
2
|
+
import { AxisType } from "../../modelBuilder";
|
|
3
|
+
import { DataManagerModel } from "../../dataManagerModel/dataManagerModel";
|
|
4
|
+
import { TwoDimensionalModel } from "../../notations/twoDimensionalModel";
|
|
5
5
|
import { AxisModelService, AxisModelTickCalculator, showAllTicks } from "./axisModelService";
|
|
6
6
|
export const MINIMAL_VERTICAL_STEP_SIZE = 60;
|
|
7
7
|
export const MINIMAL_HORIZONTAL_STEP_SIZE = 100;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AxisLabelPosition, MdtChartsDataRow, MdtChartsShowAxisLabelRule, ShowTickFn } from "
|
|
1
|
+
import { AxisLabelPosition, MdtChartsDataRow, MdtChartsShowAxisLabelRule, ShowTickFn } from "../../../config/config";
|
|
2
2
|
export declare const showAllTicks: ShowTickFn;
|
|
3
3
|
export declare class AxisModelService {
|
|
4
4
|
getKeyAxisLabelPosition(chartBlockWidth: number, scopedDataLength: number, positionFromConfig?: AxisLabelPosition): AxisLabelPosition;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LegendModel } from "./legendModel/legendModel";
|
|
2
2
|
import { TitleModel } from "./titleModel";
|
|
3
|
-
import {
|
|
3
|
+
import { TooltipCanvasModel } from "./tooltipModel/tooltipCanvasModel";
|
|
4
4
|
export class OtherComponentsModel {
|
|
5
5
|
static getOtherComponentsModel(dependencies, modelInstance) {
|
|
6
6
|
const canvasModel = modelInstance.canvasModel;
|
|
@@ -8,7 +8,7 @@ export class OtherComponentsModel {
|
|
|
8
8
|
return {
|
|
9
9
|
legendBlock: LegendModel.getBaseLegendBlockModel(canvasModel, dependencies.legendConfig),
|
|
10
10
|
titleBlock: canvasModel.titleCanvas.getModel(),
|
|
11
|
-
tooltipBlock:
|
|
11
|
+
tooltipBlock: TooltipCanvasModel.getCanvasModel(dependencies.elementsOptions.tooltip)
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MdtChartsDataRow } from "../../../../config/config";
|
|
2
|
+
import { ValueField } from "../../../model";
|
|
3
|
+
import { TooltipContentInitialRow, TooltipContentInitialRowsProvider, TooltipContentInitialRowsProviderContext } from "./tooltipContentInitialRowsProvider";
|
|
4
|
+
export interface PolarInitialRowsProviderOptions {
|
|
5
|
+
valueField: ValueField;
|
|
6
|
+
datasource: MdtChartsDataRow[];
|
|
7
|
+
chartColors: string[];
|
|
8
|
+
keyFieldName: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class PolarInitialRowsProvider implements TooltipContentInitialRowsProvider {
|
|
11
|
+
private readonly options;
|
|
12
|
+
constructor(options: PolarInitialRowsProviderOptions);
|
|
13
|
+
getInitialRows(context: TooltipContentInitialRowsProviderContext): TooltipContentInitialRow[];
|
|
14
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { POLAR_LEGEND_MARKER } from "../../../notations/polar/modelConstants/polarLegendMarker";
|
|
2
|
+
export class PolarInitialRowsProvider {
|
|
3
|
+
constructor(options) {
|
|
4
|
+
this.options = options;
|
|
5
|
+
}
|
|
6
|
+
getInitialRows(context) {
|
|
7
|
+
const indexOfCurrentDataRow = this.options.datasource.findIndex((row) => row[this.options.keyFieldName] === context.keyFieldValue);
|
|
8
|
+
const markerColor = this.options.chartColors[indexOfCurrentDataRow];
|
|
9
|
+
return [
|
|
10
|
+
{
|
|
11
|
+
marker: Object.assign(Object.assign({}, POLAR_LEGEND_MARKER), { color: markerColor }),
|
|
12
|
+
valueField: this.options.valueField
|
|
13
|
+
}
|
|
14
|
+
];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { MdtChartsDataRow } from "../../../../config/config";
|
|
2
|
+
import { TooltipMarkerModel, ValueField } from "../../../model";
|
|
3
|
+
export interface TooltipContentInitialRow {
|
|
4
|
+
marker: TooltipMarkerModel;
|
|
5
|
+
valueField: ValueField;
|
|
6
|
+
}
|
|
7
|
+
export interface TooltipContentInitialRowsProviderContext {
|
|
8
|
+
keyFieldValue: string;
|
|
9
|
+
currentDataRow: MdtChartsDataRow;
|
|
10
|
+
}
|
|
11
|
+
export interface TooltipContentInitialRowsProvider {
|
|
12
|
+
getInitialRows(context: TooltipContentInitialRowsProviderContext): TooltipContentInitialRow[];
|
|
13
|
+
}
|
package/lib/model/featuresModel/tooltipModel/contentByNotations/tooltipContentInitialRowsProvider.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/model/featuresModel/tooltipModel/contentByNotations/twoDimInitialRowsProvider.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TwoDimensionalChartModel } from "../../../model";
|
|
2
|
+
import { TooltipContentInitialRow, TooltipContentInitialRowsProvider } from "./tooltipContentInitialRowsProvider";
|
|
3
|
+
export interface TwoDimInitialRowsProviderOptions {
|
|
4
|
+
chartsInfo: Pick<TwoDimensionalChartModel, "data" | "style" | "legend">[];
|
|
5
|
+
}
|
|
6
|
+
export declare class TwoDimInitialRowsProvider implements TooltipContentInitialRowsProvider {
|
|
7
|
+
private readonly options;
|
|
8
|
+
constructor(options: TwoDimInitialRowsProviderOptions);
|
|
9
|
+
getInitialRows(): TooltipContentInitialRow[];
|
|
10
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export class TwoDimInitialRowsProvider {
|
|
2
|
+
constructor(options) {
|
|
3
|
+
this.options = options;
|
|
4
|
+
}
|
|
5
|
+
getInitialRows() {
|
|
6
|
+
const initialRows = [];
|
|
7
|
+
this.options.chartsInfo.forEach((chart) => {
|
|
8
|
+
chart.data.valueFields.forEach((valueField, valueFieldIndex) => {
|
|
9
|
+
initialRows.push({
|
|
10
|
+
marker: Object.assign({ color: chart.style.elementColors[valueFieldIndex % chart.style.elementColors.length] }, chart.legend),
|
|
11
|
+
valueField
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
return initialRows;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { MdtChartsDataRow, TooltipOptions } from "../../../config/config";
|
|
2
|
+
import { Formatter } from "../../../main";
|
|
3
|
+
import { TooltipContent } from "../../model";
|
|
4
|
+
import { TooltipContentInitialRowsProvider } from "./contentByNotations/tooltipContentInitialRowsProvider";
|
|
5
|
+
export interface TooltipContentGeneratorOptions {
|
|
6
|
+
datasource: MdtChartsDataRow[];
|
|
7
|
+
initialRowsProvider: TooltipContentInitialRowsProvider;
|
|
8
|
+
publicOptions?: TooltipOptions;
|
|
9
|
+
keyFieldName: string;
|
|
10
|
+
valueGlobalFormatter: Formatter;
|
|
11
|
+
}
|
|
12
|
+
export declare class TwoDimTooltipContentGenerator {
|
|
13
|
+
private readonly options;
|
|
14
|
+
private readonly headWrapperCssClassName;
|
|
15
|
+
constructor(options: TooltipContentGeneratorOptions);
|
|
16
|
+
generateContent(keyFieldValue: string): TooltipContent;
|
|
17
|
+
private createRows;
|
|
18
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
export class TwoDimTooltipContentGenerator {
|
|
2
|
+
constructor(options) {
|
|
3
|
+
this.options = options;
|
|
4
|
+
this.headWrapperCssClassName = "tooltip-head";
|
|
5
|
+
}
|
|
6
|
+
generateContent(keyFieldValue) {
|
|
7
|
+
var _a;
|
|
8
|
+
const currentDataRow = this.options.datasource.find((r) => r[this.options.keyFieldName] === keyFieldValue);
|
|
9
|
+
if ((_a = this.options.publicOptions) === null || _a === void 0 ? void 0 : _a.html)
|
|
10
|
+
return {
|
|
11
|
+
type: "html",
|
|
12
|
+
htmlContent: this.options.publicOptions.html(currentDataRow)
|
|
13
|
+
};
|
|
14
|
+
return this.createRows(keyFieldValue, currentDataRow);
|
|
15
|
+
}
|
|
16
|
+
createRows(keyFieldValue, currentDataRow) {
|
|
17
|
+
var _a, _b, _c, _d, _e;
|
|
18
|
+
let contentRows = [];
|
|
19
|
+
let initialRows = this.options.initialRowsProvider
|
|
20
|
+
.getInitialRows({ keyFieldValue, currentDataRow })
|
|
21
|
+
.map((initialRow) => {
|
|
22
|
+
return {
|
|
23
|
+
marker: initialRow.marker,
|
|
24
|
+
textContent: {
|
|
25
|
+
caption: initialRow.valueField.title,
|
|
26
|
+
value: currentDataRow[initialRow.valueField.name]
|
|
27
|
+
},
|
|
28
|
+
valueField: initialRow.valueField
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
initialRows = ((_b = (_a = this.options.publicOptions) === null || _a === void 0 ? void 0 : _a.rows) === null || _b === void 0 ? void 0 : _b.filterPredicate)
|
|
32
|
+
? initialRows.filter((row) => this.options.publicOptions.rows.filterPredicate(row))
|
|
33
|
+
: initialRows;
|
|
34
|
+
if ((_d = (_c = this.options.publicOptions) === null || _c === void 0 ? void 0 : _c.rows) === null || _d === void 0 ? void 0 : _d.sortCompareFn)
|
|
35
|
+
initialRows.sort(this.options.publicOptions.rows.sortCompareFn);
|
|
36
|
+
initialRows.forEach((initialRow) => {
|
|
37
|
+
var _a;
|
|
38
|
+
const formattedValueByDefault = this.options.valueGlobalFormatter(initialRow.textContent.value, {
|
|
39
|
+
type: initialRow.valueField.format
|
|
40
|
+
});
|
|
41
|
+
const formattedValue = ((_a = this.options.publicOptions) === null || _a === void 0 ? void 0 : _a.formatValue)
|
|
42
|
+
? this.options.publicOptions.formatValue({
|
|
43
|
+
rawValue: currentDataRow[initialRow.valueField.name],
|
|
44
|
+
autoFormattedValue: formattedValueByDefault
|
|
45
|
+
})
|
|
46
|
+
: formattedValueByDefault;
|
|
47
|
+
contentRows.push({
|
|
48
|
+
marker: initialRow.marker,
|
|
49
|
+
textContent: {
|
|
50
|
+
caption: initialRow.textContent.caption,
|
|
51
|
+
value: formattedValue
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
if ((_e = this.options.publicOptions) === null || _e === void 0 ? void 0 : _e.aggregator) {
|
|
56
|
+
const contentResult = this.options.publicOptions.aggregator.content({ row: currentDataRow });
|
|
57
|
+
const aggregatorContent = Array.isArray(contentResult) ? contentResult : [contentResult];
|
|
58
|
+
const tooltipAggregatorItem = aggregatorContent.map((content) => {
|
|
59
|
+
const caption = content.type === "plainText" ? content.textContent : content.caption;
|
|
60
|
+
const value = content.type === "plainText" ? undefined : content.value;
|
|
61
|
+
return {
|
|
62
|
+
textContent: {
|
|
63
|
+
caption,
|
|
64
|
+
value
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
if (this.options.publicOptions.aggregator.position === "underValues")
|
|
69
|
+
contentRows = contentRows.concat(tooltipAggregatorItem);
|
|
70
|
+
else
|
|
71
|
+
contentRows = tooltipAggregatorItem.concat(contentRows);
|
|
72
|
+
}
|
|
73
|
+
const headerRow = {
|
|
74
|
+
textContent: {
|
|
75
|
+
caption: keyFieldValue
|
|
76
|
+
},
|
|
77
|
+
wrapper: {
|
|
78
|
+
cssClassName: this.headWrapperCssClassName
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
contentRows.unshift(headerRow);
|
|
82
|
+
return {
|
|
83
|
+
type: "rows",
|
|
84
|
+
rows: contentRows
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AxisModel, LABEL_ELEMENT_HEIGHT_PX } from "../../featuresModel/axisModel";
|
|
1
|
+
import { AxisModel, LABEL_ELEMENT_HEIGHT_PX } from "../../featuresModel/axis/axisModel";
|
|
2
2
|
import { TwoDimLegendModel } from "../../featuresModel/legendModel/twoDimLegendModel";
|
|
3
3
|
import { keyAxisLabelHorizontalLog, keyAxisLabelVerticalLog } from "../../featuresModel/scaleModel/scaleAxisRecalcer";
|
|
4
4
|
import { AxisType } from "../../modelBuilder";
|
package/lib/model/model.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChartOrientation, MdtChartsColorField, PolarChartType, Size,
|
|
1
|
+
import { ChartOrientation, MdtChartsColorField, PolarChartType, Size, TwoDimensionalChartType, AxisLabelPosition, ShowTickFn, MdtChartsDataRow, TwoDimensionalValueGroup, ValueLabelsCollisionMode, ValueLabelsRotationOptions, ValueLabelsHandleElement } from "../config/config";
|
|
2
2
|
import { DataType, DonutOptionsCanvas, Formatter, StaticLegendBlockCanvas, TooltipSettings, Transitions } from "../designer/designerConfig";
|
|
3
3
|
import { BoundingRect } from "../engine/features/valueLabelsCollision/valueLabelsCollision";
|
|
4
4
|
declare type AxisType = "key" | "value";
|
|
@@ -36,8 +36,32 @@ export interface BlockMargin {
|
|
|
36
36
|
left: number;
|
|
37
37
|
right: number;
|
|
38
38
|
}
|
|
39
|
+
export interface TooltipBasicModel {
|
|
40
|
+
getContent: (keyFieldValue: string) => TooltipContent;
|
|
41
|
+
}
|
|
42
|
+
export declare type TooltipMarkerModel = ChartLegendMarkerModel & {
|
|
43
|
+
color: string;
|
|
44
|
+
};
|
|
45
|
+
export declare type TooltipContent = {
|
|
46
|
+
type: "html";
|
|
47
|
+
htmlContent: string;
|
|
48
|
+
} | TooltipContentWithRows;
|
|
49
|
+
export interface TooltipContentWithRows {
|
|
50
|
+
type: "rows";
|
|
51
|
+
rows: TooltipContentRow[];
|
|
52
|
+
}
|
|
53
|
+
export interface TooltipContentRow {
|
|
54
|
+
marker?: TooltipMarkerModel;
|
|
55
|
+
textContent: {
|
|
56
|
+
caption: string;
|
|
57
|
+
value?: string | number;
|
|
58
|
+
};
|
|
59
|
+
wrapper?: {
|
|
60
|
+
cssClassName?: string;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
39
63
|
interface BasicOptionsModel {
|
|
40
|
-
tooltip:
|
|
64
|
+
tooltip: TooltipBasicModel;
|
|
41
65
|
}
|
|
42
66
|
interface GraphicNotationOptionsModel extends BasicOptionsModel {
|
|
43
67
|
legend: ILegendModel;
|
|
@@ -281,23 +305,23 @@ export interface DonutThicknessOptions {
|
|
|
281
305
|
unit: DonutThicknessUnit;
|
|
282
306
|
}
|
|
283
307
|
interface ChartModel {
|
|
284
|
-
tooltip: TooltipModel;
|
|
285
308
|
cssClasses: string[];
|
|
286
309
|
style: ChartStyle;
|
|
287
310
|
}
|
|
288
|
-
interface TooltipModel {
|
|
289
|
-
show: boolean;
|
|
290
|
-
}
|
|
291
311
|
export interface ChartStyle {
|
|
292
312
|
elementColors: string[];
|
|
293
313
|
opacity: number;
|
|
294
314
|
}
|
|
295
|
-
export
|
|
296
|
-
markerShape:
|
|
315
|
+
export declare type ChartLegendMarkerModel = {
|
|
316
|
+
markerShape: "circle";
|
|
317
|
+
} | {
|
|
318
|
+
markerShape: "bar";
|
|
297
319
|
barViewOptions: TwoDimensionalChartLegendBarModel;
|
|
320
|
+
} | {
|
|
321
|
+
markerShape: "line";
|
|
298
322
|
lineViewOptions: TwoDimensionalChartLegendLineModel;
|
|
299
|
-
}
|
|
300
|
-
export declare type LegendMarkerShape = "
|
|
323
|
+
};
|
|
324
|
+
export declare type LegendMarkerShape = ChartLegendMarkerModel["markerShape"];
|
|
301
325
|
export interface TwoDimensionalChartLegendBarModel {
|
|
302
326
|
hatch: BarLikeChartHatchOptions;
|
|
303
327
|
borderRadius: BarBorderRadius;
|
|
@@ -359,13 +383,13 @@ export interface TwoDimensionalChartModel extends ChartModel, TwoDimensionalLine
|
|
|
359
383
|
index: number;
|
|
360
384
|
embeddedLabels: EmbeddedLabelTypeModel;
|
|
361
385
|
isSegmented: boolean;
|
|
362
|
-
legend:
|
|
386
|
+
legend: ChartLegendMarkerModel;
|
|
363
387
|
valueLabels: TwoDimChartValueLabelsOptions;
|
|
364
388
|
}
|
|
365
389
|
export interface PolarChartModel extends ChartModel {
|
|
366
390
|
type: PolarChartType;
|
|
367
391
|
data: PolarChartDataModel;
|
|
368
|
-
legend:
|
|
392
|
+
legend: ChartLegendMarkerModel;
|
|
369
393
|
}
|
|
370
394
|
export interface TwoDimensionalChartDataModel {
|
|
371
395
|
valueFields: ValueField[];
|
|
@@ -2,10 +2,14 @@ import { ChartStyleModelService } from "../../chartStyleModel/chartStyleModel";
|
|
|
2
2
|
import { DonutModel } from "./donut/donutModel";
|
|
3
3
|
import { TitleConfigReader } from "../../modelInstance/titleConfigReader";
|
|
4
4
|
import { createRecordOverflowModel } from "../../featuresModel/recordOverflowModel/recordOverflowModel";
|
|
5
|
+
import { POLAR_LEGEND_MARKER } from "./modelConstants/polarLegendMarker";
|
|
6
|
+
import { TwoDimTooltipContentGenerator } from "../../featuresModel/tooltipModel/tooltipContentModel";
|
|
7
|
+
import { PolarInitialRowsProvider } from "../../featuresModel/tooltipModel/contentByNotations/polarInitialRowsProvider";
|
|
5
8
|
export const MIN_DONUT_BLOCK_SIZE = 120;
|
|
6
9
|
export class PolarModel {
|
|
7
10
|
static getOptions(options, designerConfig, modelInstance) {
|
|
8
11
|
const titleConfig = TitleConfigReader.create(options.title, modelInstance);
|
|
12
|
+
const chart = this.getChartsModel(options.chart, modelInstance.dataModel.repository.getScopedRows().length, designerConfig.chartStyle);
|
|
9
13
|
return {
|
|
10
14
|
type: options.type,
|
|
11
15
|
selectable: !!options.selectable,
|
|
@@ -14,9 +18,25 @@ export class PolarModel {
|
|
|
14
18
|
fontSize: titleConfig.getFontSize()
|
|
15
19
|
},
|
|
16
20
|
data: Object.assign({}, options.data),
|
|
17
|
-
charts:
|
|
21
|
+
charts: [chart],
|
|
18
22
|
legend: modelInstance.canvasModel.legendCanvas.getModel(),
|
|
19
|
-
tooltip:
|
|
23
|
+
tooltip: {
|
|
24
|
+
getContent: (keyFieldValue) => {
|
|
25
|
+
const generator = new TwoDimTooltipContentGenerator({
|
|
26
|
+
datasource: modelInstance.dataModel.repository.getRawRows(),
|
|
27
|
+
keyFieldName: options.data.keyField.name,
|
|
28
|
+
publicOptions: options.tooltip,
|
|
29
|
+
initialRowsProvider: new PolarInitialRowsProvider({
|
|
30
|
+
datasource: modelInstance.dataModel.repository.getRawRows(),
|
|
31
|
+
valueField: options.chart.data.valueField,
|
|
32
|
+
keyFieldName: options.data.keyField.name,
|
|
33
|
+
chartColors: chart.style.elementColors
|
|
34
|
+
}),
|
|
35
|
+
valueGlobalFormatter: designerConfig.dataFormat.formatters
|
|
36
|
+
});
|
|
37
|
+
return generator.generateContent(keyFieldValue);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
20
40
|
chartCanvas: this.getDonutSettings(designerConfig.canvas.chartOptions.donut, options.chart, modelInstance.dataModel.repository.getRawRows()),
|
|
21
41
|
defs: { gradients: [] },
|
|
22
42
|
recordOverflowAlert: createRecordOverflowModel(modelInstance.dataModel.getScope().hidedRecordsAmount, {
|
|
@@ -52,28 +72,13 @@ export class PolarModel {
|
|
|
52
72
|
return this.donutModel.getSettings(settings, chartOptions, dataRows);
|
|
53
73
|
}
|
|
54
74
|
static getChartsModel(chart, dataLength, chartStyleConfig) {
|
|
55
|
-
|
|
56
|
-
chartsModel.push({
|
|
75
|
+
return {
|
|
57
76
|
type: chart.type,
|
|
58
77
|
data: Object.assign({}, chart.data),
|
|
59
|
-
tooltip: { show: true },
|
|
60
78
|
cssClasses: ChartStyleModelService.getCssClasses(0),
|
|
61
79
|
style: ChartStyleModelService.getChartStyle(dataLength, chartStyleConfig),
|
|
62
|
-
legend:
|
|
63
|
-
|
|
64
|
-
barViewOptions: {
|
|
65
|
-
hatch: { on: false },
|
|
66
|
-
borderRadius: { topLeft: 0, topRight: 0, bottomLeft: 0, bottomRight: 0 },
|
|
67
|
-
width: 0
|
|
68
|
-
},
|
|
69
|
-
lineViewOptions: {
|
|
70
|
-
dashedStyles: { on: false, dashSize: 0, gapSize: 0 },
|
|
71
|
-
strokeWidth: 0,
|
|
72
|
-
length: 0
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
return chartsModel;
|
|
80
|
+
legend: POLAR_LEGEND_MARKER
|
|
81
|
+
};
|
|
77
82
|
}
|
|
78
83
|
}
|
|
79
84
|
PolarModel.donutModel = new DonutModel();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AreaChartViewOptions, BarBorderRadius,
|
|
1
|
+
import { AreaChartViewOptions, BarBorderRadius, ChartLegendMarkerModel, ChartStyle, GradientId, LineLikeChartDashOptions, LineLikeChartShapeOptions, Orient, TwoDimensionalBarLikeChartViewModel, TwoDimensionalChartLegendLineModel } from "../../model";
|
|
2
2
|
import { ChartOrientation, MdtChartsLineLikeChartDashedStyles, MdtChartsTwoDimensionalChart, TwoDimensionalChartType } from "../../../config/config";
|
|
3
3
|
import { MdtChartsLineLikeChartShape } from "../../../designer/designerConfig";
|
|
4
4
|
export declare const LINE_CHART_DEFAULT_WIDTH = 2;
|
|
@@ -7,7 +7,7 @@ export declare function parseDashStyles(configOptions?: MdtChartsLineLikeChartDa
|
|
|
7
7
|
export declare function getBarViewOptions(chart: MdtChartsTwoDimensionalChart, keyAxisOrient: Orient, barIndexes: number[]): TwoDimensionalBarLikeChartViewModel;
|
|
8
8
|
export declare function calculateBarIndexes(allCharts: Pick<MdtChartsTwoDimensionalChart, "isSegmented" | "data" | "type">[], currentChart: Pick<MdtChartsTwoDimensionalChart, "isSegmented" | "data" | "type">, currentChartIndex: number): number[];
|
|
9
9
|
export declare function getSegmentedRadiusValues(segmentsLength: number, segmentIndex: number, keyAxisOrient: Orient, defaultRadius: number): BarBorderRadius;
|
|
10
|
-
export declare function getLegendMarkerOptions(chart: MdtChartsTwoDimensionalChart):
|
|
10
|
+
export declare function getLegendMarkerOptions(chart: MdtChartsTwoDimensionalChart): ChartLegendMarkerModel;
|
|
11
11
|
export declare function getLineViewOptions(chart: MdtChartsTwoDimensionalChart): TwoDimensionalChartLegendLineModel;
|
|
12
12
|
export declare function getWidthOfLegendMarkerByType(chartType: TwoDimensionalChartType): number;
|
|
13
13
|
export declare function getAreaViewOptions(chart: MdtChartsTwoDimensionalChart, chartIndex: number, style: ChartStyle, chartBlockId: number): AreaChartViewOptions;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ChartStyleModelService } from "../chartStyleModel/chartStyleModel";
|
|
2
2
|
import { TwoDimensionalChartStyleModel } from "../chartStyleModel/twoDimensionalChartStyleModel";
|
|
3
|
-
import { AxisModel } from "../featuresModel/axisModel";
|
|
3
|
+
import { AxisModel } from "../featuresModel/axis/axisModel";
|
|
4
4
|
import { ScaleAxisRecalcer } from "../featuresModel/scaleModel/scaleAxisRecalcer";
|
|
5
5
|
import { ScaleModel } from "../featuresModel/scaleModel/scaleModel";
|
|
6
6
|
import { calculateBarIndexes, getAreaViewOptions, getBarViewOptions, getLegendMarkerOptions, LINE_CHART_DEFAULT_WIDTH, parseDashStyles, parseShape } from "./twoDimensional/styles";
|
|
@@ -8,6 +8,8 @@ import { calculateValueLabelAlignment, ValueLabelCoordinateCalculator } from "..
|
|
|
8
8
|
import { TwoDimensionalModelHelper } from "../helpers/twoDimensionalModelHelper";
|
|
9
9
|
import { TitleConfigReader } from "../modelInstance/titleConfigReader";
|
|
10
10
|
import { createRecordOverflowModel } from "../featuresModel/recordOverflowModel/recordOverflowModel";
|
|
11
|
+
import { TwoDimTooltipContentGenerator } from "../featuresModel/tooltipModel/tooltipContentModel";
|
|
12
|
+
import { TwoDimInitialRowsProvider } from "../featuresModel/tooltipModel/contentByNotations/twoDimInitialRowsProvider";
|
|
11
13
|
export class TwoDimensionalModel {
|
|
12
14
|
static getOptions(configReader, designerConfig, modelInstance) {
|
|
13
15
|
const options = configReader.options;
|
|
@@ -42,7 +44,18 @@ export class TwoDimensionalModel {
|
|
|
42
44
|
data: Object.assign({}, options.data),
|
|
43
45
|
charts,
|
|
44
46
|
additionalElements: this.getAdditionalElements(options),
|
|
45
|
-
tooltip:
|
|
47
|
+
tooltip: {
|
|
48
|
+
getContent: (keyFieldValue) => {
|
|
49
|
+
const generator = new TwoDimTooltipContentGenerator({
|
|
50
|
+
datasource: modelInstance.dataModel.repository.getRawRows(),
|
|
51
|
+
keyFieldName: options.data.keyField.name,
|
|
52
|
+
publicOptions: options.tooltip,
|
|
53
|
+
initialRowsProvider: new TwoDimInitialRowsProvider({ chartsInfo: charts }),
|
|
54
|
+
valueGlobalFormatter: designerConfig.dataFormat.formatters
|
|
55
|
+
});
|
|
56
|
+
return generator.generateContent(keyFieldValue);
|
|
57
|
+
}
|
|
58
|
+
},
|
|
46
59
|
chartSettings: this.getChartsSettings(designerConfig.canvas.chartOptions, options.orientation),
|
|
47
60
|
valueLabels: TwoDimensionalModelHelper.getValueLabels(options.valueLabels, canvasModel, options.orientation, configReader.getValueLabelsStyleModel()),
|
|
48
61
|
defs: {
|
|
@@ -90,7 +103,6 @@ export class TwoDimensionalModel {
|
|
|
90
103
|
type: chart.type,
|
|
91
104
|
isSegmented: chart.isSegmented,
|
|
92
105
|
data: Object.assign({}, chart.data),
|
|
93
|
-
tooltip: { show: true },
|
|
94
106
|
cssClasses: ChartStyleModelService.getCssClasses(index),
|
|
95
107
|
style,
|
|
96
108
|
embeddedLabels: this.getEmbeddedLabelType(chart, chartOrientation),
|
|
@@ -193,10 +193,10 @@
|
|
|
193
193
|
.mdt-charts-tooltip-content .tooltip-text-item > span {
|
|
194
194
|
display: block;
|
|
195
195
|
}
|
|
196
|
-
.mdt-charts-tooltip-content .tooltip-text-item
|
|
196
|
+
.mdt-charts-tooltip-content .tooltip-text-item .tooltip-field-title {
|
|
197
197
|
flex: 1;
|
|
198
198
|
}
|
|
199
|
-
.mdt-charts-tooltip-content .tooltip-text-item
|
|
199
|
+
.mdt-charts-tooltip-content .tooltip-text-item .tooltip-field-value {
|
|
200
200
|
flex: 0;
|
|
201
201
|
}
|
|
202
202
|
.tooltip-field-value {
|
|
@@ -193,10 +193,10 @@
|
|
|
193
193
|
.mdt-charts-tooltip-content .tooltip-text-item > span {
|
|
194
194
|
display: block;
|
|
195
195
|
}
|
|
196
|
-
.mdt-charts-tooltip-content .tooltip-text-item
|
|
196
|
+
.mdt-charts-tooltip-content .tooltip-text-item .tooltip-field-title {
|
|
197
197
|
flex: 1;
|
|
198
198
|
}
|
|
199
|
-
.mdt-charts-tooltip-content .tooltip-text-item
|
|
199
|
+
.mdt-charts-tooltip-content .tooltip-text-item .tooltip-field-value {
|
|
200
200
|
flex: 0;
|
|
201
201
|
}
|
|
202
202
|
.tooltip-field-value {
|
package/package.json
CHANGED
|
File without changes
|