mdt-charts 1.18.3 → 1.18.4
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 -3
- package/lib/engine/contentManager/contentManagerFactory.js +0 -2
- package/lib/engine/features/axis/axis.d.ts +1 -0
- package/lib/engine/features/axis/axis.js +14 -0
- package/lib/engine/features/axis/axisHelper.js +3 -1
- package/lib/engine/features/legend/legend.d.ts +2 -2
- package/lib/engine/features/legend/legendHelper.d.ts +2 -2
- package/lib/engine/features/legend/legendHelper.js +0 -3
- package/lib/engine/features/scale/scale.d.ts +4 -0
- package/lib/engine/features/scale/scale.js +4 -0
- package/lib/engine/features/tolltip/tooltip.d.ts +0 -1
- package/lib/engine/features/tolltip/tooltip.js +2 -21
- package/lib/engine/features/tolltip/tooltipDomHelper.d.ts +6 -3
- package/lib/engine/features/tolltip/tooltipDomHelper.js +64 -27
- package/lib/engine/filterManager/filterEventManager.d.ts +6 -0
- package/lib/engine/filterManager/filterEventManager.js +8 -0
- package/lib/engine/twoDimensionalNotation/line/line.d.ts +6 -0
- package/lib/engine/twoDimensionalNotation/line/line.js +7 -8
- package/lib/engine/twoDimensionalNotation/line/lineHelper.d.ts +4 -1
- package/lib/engine/twoDimensionalNotation/line/lineHelper.js +18 -6
- package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +10 -8
- package/lib/model/EventEmitter.d.ts +10 -0
- package/lib/model/EventEmitter.js +26 -0
- package/lib/model/dataManagerModel/dataManagerModel.d.ts +0 -1
- package/lib/model/dataManagerModel/dataManagerModel.js +0 -13
- package/lib/model/featuresModel/axisModel.d.ts +1 -0
- package/lib/model/featuresModel/axisModel.js +12 -1
- package/lib/model/featuresModel/scaleModel/scaleDomainService.d.ts +3 -2
- package/lib/model/featuresModel/scaleModel/scaleDomainService.js +16 -6
- package/lib/model/featuresModel/scaleModel/scaleModel.d.ts +1 -0
- package/lib/model/featuresModel/scaleModel/scaleModel.js +12 -0
- package/lib/model/helpers/modelHelper.d.ts +2 -2
- package/lib/model/helpers/modelHelper.js +11 -22
- package/lib/model/margin/twoDim/twoDimMarginModel.d.ts +1 -1
- package/lib/model/margin/twoDim/twoDimMarginModel.js +3 -3
- package/lib/model/model.d.ts +6 -2
- package/lib/model/modelBuilder.js +0 -13
- package/lib/model/modelInstance/configReader.d.ts +2 -0
- package/lib/model/modelInstance/configReader.js +11 -1
- package/lib/model/notations/twoDimensionalModel.js +9 -2
- package/lib/style/charts-main.css +9 -7
- package/lib/style/charts-main.less +9 -7
- package/lib/style/css-vars.css +3 -0
- package/package.json +3 -3
package/lib/config/config.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ export declare type TwoDimensionalChartType = 'line' | 'bar' | 'area';
|
|
|
8
8
|
export declare type PolarChartType = 'donut';
|
|
9
9
|
export declare type IntervalChartType = 'gantt';
|
|
10
10
|
export declare type EmbeddedLabelType = 'none' | 'key' | 'value';
|
|
11
|
-
export declare type TooltipHtml = (dataRow: MdtChartsDataRow) => string;
|
|
12
11
|
export declare type MdtChartsDataRow = {
|
|
13
12
|
[field: string]: any;
|
|
14
13
|
};
|
|
@@ -96,8 +95,29 @@ export interface TwoDimValueField extends MdtChartsValueField {
|
|
|
96
95
|
color?: string;
|
|
97
96
|
}
|
|
98
97
|
export interface TooltipOptions {
|
|
99
|
-
html
|
|
98
|
+
html?: TooltipHtml;
|
|
99
|
+
aggregator?: TooltipAggregator;
|
|
100
|
+
formatValue?: TooltipFormatValue;
|
|
100
101
|
}
|
|
102
|
+
export declare type TooltipHtml = (dataRow: MdtChartsDataRow) => string;
|
|
103
|
+
export interface TooltipAggregator {
|
|
104
|
+
content: (options: {
|
|
105
|
+
row: MdtChartsDataRow;
|
|
106
|
+
}) => TooltipAggregatorContent;
|
|
107
|
+
position?: "underKey" | "underValues";
|
|
108
|
+
}
|
|
109
|
+
export declare type TooltipAggregatorContent = {
|
|
110
|
+
type: "plainText";
|
|
111
|
+
textContent: string;
|
|
112
|
+
} | {
|
|
113
|
+
type: "captionValue";
|
|
114
|
+
caption: string;
|
|
115
|
+
value: any;
|
|
116
|
+
};
|
|
117
|
+
export declare type TooltipFormatValue = (params: {
|
|
118
|
+
rawValue: number | null | undefined;
|
|
119
|
+
autoFormattedValue: string;
|
|
120
|
+
}) => string;
|
|
101
121
|
export interface AdditionalElements {
|
|
102
122
|
gridLine: GridLineOptions;
|
|
103
123
|
}
|
|
@@ -121,13 +141,18 @@ interface AxisTicks {
|
|
|
121
141
|
flag: boolean;
|
|
122
142
|
}
|
|
123
143
|
export interface NumberAxisOptions extends AxisOptions {
|
|
124
|
-
domain:
|
|
144
|
+
domain: AxisNumberDomain;
|
|
125
145
|
labels?: NumberAxisLabel;
|
|
126
146
|
}
|
|
127
147
|
export interface NumberDomain {
|
|
128
148
|
start: number;
|
|
129
149
|
end: number;
|
|
130
150
|
}
|
|
151
|
+
export interface AxisDomainFunctionParams {
|
|
152
|
+
data: MdtChartsDataRow[];
|
|
153
|
+
}
|
|
154
|
+
export declare type AxisDomainFunction = (params: AxisDomainFunctionParams) => NumberDomain;
|
|
155
|
+
export declare type AxisNumberDomain = NumberDomain | AxisDomainFunction;
|
|
131
156
|
export interface NumberAxisLabel {
|
|
132
157
|
format: (v: number) => string;
|
|
133
158
|
stepSize?: number;
|
|
@@ -195,7 +220,9 @@ export interface IntervalChart extends ChartSettings {
|
|
|
195
220
|
}
|
|
196
221
|
export interface TwoDimensionalChartData {
|
|
197
222
|
valueFields: TwoDimValueField[];
|
|
223
|
+
valueGroup?: TwoDimensionalValueGroup;
|
|
198
224
|
}
|
|
225
|
+
export declare type TwoDimensionalValueGroup = 'main' | 'secondary';
|
|
199
226
|
interface MarkersOptions {
|
|
200
227
|
show: boolean;
|
|
201
228
|
}
|
|
@@ -51,6 +51,9 @@ export class Axis {
|
|
|
51
51
|
AxisLabelHelper.cropLabels(block, scale, scaleOptions, axisOptions, blockSize);
|
|
52
52
|
AxisLabelHelper.alignLabelsInKeyAxis(axisOptions, axisElement);
|
|
53
53
|
AxisLabelsEventManager.setHoverEvents(block, axisElement);
|
|
54
|
+
block.filterEventManager.eventEmitter.subscribe('change', (selectedKeys) => {
|
|
55
|
+
this.handleLabelsHighlight(axisElement, selectedKeys);
|
|
56
|
+
});
|
|
54
57
|
}
|
|
55
58
|
if (axisOptions.type === "value") {
|
|
56
59
|
AxisLabelHelper.cropLabels(block, scale, scaleOptions, axisOptions, blockSize);
|
|
@@ -97,6 +100,7 @@ export class Axis {
|
|
|
97
100
|
AxisLabelsEventManager.setHoverEvents(block, axisElement);
|
|
98
101
|
if (axisOptions.labels.defaultTooltip)
|
|
99
102
|
AxisLabelHelper.setTitles(axisElement);
|
|
103
|
+
this.handleLabelsHighlight(axisElement, block.filterEventManager.getSelectedKeys());
|
|
100
104
|
});
|
|
101
105
|
// Ведется отсчет нескольких кадров, чтобы получить уже 100%-отрендеренные лейблы оси.
|
|
102
106
|
let frame = 0;
|
|
@@ -131,5 +135,15 @@ export class Axis {
|
|
|
131
135
|
};
|
|
132
136
|
requestAnimationFrame(labelHandler);
|
|
133
137
|
}
|
|
138
|
+
static handleLabelsHighlight(axisElement, selectedKeys) {
|
|
139
|
+
const labels = axisElement.selectAll('.tick text');
|
|
140
|
+
if (selectedKeys.length === 0)
|
|
141
|
+
labels.classed('mdt-charts-opacity-inactive', false);
|
|
142
|
+
else
|
|
143
|
+
labels.each(function (data) {
|
|
144
|
+
const isActive = selectedKeys.includes(data);
|
|
145
|
+
select(this).classed('mdt-charts-opacity-inactive', !isActive);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
134
148
|
}
|
|
135
149
|
Axis.axesClass = NamesHelper.getClassName('axis');
|
|
@@ -2,6 +2,7 @@ import { axisTop, axisBottom, axisLeft, axisRight } from 'd3-axis';
|
|
|
2
2
|
import { format } from 'd3-format';
|
|
3
3
|
import { AxisLabelHelper } from './axisLabelDomHelper';
|
|
4
4
|
import { max, min } from 'd3-array';
|
|
5
|
+
import { AxisModel } from "../../../model/featuresModel/axisModel";
|
|
5
6
|
export class AxisHelper {
|
|
6
7
|
static getAxisByOrient(orient, scale) {
|
|
7
8
|
if (orient === 'top')
|
|
@@ -20,7 +21,8 @@ export class AxisHelper {
|
|
|
20
21
|
axisGenerator.ticks(Math.floor(axisLength / minimalStepSize));
|
|
21
22
|
}
|
|
22
23
|
else {
|
|
23
|
-
|
|
24
|
+
const roundedMaxValue = AxisModel.getRoundValue(max(scaleOptions.domain));
|
|
25
|
+
axisGenerator.tickValues([min(scaleOptions.domain), roundedMaxValue]);
|
|
24
26
|
}
|
|
25
27
|
if (scaleOptions.type === 'linear') {
|
|
26
28
|
this.setNumTickFormat(axisGenerator, scaleOptions.formatter);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseType, Selection } from "d3-selection";
|
|
2
2
|
import { MdtChartsDataSource } from "../../../config/config";
|
|
3
|
-
import {
|
|
3
|
+
import { LegendBlockModel, Model, PolarOptionsModel, TwoDimensionalOptionsModel } from "../../../model/model";
|
|
4
4
|
import { Block } from "../../block/block";
|
|
5
5
|
import { SelectionCondition } from "../../helpers/domHelper";
|
|
6
6
|
import { ChartLegendEngineModel } from "./legendHelper";
|
|
@@ -25,7 +25,7 @@ export declare class Legend {
|
|
|
25
25
|
private readonly markerCreator;
|
|
26
26
|
render(block: Block, data: MdtChartsDataSource, options: TwoDimensionalOptionsModel | PolarOptionsModel, model: Model): void;
|
|
27
27
|
update(block: Block, data: MdtChartsDataSource, model: Model<TwoDimensionalOptionsModel | PolarOptionsModel>): void;
|
|
28
|
-
updateColors(block: Block, options: TwoDimensionalOptionsModel | PolarOptionsModel
|
|
28
|
+
updateColors(block: Block, options: TwoDimensionalOptionsModel | PolarOptionsModel): void;
|
|
29
29
|
static getItemsByKeys(block: Block, keys: string[], condition?: SelectionCondition): Selection<HTMLDivElement, ChartLegendEngineModel, BaseType, unknown>;
|
|
30
30
|
private setContent;
|
|
31
31
|
private renderObject;
|
|
@@ -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 { ChartLegendModel,
|
|
3
|
+
import { ChartLegendModel, 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 {
|
|
@@ -15,7 +15,7 @@ export interface ChartLegendEngineModel extends ChartLegendModel {
|
|
|
15
15
|
export declare class LegendHelper {
|
|
16
16
|
static service: LegendHelperService;
|
|
17
17
|
static getLegendItemsContent(options: TwoDimensionalOptionsModel | PolarOptionsModel, data: MdtChartsDataSource): ChartLegendEngineModel[];
|
|
18
|
-
static getMarksColor(options: TwoDimensionalOptionsModel | PolarOptionsModel
|
|
18
|
+
static getMarksColor(options: TwoDimensionalOptionsModel | PolarOptionsModel, dataRows?: MdtChartsDataRow[]): string[];
|
|
19
19
|
static getMaxItemWidth(legendBlockWidth: string, marginsLeft: number[], itemsDirection: LegendItemsDirection): number;
|
|
20
20
|
static getSumOfItemsWidths(itemsWidth: number[], marginsLeft: number[]): number;
|
|
21
21
|
static getLegendCoordinateByPosition(legendPosition: Orient, legendBlockModel: LegendBlockModel, blockSize: Size): LegendCoordinate;
|
|
@@ -27,9 +27,6 @@ export class LegendHelper {
|
|
|
27
27
|
return options.charts.map(chart => chart.style.elementColors)[0];
|
|
28
28
|
return dataRows.map(row => row[options.charts[0].data.colorField]);
|
|
29
29
|
}
|
|
30
|
-
else if (options.type === 'interval') {
|
|
31
|
-
return options.charts.map(chart => chart.style.elementColors[0]);
|
|
32
|
-
}
|
|
33
30
|
}
|
|
34
31
|
static getMaxItemWidth(legendBlockWidth, marginsLeft, itemsDirection) {
|
|
35
32
|
if (itemsDirection === 'row') {
|
|
@@ -5,8 +5,12 @@ export interface Scales {
|
|
|
5
5
|
key: AxisScale<any>;
|
|
6
6
|
value: AxisScale<any>;
|
|
7
7
|
}
|
|
8
|
+
export interface ScalesWithSecondary extends Scales {
|
|
9
|
+
valueSecondary: AxisScale<any>;
|
|
10
|
+
}
|
|
8
11
|
export declare class Scale {
|
|
9
12
|
static getScales(scaleKey: ScaleKeyModel, scaleValue: ScaleValueModel, bandSettings: BarChartSettings): Scales;
|
|
13
|
+
static getScalesWithSecondary(scaleKey: ScaleKeyModel, scaleValue: ScaleValueModel, scaleValueSecondary: ScaleValueModel, bandSettings: BarChartSettings): ScalesWithSecondary;
|
|
10
14
|
static getScaleValue(scaleValue: ScaleValueModel): ScaleLinear<number, number, never> | ScaleTime<number, number, never>;
|
|
11
15
|
static getScaleBandWidth(scale: AxisScale<any>): number;
|
|
12
16
|
static getScaleStep(scale: AxisScale<any>): number;
|
|
@@ -12,6 +12,10 @@ export class Scale {
|
|
|
12
12
|
scales.value = this.getScaleValue(scaleValue);
|
|
13
13
|
return scales;
|
|
14
14
|
}
|
|
15
|
+
static getScalesWithSecondary(scaleKey, scaleValue, scaleValueSecondary, bandSettings) {
|
|
16
|
+
const scales = this.getScales(scaleKey, scaleValue, bandSettings);
|
|
17
|
+
return Object.assign(Object.assign({}, scales), { valueSecondary: this.getScaleValue(scaleValueSecondary) });
|
|
18
|
+
}
|
|
15
19
|
static getScaleValue(scaleValue) {
|
|
16
20
|
if (scaleValue.type === 'linear')
|
|
17
21
|
return this.getScaleLinear(scaleValue.domain, scaleValue.range);
|
|
@@ -12,7 +12,6 @@ export declare class Tooltip {
|
|
|
12
12
|
static render(block: Block, model: Model<TwoDimensionalOptionsModel | PolarOptionsModel>, data: MdtChartsDataSource, tooltipOptions: TooltipSettings, scales?: Scales): void;
|
|
13
13
|
static hide(block: Block): void;
|
|
14
14
|
private static renderTooltipFor2DCharts;
|
|
15
|
-
private static renderTooltipForIntervalCharts;
|
|
16
15
|
private static renderTooltipForPolar;
|
|
17
16
|
private static renderLineTooltip;
|
|
18
17
|
private static renderTooltipForDonut;
|
|
@@ -45,24 +45,6 @@ export class Tooltip {
|
|
|
45
45
|
};
|
|
46
46
|
this.renderLineTooltip(block, data, tooltipParams);
|
|
47
47
|
}
|
|
48
|
-
static renderTooltipForIntervalCharts(block, data, blockSize, margin, scales, options, tooltipOptions) {
|
|
49
|
-
if (scales.key.domain().length === 0)
|
|
50
|
-
return;
|
|
51
|
-
const tooltipParams = {
|
|
52
|
-
type: 'interval',
|
|
53
|
-
scales,
|
|
54
|
-
margin,
|
|
55
|
-
blockSize,
|
|
56
|
-
charts: options.charts,
|
|
57
|
-
chartOrientation: options.orient,
|
|
58
|
-
keyAxisOrient: options.axis.key.orient,
|
|
59
|
-
dataOptions: options.data,
|
|
60
|
-
scaleKeyModel: options.scale.key,
|
|
61
|
-
tooltipSettings: tooltipOptions,
|
|
62
|
-
tooltipOptions: options.tooltip
|
|
63
|
-
};
|
|
64
|
-
this.renderLineTooltip(block, data, tooltipParams);
|
|
65
|
-
}
|
|
66
48
|
static renderTooltipForPolar(block, options, data, blockSize, margin, chartThickness, tooltipOptions) {
|
|
67
49
|
const attrTransform = block.getSvg().select(`.${Donut.donutBlockClass}`).attr('transform');
|
|
68
50
|
const translateNums = Helper.getTranslateNumbers(attrTransform);
|
|
@@ -76,7 +58,6 @@ export class Tooltip {
|
|
|
76
58
|
const tipBox = TipBox.renderOrGet(block, args.margin, args.blockSize);
|
|
77
59
|
let currentKey = null;
|
|
78
60
|
tipBox.on('mousemove', function (e) {
|
|
79
|
-
var _a;
|
|
80
61
|
const keyValue = e.detail.keyValue || TipBoxHelper.getKeyValueByPointer(pointer(e, this), args.chartOrientation, args.margin, args.blockSize, args.scales.key, args.scaleKeyModel.type);
|
|
81
62
|
if (args.tooltipSettings.position === 'followCursor') {
|
|
82
63
|
const tooltipCoordinate = TooltipHelper.getTooltipCursorCoordinate(e.detail.pointer || pointer(e, this), block.getSvg().node().getBoundingClientRect(), tooltipBlock.getEl().node().getBoundingClientRect());
|
|
@@ -85,7 +66,7 @@ export class Tooltip {
|
|
|
85
66
|
if (!currentKey || currentKey !== keyValue) {
|
|
86
67
|
TooltipComponentsManager.showComponent(tooltipBlock.getEl());
|
|
87
68
|
if (args.type === '2d')
|
|
88
|
-
TooltipDomHelper.fillForMulti2DCharts(tooltipContent, args.charts.filter(ch => ch.tooltip.show), data, args.dataOptions, keyValue,
|
|
69
|
+
TooltipDomHelper.fillForMulti2DCharts(tooltipContent, args.charts.filter(ch => ch.tooltip.show), data, args.dataOptions, keyValue, args.tooltipOptions);
|
|
89
70
|
if (args.tooltipSettings.position === 'fixed') {
|
|
90
71
|
const tooltipCoordinate = TooltipHelper.getTooltipFixedCoordinate(args.scales.key, args.margin, keyValue, block.getSvg().node().getBoundingClientRect(), tooltipContent.node().getBoundingClientRect(), args.keyAxisOrient, window.innerWidth, window.innerHeight);
|
|
91
72
|
TooltipComponentsManager.setLineTooltipCoordinate(tooltipBlock, tooltipCoordinate, args.chartOrientation, block.transitionManager.durations.tooltipSlide);
|
|
@@ -140,7 +121,7 @@ export class Tooltip {
|
|
|
140
121
|
}
|
|
141
122
|
elements.on('mouseover', function (e, dataRow) {
|
|
142
123
|
TooltipComponentsManager.showComponent(tooltipBlock.getEl());
|
|
143
|
-
TooltipDomHelper.fillForPolarChart(tooltipContent, chart, data, dataOptions, dataRow.data[dataOptions.keyField.name], select(this).select('path').style('fill'), tooltipOptions
|
|
124
|
+
TooltipDomHelper.fillForPolarChart(tooltipContent, chart, data, dataOptions, dataRow.data[dataOptions.keyField.name], select(this).select('path').style('fill'), tooltipOptions);
|
|
144
125
|
if (tooltipSettings.position === 'fixed') {
|
|
145
126
|
const coordinatePointer = TooltipDomHelper.getRecalcedCoordinateByArrow(DonutHelper.getArcCentroid(blockSize, margin, dataRow, donutThickness), tooltipBlock.getEl(), blockSize, tooltipArrow, translate.x, translate.y);
|
|
146
127
|
coordinatePointer[0] = coordinatePointer[0] + translate.x;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Selection, BaseType } from 'd3-selection';
|
|
2
|
-
import { MdtChartsDataSource,
|
|
2
|
+
import { MdtChartsDataSource, TooltipOptions } from "../../../config/config";
|
|
3
3
|
import { OptionsModelData, PolarChartModel, TwoDimensionalChartModel } from "../../../model/model";
|
|
4
4
|
import { Size } from "../../../config/config";
|
|
5
5
|
export interface TooltipLineAttributes {
|
|
@@ -17,14 +17,17 @@ export declare class TooltipDomHelper {
|
|
|
17
17
|
private static readonly headClass;
|
|
18
18
|
private static readonly textItemClass;
|
|
19
19
|
private static readonly tooltipLegendDefaultMarker;
|
|
20
|
-
static fillForMulti2DCharts(contentBlock: Selection<HTMLElement, unknown, BaseType, unknown>, charts: TwoDimensionalChartModel[], data: MdtChartsDataSource, dataOptions: OptionsModelData, keyValue: string,
|
|
21
|
-
static fillForPolarChart(contentBlock: Selection<HTMLElement, unknown, BaseType, unknown>, chart: PolarChartModel, data: MdtChartsDataSource, dataOptions: OptionsModelData, keyValue: string, markColor: string,
|
|
20
|
+
static fillForMulti2DCharts(contentBlock: Selection<HTMLElement, unknown, BaseType, unknown>, charts: TwoDimensionalChartModel[], data: MdtChartsDataSource, dataOptions: OptionsModelData, keyValue: string, tooltipOptions?: TooltipOptions): void;
|
|
21
|
+
static fillForPolarChart(contentBlock: Selection<HTMLElement, unknown, BaseType, unknown>, chart: PolarChartModel, data: MdtChartsDataSource, dataOptions: OptionsModelData, keyValue: string, markColor: string, tooltipOptions?: TooltipOptions): void;
|
|
22
22
|
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
23
|
private static renderHead;
|
|
24
24
|
private static fillValuesContent;
|
|
25
25
|
private static getTooltipItemHtml;
|
|
26
|
+
private static getTooltipContentItemHtml;
|
|
26
27
|
private static setTooltipArrowCoordinate;
|
|
27
28
|
private static fillContentByFunction;
|
|
28
29
|
private static setWhiteSpaceForTextBlocks;
|
|
29
30
|
private static getMarkerCreator;
|
|
31
|
+
private static addAggregatorTooltipItem;
|
|
32
|
+
private static fillCharts;
|
|
30
33
|
}
|
|
@@ -7,31 +7,26 @@ export const ARROW_DEFAULT_POSITION = 9;
|
|
|
7
7
|
export const TOOLTIP_ARROW_PADDING_X = ARROW_DEFAULT_POSITION - (ARROW_SIZE * Math.sqrt(2) - ARROW_SIZE) / 2 + 14;
|
|
8
8
|
export const TOOLTIP_ARROW_PADDING_Y = 13;
|
|
9
9
|
export class TooltipDomHelper {
|
|
10
|
-
static fillForMulti2DCharts(contentBlock, charts, data, dataOptions, keyValue,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
static fillForMulti2DCharts(contentBlock, charts, data, dataOptions, keyValue, tooltipOptions) {
|
|
11
|
+
const chartDataRows = [];
|
|
12
|
+
charts.forEach(chart => {
|
|
13
|
+
chart.data.valueFields.forEach((field, index) => {
|
|
14
|
+
chartDataRows.push({
|
|
15
|
+
field,
|
|
16
|
+
markColor: chart.style.elementColors[index % chart.style.elementColors.length],
|
|
17
|
+
markerCreator: this.getMarkerCreator(chart.legend)
|
|
18
18
|
});
|
|
19
19
|
});
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
this.fillContentByFunction(contentBlock, data, dataOptions, keyValue, htmlHandler);
|
|
23
|
-
}
|
|
20
|
+
});
|
|
21
|
+
this.fillCharts(contentBlock, chartDataRows, data, dataOptions, keyValue, tooltipOptions);
|
|
24
22
|
}
|
|
25
|
-
static fillForPolarChart(contentBlock, chart, data, dataOptions, keyValue, markColor,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
else {
|
|
33
|
-
this.fillContentByFunction(contentBlock, data, dataOptions, keyValue, htmlHandler);
|
|
34
|
-
}
|
|
23
|
+
static fillForPolarChart(contentBlock, chart, data, dataOptions, keyValue, markColor, tooltipOptions) {
|
|
24
|
+
const chartDataRows = [{
|
|
25
|
+
field: chart.data.valueField,
|
|
26
|
+
markColor,
|
|
27
|
+
markerCreator: this.getMarkerCreator(chart.legend)
|
|
28
|
+
}];
|
|
29
|
+
this.fillCharts(contentBlock, chartDataRows, data, dataOptions, keyValue, tooltipOptions);
|
|
35
30
|
}
|
|
36
31
|
static getRecalcedCoordinateByArrow(coordinate, tooltipBlock, blockSize, tooltipArrow, translateX = 0, translateY = 0) {
|
|
37
32
|
const tooltipBlockNode = tooltipBlock.node();
|
|
@@ -46,7 +41,7 @@ export class TooltipDomHelper {
|
|
|
46
41
|
.attr('class', `${this.groupClass} ${this.headClass}`)
|
|
47
42
|
.text(keyValue);
|
|
48
43
|
}
|
|
49
|
-
static fillValuesContent(contentBlock, markColor, tooltipHtml, markerCreator) {
|
|
44
|
+
static fillValuesContent(contentBlock, { markColor, tooltipHtml, markerCreator }) {
|
|
50
45
|
const group = contentBlock.append('div')
|
|
51
46
|
.attr('class', this.groupClass);
|
|
52
47
|
if (markColor) {
|
|
@@ -59,12 +54,20 @@ export class TooltipDomHelper {
|
|
|
59
54
|
.attr('class', this.textItemClass)
|
|
60
55
|
.html(tooltipHtml);
|
|
61
56
|
}
|
|
62
|
-
static getTooltipItemHtml(
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
|
|
57
|
+
static getTooltipItemHtml(row, valueField, tooltipOptions) {
|
|
58
|
+
const formattedValueByDefault = ValueFormatter.formatField(valueField.format, row[valueField.name]);
|
|
59
|
+
const formattedValue = (tooltipOptions === null || tooltipOptions === void 0 ? void 0 : tooltipOptions.formatValue) ? tooltipOptions.formatValue({
|
|
60
|
+
rawValue: row[valueField.name],
|
|
61
|
+
autoFormattedValue: formattedValueByDefault
|
|
62
|
+
})
|
|
63
|
+
: formattedValueByDefault;
|
|
64
|
+
const text = this.getTooltipContentItemHtml(valueField.title, formattedValue);
|
|
66
65
|
return text;
|
|
67
66
|
}
|
|
67
|
+
static getTooltipContentItemHtml(fieldTitle, fieldValue) {
|
|
68
|
+
return `<span class="tooltip-field-title">${fieldTitle}</span>
|
|
69
|
+
<span class="tooltip-field-value">${fieldValue}</span>`;
|
|
70
|
+
}
|
|
68
71
|
static setTooltipArrowCoordinate(tooltipArrow, horizontalPad) {
|
|
69
72
|
if (horizontalPad !== 0)
|
|
70
73
|
tooltipArrow.style('left', `${ARROW_DEFAULT_POSITION + Math.floor(horizontalPad)}px`);
|
|
@@ -83,6 +86,40 @@ export class TooltipDomHelper {
|
|
|
83
86
|
static getMarkerCreator(options) {
|
|
84
87
|
return getMarkerCreator(options, { default: { cssClass: TooltipDomHelper.tooltipLegendDefaultMarker } });
|
|
85
88
|
}
|
|
89
|
+
static addAggregatorTooltipItem(tooltipOptions, data, tooltipItems) {
|
|
90
|
+
if (tooltipOptions === null || tooltipOptions === void 0 ? void 0 : tooltipOptions.aggregator) {
|
|
91
|
+
const aggregatorContent = tooltipOptions.aggregator.content({ row: data });
|
|
92
|
+
const aggregatorHtml = aggregatorContent.type === 'plainText'
|
|
93
|
+
? aggregatorContent.textContent
|
|
94
|
+
: this.getTooltipContentItemHtml(aggregatorContent.caption, aggregatorContent.value);
|
|
95
|
+
const tooltipAggregatorItem = { markColor: undefined, tooltipHtml: aggregatorHtml, markerCreator: undefined };
|
|
96
|
+
if (tooltipOptions.aggregator.position === 'underValues')
|
|
97
|
+
tooltipItems.push(tooltipAggregatorItem);
|
|
98
|
+
else
|
|
99
|
+
tooltipItems.unshift(tooltipAggregatorItem);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
static fillCharts(contentBlock, chartDataRows, data, dataOptions, keyValue, tooltipOptions) {
|
|
103
|
+
const row = data[dataOptions.dataSource].find(d => d[dataOptions.keyField.name] === keyValue);
|
|
104
|
+
contentBlock.html('');
|
|
105
|
+
if (!(tooltipOptions === null || tooltipOptions === void 0 ? void 0 : tooltipOptions.html)) {
|
|
106
|
+
const tooltipItems = [];
|
|
107
|
+
this.renderHead(contentBlock, keyValue);
|
|
108
|
+
chartDataRows.forEach((dataRow) => {
|
|
109
|
+
const html = this.getTooltipItemHtml(row, dataRow.field, tooltipOptions);
|
|
110
|
+
tooltipItems.push({
|
|
111
|
+
markColor: dataRow.markColor,
|
|
112
|
+
tooltipHtml: html,
|
|
113
|
+
markerCreator: dataRow.markerCreator
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
this.addAggregatorTooltipItem(tooltipOptions, row, tooltipItems);
|
|
117
|
+
tooltipItems.forEach(item => { this.fillValuesContent(contentBlock, item); });
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
this.fillContentByFunction(contentBlock, data, dataOptions, keyValue, tooltipOptions.html);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
86
123
|
}
|
|
87
124
|
TooltipDomHelper.groupClass = 'tooltip-group';
|
|
88
125
|
TooltipDomHelper.headClass = 'tooltip-head';
|
|
@@ -2,17 +2,22 @@ import { AxisScale } from "d3-axis";
|
|
|
2
2
|
import { MdtChartsDataRow, Size } from "../../config/config";
|
|
3
3
|
import { BlockMargin, TwoDimensionalOptionsModel, PolarOptionsModel } from "../../model/model";
|
|
4
4
|
import { Block } from "../block/block";
|
|
5
|
+
import { EventEmitter } from "../../model/EventEmitter";
|
|
5
6
|
export declare type FilterCallback = (rows: MdtChartsDataRow[]) => void;
|
|
6
7
|
export interface SelectDetails {
|
|
7
8
|
multySelect: boolean;
|
|
8
9
|
keyValue?: string;
|
|
9
10
|
}
|
|
11
|
+
interface FilterEventMap {
|
|
12
|
+
change: string[];
|
|
13
|
+
}
|
|
10
14
|
export declare class FilterEventManager {
|
|
11
15
|
private callback;
|
|
12
16
|
private fullDataset;
|
|
13
17
|
private filterable;
|
|
14
18
|
private block;
|
|
15
19
|
private selectedKeys;
|
|
20
|
+
eventEmitter: EventEmitter<FilterEventMap>;
|
|
16
21
|
constructor(callback: FilterCallback, fullDataset: MdtChartsDataRow[], filtrable: boolean, keyFieldName: string, selectedIds?: number[]);
|
|
17
22
|
setBlock(block: Block): void;
|
|
18
23
|
getSelectedKeys(): string[];
|
|
@@ -31,3 +36,4 @@ export declare class FilterEventManager {
|
|
|
31
36
|
private getMultyParamByEvent;
|
|
32
37
|
private getMultySelectParam;
|
|
33
38
|
}
|
|
39
|
+
export {};
|
|
@@ -4,12 +4,14 @@ import { TipBox } from "../features/tipBox/tipBox";
|
|
|
4
4
|
import { TipBoxHelper } from "../features/tipBox/tipBoxHelper";
|
|
5
5
|
import { Helper } from "../helpers/helper";
|
|
6
6
|
import { Donut } from "../polarNotation/donut/donut";
|
|
7
|
+
import { EventEmitter } from "../../model/EventEmitter";
|
|
7
8
|
export class FilterEventManager {
|
|
8
9
|
constructor(callback, fullDataset, filtrable, keyFieldName, selectedIds = []) {
|
|
9
10
|
this.callback = callback;
|
|
10
11
|
this.fullDataset = fullDataset;
|
|
11
12
|
this.selectedKeys = Helper.getKeysByIds(selectedIds, keyFieldName, fullDataset);
|
|
12
13
|
this.filterable = filtrable;
|
|
14
|
+
this.eventEmitter = new EventEmitter();
|
|
13
15
|
}
|
|
14
16
|
setBlock(block) {
|
|
15
17
|
this.block = block;
|
|
@@ -27,12 +29,14 @@ export class FilterEventManager {
|
|
|
27
29
|
this.selectedKeys = [];
|
|
28
30
|
if (this.callback)
|
|
29
31
|
this.callback([]);
|
|
32
|
+
this.eventEmitter.emit('change', this.selectedKeys);
|
|
30
33
|
SelectHighlighter.clear2D(this.block, options);
|
|
31
34
|
}
|
|
32
35
|
clearKeysForPolar(margin, blockSize, options) {
|
|
33
36
|
this.selectedKeys = [];
|
|
34
37
|
if (this.callback)
|
|
35
38
|
this.callback([]);
|
|
39
|
+
this.eventEmitter.emit('change', this.selectedKeys);
|
|
36
40
|
SelectHighlighter.clearPolar(margin, blockSize, this.block, options, Donut.getAllArcGroups(this.block), options.chartCanvas);
|
|
37
41
|
}
|
|
38
42
|
setKey(key) {
|
|
@@ -82,6 +86,8 @@ export class FilterEventManager {
|
|
|
82
86
|
removedKeys.push(key);
|
|
83
87
|
});
|
|
84
88
|
removedKeys.forEach(rKey => this.selectedKeys.splice(this.selectedKeys.findIndex(sKey => sKey === rKey), 1));
|
|
89
|
+
if (removedKeys.length > 0)
|
|
90
|
+
this.eventEmitter.emit("change", this.selectedKeys);
|
|
85
91
|
this.selectedKeys.forEach(key => {
|
|
86
92
|
SelectHighlighter.click2DHandler(true, true, key, this.selectedKeys, this.block, options);
|
|
87
93
|
});
|
|
@@ -99,6 +105,7 @@ export class FilterEventManager {
|
|
|
99
105
|
if (thisClass.callback) {
|
|
100
106
|
thisClass.callback(Helper.getRowsByKeys(thisClass.selectedKeys, options.data.keyField.name, thisClass.fullDataset));
|
|
101
107
|
}
|
|
108
|
+
thisClass.eventEmitter.emit("change", thisClass.selectedKeys);
|
|
102
109
|
});
|
|
103
110
|
}
|
|
104
111
|
}
|
|
@@ -113,6 +120,7 @@ export class FilterEventManager {
|
|
|
113
120
|
if (thisClass.callback) {
|
|
114
121
|
thisClass.callback(Helper.getRowsByKeys(thisClass.selectedKeys, options.data.keyField.name, thisClass.fullDataset));
|
|
115
122
|
}
|
|
123
|
+
thisClass.eventEmitter.emit("change", thisClass.selectedKeys);
|
|
116
124
|
});
|
|
117
125
|
}
|
|
118
126
|
getMultyParamByEvent(e) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SeriesPoint } from 'd3-shape';
|
|
1
2
|
import { BaseType, Selection } from 'd3-selection';
|
|
2
3
|
import { BlockMargin, Field, LineLikeChartSettings, Orient, TwoDimensionalChartModel } from "../../../model/model";
|
|
3
4
|
import { Scales } from "../../features/scale/scale";
|
|
@@ -7,6 +8,11 @@ import { Pipeline } from '../../helpers/pipeline/Pipeline';
|
|
|
7
8
|
interface LineChartOptions {
|
|
8
9
|
staticSettings: LineLikeChartSettings;
|
|
9
10
|
}
|
|
11
|
+
export interface Segment extends SeriesPoint<{
|
|
12
|
+
[p: string]: number;
|
|
13
|
+
}> {
|
|
14
|
+
fieldName: string;
|
|
15
|
+
}
|
|
10
16
|
export declare class Line {
|
|
11
17
|
private options;
|
|
12
18
|
static readonly lineChartClass = "line";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { stack } from 'd3-shape';
|
|
2
1
|
import { select } from 'd3-selection';
|
|
3
2
|
import { MarkDot } from "../../features/markDots/markDot";
|
|
4
|
-
import { LineGeneratorFactory, onLineChartInit } from './lineHelper';
|
|
3
|
+
import { getStackedData, LineGeneratorFactory, onLineChartInit } from './lineHelper';
|
|
5
4
|
import { DomHelper } from '../../helpers/domHelper';
|
|
6
5
|
import { Helper } from '../../helpers/helper';
|
|
7
6
|
import { Pipeline } from '../../helpers/pipeline/Pipeline';
|
|
@@ -40,7 +39,7 @@ export class Line {
|
|
|
40
39
|
});
|
|
41
40
|
}
|
|
42
41
|
renderGrouped(block, scales, data, keyField, margin, keyAxisOrient, chart) {
|
|
43
|
-
const generatorFactory = new LineGeneratorFactory({ keyAxisOrient, scales, keyFieldName: keyField.name, margin, curve: this.options.staticSettings.shape.curve.type });
|
|
42
|
+
const generatorFactory = new LineGeneratorFactory({ keyAxisOrient, scales, keyFieldName: keyField.name, margin, curve: this.options.staticSettings.shape.curve.type, shouldRenderLine: chart.lineViewOptions.renderForKey });
|
|
44
43
|
chart.data.valueFields.forEach((valueField, valueIndex) => {
|
|
45
44
|
const lineGenerator = generatorFactory.getLineGenerator(valueField.name);
|
|
46
45
|
let path = block.svg.getChartGroup(chart.index)
|
|
@@ -57,8 +56,8 @@ export class Line {
|
|
|
57
56
|
});
|
|
58
57
|
}
|
|
59
58
|
renderSegmented(block, scales, data, keyField, margin, keyAxisOrient, chart) {
|
|
60
|
-
|
|
61
|
-
const generatorFactory = new LineGeneratorFactory({ keyAxisOrient, scales, keyFieldName: keyField.name, margin, curve: this.options.staticSettings.shape.curve.type });
|
|
59
|
+
let stackedData = getStackedData(data, chart);
|
|
60
|
+
const generatorFactory = new LineGeneratorFactory({ keyAxisOrient, scales, keyFieldName: keyField.name, margin, curve: this.options.staticSettings.shape.curve.type, shouldRenderLine: chart.lineViewOptions.renderForKey });
|
|
62
61
|
const lineGenerator = generatorFactory.getSegmentedLineGenerator();
|
|
63
62
|
let lines = block.svg.getChartGroup(chart.index)
|
|
64
63
|
.selectAll(`.${this.lineChartClass}${Helper.getCssClassesLine(chart.cssClasses)}`)
|
|
@@ -81,7 +80,7 @@ export class Line {
|
|
|
81
80
|
}
|
|
82
81
|
updateGrouped(block, scales, newData, keyField, margin, keyAxisOrient, chart) {
|
|
83
82
|
const promises = [];
|
|
84
|
-
const generatorFactory = new LineGeneratorFactory({ keyAxisOrient, scales, keyFieldName: keyField.name, margin, curve: this.options.staticSettings.shape.curve.type });
|
|
83
|
+
const generatorFactory = new LineGeneratorFactory({ keyAxisOrient, scales, keyFieldName: keyField.name, margin, curve: this.options.staticSettings.shape.curve.type, shouldRenderLine: chart.lineViewOptions.renderForKey });
|
|
85
84
|
chart.data.valueFields.forEach((valueField, valueFieldIndex) => {
|
|
86
85
|
const lineGenerator = generatorFactory.getLineGenerator(valueField.name);
|
|
87
86
|
const lineObject = block.svg.getChartGroup(chart.index)
|
|
@@ -93,8 +92,8 @@ export class Line {
|
|
|
93
92
|
return promises;
|
|
94
93
|
}
|
|
95
94
|
updateSegmented(block, scales, newData, keyField, margin, keyAxisOrient, chart) {
|
|
96
|
-
|
|
97
|
-
const generatorFactory = new LineGeneratorFactory({ keyAxisOrient, scales, keyFieldName: keyField.name, margin, curve: this.options.staticSettings.shape.curve.type });
|
|
95
|
+
let stackedData = getStackedData(newData, chart);
|
|
96
|
+
const generatorFactory = new LineGeneratorFactory({ keyAxisOrient, scales, keyFieldName: keyField.name, margin, curve: this.options.staticSettings.shape.curve.type, shouldRenderLine: chart.lineViewOptions.renderForKey });
|
|
98
97
|
const lineGenerator = generatorFactory.getSegmentedLineGenerator();
|
|
99
98
|
const lines = block.svg.getChartGroup(chart.index)
|
|
100
99
|
.selectAll(`path.${this.lineChartClass}${Helper.getCssClassesLine(chart.cssClasses)}`)
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { Line as ILine } from 'd3-shape';
|
|
2
2
|
import { MdtChartsDataRow } from '../../../config/config';
|
|
3
|
-
import { Orient, BlockMargin, LineCurveType, TwoDimensionalChartModel } from "../../../model/model";
|
|
3
|
+
import { Orient, BlockMargin, LineCurveType, TwoDimensionalChartModel, LineLikeChartRenderOptions } from "../../../model/model";
|
|
4
4
|
import { Scales } from "../../features/scale/scale";
|
|
5
5
|
import { Pipeline } from '../../helpers/pipeline/Pipeline';
|
|
6
6
|
import { BaseType, Selection } from 'd3-selection';
|
|
7
|
+
import { Segment } from './line';
|
|
7
8
|
interface LineGeneratorFactoryOptions {
|
|
8
9
|
keyAxisOrient: Orient;
|
|
9
10
|
scales: Scales;
|
|
10
11
|
keyFieldName: string;
|
|
11
12
|
margin: BlockMargin;
|
|
12
13
|
curve: LineCurveType;
|
|
14
|
+
shouldRenderLine: LineLikeChartRenderOptions;
|
|
13
15
|
}
|
|
14
16
|
export declare class LineGeneratorFactory {
|
|
15
17
|
private options;
|
|
@@ -19,4 +21,5 @@ export declare class LineGeneratorFactory {
|
|
|
19
21
|
}
|
|
20
22
|
export declare function onLineChartInit(creatingPipeline: Pipeline<Selection<SVGElement, any, BaseType, any>, TwoDimensionalChartModel>): void;
|
|
21
23
|
export declare function applyLineDash(lineSelection: Selection<SVGElement, any, BaseType, any>, dashSize: number, gapSize: number): Selection<SVGElement, any, BaseType, any>;
|
|
24
|
+
export declare function getStackedData(data: MdtChartsDataRow[], chart: TwoDimensionalChartModel): Segment[][];
|
|
22
25
|
export {};
|