@evergis/charts 2.0.94 → 2.0.95
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/dist/charts/BarChart/drawTooltip/index.d.ts +1 -1
- package/dist/charts/BarChart/drawTooltip/types.d.ts +1 -1
- package/dist/charts/BarChart/types.d.ts +2 -0
- package/dist/charts.cjs.development.js +24 -3
- package/dist/charts.cjs.development.js.map +1 -1
- package/dist/charts.cjs.production.min.js +1 -1
- package/dist/charts.cjs.production.min.js.map +1 -1
- package/dist/charts.esm.js +24 -3
- package/dist/charts.esm.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { DrawTooltipProps } from './types';
|
|
2
|
-
export declare const drawTooltip: ({ svg, node, data, marshalledData, xScale, yScale, renderTooltip, labelPosition, marginTop, renderLabel, barWidth, barPadding, dynamicTooltipEnable, tooltipY, tooltipBind, lineData, formatTooltipValue, formatTooltipName, tooltipYDomain, setTooltipPosition, onLabelItem, isBarTooltip, bars, tooltipRoot, tooltipClassName, }: DrawTooltipProps) => void;
|
|
2
|
+
export declare const drawTooltip: ({ svg, node, data, marshalledData, xScale, yScale, renderTooltip, labelPosition, marginTop, renderLabel, barWidth, barPadding, dynamicTooltipEnable, tooltipY, tooltipBind, lineData, formatTooltipValue, formatTooltipName, tooltipYDomain, setTooltipPosition, onLabelItem, isBarTooltip, bars, tooltipRoot, tooltipClassName, onBarClick, onBarHover, }: DrawTooltipProps) => void;
|
|
@@ -10,4 +10,4 @@ export declare type DrawTooltipProps = {
|
|
|
10
10
|
marginTop: number;
|
|
11
11
|
barWidth: number;
|
|
12
12
|
bars: d3.Selection<SVGGElement, BarChartMarshalledGroup[], SVGGElement, unknown>;
|
|
13
|
-
} & Pick<BarChartProps, 'renderTooltip' | 'labelPosition' | 'renderLabel' | 'dynamicTooltipEnable' | 'tooltipY' | 'tooltipBind' | 'lineData' | 'formatTooltipValue' | 'formatTooltipName' | 'tooltipYDomain' | 'data' | 'barPadding' | 'setTooltipPosition' | 'onLabelItem' | 'isBarTooltip' | 'tooltipRoot' | 'tooltipClassName'>;
|
|
13
|
+
} & Pick<BarChartProps, 'renderTooltip' | 'labelPosition' | 'renderLabel' | 'dynamicTooltipEnable' | 'tooltipY' | 'tooltipBind' | 'lineData' | 'formatTooltipValue' | 'formatTooltipName' | 'tooltipYDomain' | 'data' | 'barPadding' | 'setTooltipPosition' | 'onLabelItem' | 'isBarTooltip' | 'tooltipRoot' | 'tooltipClassName' | 'onBarClick' | 'onBarHover'>;
|
|
@@ -113,6 +113,8 @@ export declare type BarChartProps = {
|
|
|
113
113
|
tooltipClassName?: string;
|
|
114
114
|
selectable?: boolean;
|
|
115
115
|
onSelect?: (value: [number, number]) => void;
|
|
116
|
+
onBarClick?: (group: BarChartMarshalledGroup) => void;
|
|
117
|
+
onBarHover?: (group?: BarChartMarshalledGroup) => void;
|
|
116
118
|
};
|
|
117
119
|
export declare type BarChartMergedData = (BarChartMarshalledGroup & BarChartLineData & {
|
|
118
120
|
groupName: string;
|
|
@@ -2309,7 +2309,9 @@ const drawTooltip$2 = _ref => {
|
|
|
2309
2309
|
isBarTooltip,
|
|
2310
2310
|
bars,
|
|
2311
2311
|
tooltipRoot,
|
|
2312
|
-
tooltipClassName
|
|
2312
|
+
tooltipClassName,
|
|
2313
|
+
onBarClick,
|
|
2314
|
+
onBarHover
|
|
2313
2315
|
} = _ref;
|
|
2314
2316
|
d3.select(node).select("." + barChartClassNames.barChartMouseContainer).remove();
|
|
2315
2317
|
const xScaleBandDomain = xScale.domain();
|
|
@@ -2513,6 +2515,21 @@ const drawTooltip$2 = _ref => {
|
|
|
2513
2515
|
const container = d3.select(node).append('div').attr('class', barChartClassNames.barChartMouseContainer);
|
|
2514
2516
|
const labelContainer = container.append('div').attr('class', barChartClassNames.barChartLabelContainer).style('position', 'absolute').style('top', y2 + "px");
|
|
2515
2517
|
|
|
2518
|
+
const isMouseWithin = (e, callback) => {
|
|
2519
|
+
const [rectrX, rectrY] = d3.pointer(e, mouseRect);
|
|
2520
|
+
const [nodeX, nodeY] = d3.pointer(e, node);
|
|
2521
|
+
const x = rectrX - (rectrX - nodeX);
|
|
2522
|
+
const y = rectrY - nodeY;
|
|
2523
|
+
const currIndex = groups.findIndex(value => x <= value);
|
|
2524
|
+
const dataItem = marshalledData[currIndex][0];
|
|
2525
|
+
|
|
2526
|
+
if (dataItem.height >= y1 - y) {
|
|
2527
|
+
callback(dataItem);
|
|
2528
|
+
}
|
|
2529
|
+
};
|
|
2530
|
+
|
|
2531
|
+
mouseGlobal.on("click", e => isMouseWithin(e, dataItem => onBarClick && onBarClick(dataItem))).on("mousemove", e => isMouseWithin(e, dataItem => onBarHover && onBarHover(dataItem))).on("mouseleave", () => onBarHover && onBarHover(undefined));
|
|
2532
|
+
|
|
2516
2533
|
if (labelPosition) {
|
|
2517
2534
|
const concatedData = lineData ? marshalledData.map((stack, index) => stack.concat(lineData.map(_ref6 => {
|
|
2518
2535
|
let {
|
|
@@ -2646,7 +2663,9 @@ const draw$4 = (node, props) => {
|
|
|
2646
2663
|
isBarTooltip,
|
|
2647
2664
|
xScaleItemWidth,
|
|
2648
2665
|
tooltipRoot,
|
|
2649
|
-
tooltipClassName
|
|
2666
|
+
tooltipClassName,
|
|
2667
|
+
onBarClick,
|
|
2668
|
+
onBarHover
|
|
2650
2669
|
} = props;
|
|
2651
2670
|
|
|
2652
2671
|
if (node !== null && data.length) {
|
|
@@ -2817,7 +2836,9 @@ const draw$4 = (node, props) => {
|
|
|
2817
2836
|
isBarTooltip,
|
|
2818
2837
|
bars: groups,
|
|
2819
2838
|
tooltipRoot,
|
|
2820
|
-
tooltipClassName
|
|
2839
|
+
tooltipClassName,
|
|
2840
|
+
onBarClick,
|
|
2841
|
+
onBarHover
|
|
2821
2842
|
});
|
|
2822
2843
|
}
|
|
2823
2844
|
|