mdt-charts 1.30.2 → 1.32.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 +30 -5
- 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/features/valueLabels/valueLabels.js +17 -9
- 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/featuresModel/valueLabelsModel/valueLabelsModel.d.ts +4 -3
- package/lib/model/featuresModel/valueLabelsModel/valueLabelsModel.js +38 -6
- package/lib/model/margin/twoDim/twoDimMarginModel.js +3 -3
- package/lib/model/model.d.ts +45 -13
- package/lib/model/modelInstance/configReader.js +1 -1
- 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 +40 -24
- package/lib/style/charts-main.css +2 -2
- package/lib/style/charts-main.less +2 -2
- package/package.json +2 -3
- 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
|
}
|
|
@@ -283,15 +294,29 @@ export interface TwoDimensionalChartData {
|
|
|
283
294
|
valueFields: TwoDimValueField[];
|
|
284
295
|
valueGroup?: TwoDimensionalValueGroup;
|
|
285
296
|
}
|
|
286
|
-
export declare type
|
|
297
|
+
export declare type ValueLabelsPositionOptions = {
|
|
298
|
+
mode: "afterHead" | "beforeHead";
|
|
299
|
+
/** @default 10 */
|
|
300
|
+
offsetSize?: number;
|
|
301
|
+
} | {
|
|
302
|
+
mode?: "center";
|
|
303
|
+
};
|
|
304
|
+
export declare type ValueLabelsPositionMode = ValueLabelsPositionOptions["mode"];
|
|
305
|
+
export interface ValueLabelsContentSetterOptions {
|
|
306
|
+
dataRow: MdtChartsDataRow;
|
|
307
|
+
field: MdtChartsValueField;
|
|
308
|
+
}
|
|
309
|
+
export declare type ValueLabelsContentSetter = (options: ValueLabelsContentSetterOptions) => {
|
|
310
|
+
textContent: string | number;
|
|
311
|
+
};
|
|
287
312
|
export interface TwoDimensionalChartValueLabels {
|
|
288
313
|
on: boolean;
|
|
289
|
-
position?:
|
|
290
|
-
mode?: ValueLabelsPositionMode;
|
|
291
|
-
};
|
|
314
|
+
position?: ValueLabelsPositionOptions;
|
|
292
315
|
format?: ValueLabelsFormatter;
|
|
293
316
|
rotation?: ValueLabelsRotationOptions;
|
|
294
317
|
handleElement?: ValueLabelsHandleElement;
|
|
318
|
+
renderForFields?: MdtChartsFieldName[];
|
|
319
|
+
setContent?: ValueLabelsContentSetter;
|
|
295
320
|
}
|
|
296
321
|
export declare type ValueLabelsHandleElement = (elInfo: {
|
|
297
322
|
element: SVGTextElement;
|
|
@@ -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";
|
|
@@ -24,14 +24,18 @@ export class ChartValueLabels {
|
|
|
24
24
|
render(scales, data) {
|
|
25
25
|
if (this.chart.isSegmented) {
|
|
26
26
|
const preparedData = getStackedData(data, this.chart);
|
|
27
|
-
preparedData
|
|
27
|
+
preparedData
|
|
28
|
+
.filter((segment) => { var _a; return this.options.forFields.includes((_a = segment[0]) === null || _a === void 0 ? void 0 : _a.fieldName); })
|
|
29
|
+
.forEach((segment, segmentIndex) => {
|
|
28
30
|
if (!segment[0])
|
|
29
31
|
return;
|
|
30
32
|
this.renderByGroupIndex(scales, segmentIndex, segment, segment[0].fieldName, "1", (d) => d.data);
|
|
31
33
|
});
|
|
32
34
|
}
|
|
33
35
|
else {
|
|
34
|
-
this.chart.data.valueFields
|
|
36
|
+
this.chart.data.valueFields
|
|
37
|
+
.filter((field) => this.options.forFields.includes(field.name))
|
|
38
|
+
.forEach((valueField, vfIndex) => {
|
|
35
39
|
this.renderByGroupIndex(scales, vfIndex, data, valueField.name, valueField.name, (d) => d);
|
|
36
40
|
});
|
|
37
41
|
}
|
|
@@ -41,14 +45,18 @@ export class ChartValueLabels {
|
|
|
41
45
|
this.options = updatedOptions;
|
|
42
46
|
if (this.chart.isSegmented) {
|
|
43
47
|
const preparedData = getStackedData(newData, this.chart);
|
|
44
|
-
preparedData
|
|
48
|
+
preparedData
|
|
49
|
+
.filter((segment) => { var _a; return this.options.forFields.includes((_a = segment[0]) === null || _a === void 0 ? void 0 : _a.fieldName); })
|
|
50
|
+
.forEach((segment, segmentIndex) => {
|
|
45
51
|
var _a;
|
|
46
52
|
const promise = this.updateByGroupIndex(scales, segmentIndex, segment, "1", (d) => d.data, (_a = segment[0]) === null || _a === void 0 ? void 0 : _a.fieldName);
|
|
47
53
|
updatePromises.push(promise);
|
|
48
54
|
});
|
|
49
55
|
}
|
|
50
56
|
else {
|
|
51
|
-
this.chart.data.valueFields
|
|
57
|
+
this.chart.data.valueFields
|
|
58
|
+
.filter((field) => this.options.forFields.includes(field.name))
|
|
59
|
+
.forEach((valueField, vfIndex) => {
|
|
52
60
|
const promise = this.updateByGroupIndex(scales, vfIndex, newData, valueField.name, (d) => d, valueField.name);
|
|
53
61
|
updatePromises.push(promise);
|
|
54
62
|
});
|
|
@@ -59,7 +67,7 @@ export class ChartValueLabels {
|
|
|
59
67
|
let valueLabels = this.getAllValueLabelsOfChart(groupIndex).data(data).enter().append("text");
|
|
60
68
|
valueLabels = this.renderPipeline.execute(valueLabels, { style: this.globalOptions.canvas.style });
|
|
61
69
|
const attrs = this.attrsProvider.getAttrs(this.globalOptions, this.options, scales, datumField, dataRowAccessor);
|
|
62
|
-
this.setAttrs(valueLabels, attrs, valueFieldName, this.options.
|
|
70
|
+
this.setAttrs(valueLabels, attrs, valueFieldName, this.options.setContent, dataRowAccessor);
|
|
63
71
|
this.setClasses(valueLabels, this.chart.cssClasses, groupIndex);
|
|
64
72
|
}
|
|
65
73
|
updateByGroupIndex(scales, groupIndex, data, datumField, dataRowAccessor, valueFieldName) {
|
|
@@ -74,19 +82,19 @@ export class ChartValueLabels {
|
|
|
74
82
|
let newValueLabels = valueLabels.enter().append("text");
|
|
75
83
|
newValueLabels = this.renderPipeline.execute(newValueLabels, { style: this.globalOptions.canvas.style });
|
|
76
84
|
const mergedValueLabels = newValueLabels.merge(valueLabels);
|
|
77
|
-
this.setAttrs(newValueLabels, attrs, valueFieldName, this.options.
|
|
85
|
+
this.setAttrs(newValueLabels, attrs, valueFieldName, this.options.setContent, dataRowAccessor);
|
|
78
86
|
this.setClasses(mergedValueLabels, this.chart.cssClasses, groupIndex);
|
|
79
|
-
this.setAttrs(valueLabels, attrs, valueFieldName, this.options.
|
|
87
|
+
this.setAttrs(valueLabels, attrs, valueFieldName, this.options.setContent, dataRowAccessor, true, resolve);
|
|
80
88
|
});
|
|
81
89
|
}
|
|
82
90
|
getAllValueLabelsOfChart(vfIndex) {
|
|
83
91
|
const block = this.globalOptions.elementAccessors.getBlock().svg.getChartBlock();
|
|
84
92
|
return block.selectAll(`.${ChartValueLabels.valueLabelClass}.${CLASSES.dataLabel}${Helper.getCssClassesLine(this.chart.cssClasses)}.chart-element-${vfIndex}`);
|
|
85
93
|
}
|
|
86
|
-
setAttrs(valueLabels, attrs, valueFieldName,
|
|
94
|
+
setAttrs(valueLabels, attrs, valueFieldName, setContent, dataRowAccessor, animate = false, onEndAnimation) {
|
|
87
95
|
const animationName = "labels-updating";
|
|
88
96
|
let selection = valueLabels
|
|
89
|
-
.text((d) =>
|
|
97
|
+
.text((d) => setContent({ dataRow: dataRowAccessor(d), fieldName: valueFieldName }).textContent)
|
|
90
98
|
.attr("dominant-baseline", attrs.dominantBaseline)
|
|
91
99
|
.attr("text-anchor", attrs.textAnchor);
|
|
92
100
|
if (animate) {
|
|
@@ -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
|
+
}
|