@evergis/charts 2.0.14 → 2.0.19
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/styled.d.ts +1 -0
- package/dist/charts/BarChart/types.d.ts +2 -0
- package/dist/charts/HorizontalBarChart/hooks/useTooltip/index.d.ts +1 -1
- package/dist/charts/HorizontalBarChart/types.d.ts +1 -0
- package/dist/charts/LineChart/types.d.ts +3 -1
- package/dist/charts/PieChart/drawTooltips/index.d.ts +1 -1
- package/dist/charts/PieChart/drawTooltips/types.d.ts +2 -1
- package/dist/charts/PieChart/styled.d.ts +1 -0
- package/dist/charts.cjs.development.js +104 -56
- 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 +104 -56
- 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, }: 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, }: 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'>;
|
|
13
|
+
} & Pick<BarChartProps, 'renderTooltip' | 'labelPosition' | 'renderLabel' | 'dynamicTooltipEnable' | 'tooltipY' | 'tooltipBind' | 'lineData' | 'formatTooltipValue' | 'formatTooltipName' | 'tooltipYDomain' | 'data' | 'barPadding' | 'setTooltipPosition' | 'onLabelItem' | 'isBarTooltip' | 'tooltipRoot' | 'tooltipClassName'>;
|
|
@@ -30,3 +30,4 @@ export declare const barChartClassNames: {
|
|
|
30
30
|
barChartGridLineY: string;
|
|
31
31
|
};
|
|
32
32
|
export declare const SvgWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
33
|
+
export declare const TooltipStyles: import("styled-components").GlobalStyleComponent<{}, import("styled-components").DefaultTheme>;
|
|
@@ -101,6 +101,8 @@ export declare type BarChartProps = {
|
|
|
101
101
|
onLabelItem?: (data: BarChartMarshalledGroup[]) => BarChartMarshalledGroup[];
|
|
102
102
|
isBarTooltip?: boolean;
|
|
103
103
|
xScaleItemWidth?: number;
|
|
104
|
+
tooltipRoot?: Element;
|
|
105
|
+
tooltipClassName?: string;
|
|
104
106
|
};
|
|
105
107
|
export declare type BarChartMergedData = (BarChartMarshalledGroup & BarChartLinetData & {
|
|
106
108
|
groupName: string;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { HorizontalBarChartProps } from '../../types';
|
|
2
2
|
import { UseTooltip } from './types';
|
|
3
|
-
export declare const useTooltip: ({ renderTooltip, tooltipBind, tooltipStyle, tooltipRoot, tooltipClassName, }: Pick<HorizontalBarChartProps, 'renderTooltip' | 'tooltipBind' | 'tooltipStyle' | 'tooltipRoot' | 'tooltipClassName'>) => UseTooltip;
|
|
3
|
+
export declare const useTooltip: ({ renderTooltip, tooltipBind, tooltipStyle, tooltipRoot, tooltipClassName, hideTooltip, }: Pick<HorizontalBarChartProps, 'renderTooltip' | 'tooltipBind' | 'tooltipStyle' | 'tooltipRoot' | 'tooltipClassName' | 'hideTooltip'>) => UseTooltip;
|
|
@@ -13,6 +13,7 @@ export declare type HorizontalBarChartProps = {
|
|
|
13
13
|
maxValue?: number | undefined;
|
|
14
14
|
formatNativeTitle?: (bar: HorizontalBarChartMarshalingData) => string;
|
|
15
15
|
renderTooltip?: (bar: HorizontalBarChartMarshalingData[]) => ReactNode;
|
|
16
|
+
hideTooltip?: () => void;
|
|
16
17
|
withTooltip?: boolean;
|
|
17
18
|
fullooltip?: boolean;
|
|
18
19
|
stackedTooltip?: boolean;
|
|
@@ -51,7 +51,7 @@ export declare type LineChartProps = {
|
|
|
51
51
|
xScaleItemWidth?: number;
|
|
52
52
|
};
|
|
53
53
|
export declare type LineChartDot = {
|
|
54
|
-
radius
|
|
54
|
+
radius?: number;
|
|
55
55
|
style?: string;
|
|
56
56
|
filter?: (value: LineChartData, index: number, circles: (d3.BaseType | SVGCircleElement)[] | ArrayLike<d3.BaseType | SVGCircleElement>) => boolean;
|
|
57
57
|
};
|
|
@@ -65,7 +65,9 @@ export declare type LineChartData = {
|
|
|
65
65
|
style?: string;
|
|
66
66
|
dot?: LineChartDot;
|
|
67
67
|
dynamicDotStyle?: string;
|
|
68
|
+
dynamicDotOff?: boolean;
|
|
68
69
|
areaStyle?: string;
|
|
70
|
+
tooltipOrder?: number;
|
|
69
71
|
};
|
|
70
72
|
export declare type LineChartDatas = Omit<LineChartData, 'values'> & {
|
|
71
73
|
value: number | null;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { DrawTooltipProps } from './types';
|
|
2
|
-
export declare const drawTooltip: ({ fullChartTooltip, global, tooltipRoot, data, tooltipClassName, tooltipBind, renderTooltip, arc, allSlices, tooltipStyle, }: DrawTooltipProps) => void;
|
|
2
|
+
export declare const drawTooltip: ({ fullChartTooltip, global, tooltipRoot, data, tooltipClassName, tooltipBind, renderTooltip, arc, allSlices, tooltipStyle, width, height, radius, }: DrawTooltipProps) => void;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as d3 from 'd3';
|
|
2
2
|
import { PieChartProps, PieChartDatum } from '../types';
|
|
3
|
-
export declare type DrawTooltipProps = Pick<PieChartProps, 'fullChartTooltip' | 'tooltipRoot' | 'data' | 'tooltipClassName' | 'tooltipBind' | 'renderTooltip' | 'tooltipStyle'> & {
|
|
3
|
+
export declare type DrawTooltipProps = Pick<PieChartProps, 'fullChartTooltip' | 'tooltipRoot' | 'data' | 'tooltipClassName' | 'tooltipBind' | 'renderTooltip' | 'tooltipStyle' | 'width' | 'height'> & {
|
|
4
4
|
global: d3.Selection<SVGGElement, unknown, null, undefined>;
|
|
5
5
|
allSlices: d3.Selection<SVGPathElement, PieChartDatum, SVGGElement, unknown>;
|
|
6
6
|
arc: d3.Arc<any, d3.DefaultArcObject>;
|
|
7
|
+
radius: number;
|
|
7
8
|
};
|
|
@@ -13,5 +13,6 @@ export declare const pieChartclassNames: {
|
|
|
13
13
|
pieTooltipName: string;
|
|
14
14
|
pieTooltipValue: string;
|
|
15
15
|
pieTooltipColorBox: string;
|
|
16
|
+
pieFullChartTooltipCircle: string;
|
|
16
17
|
};
|
|
17
18
|
export declare const SvgWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -88,7 +88,7 @@ const THROTTLE_DELAY = 44;
|
|
|
88
88
|
const useResize = (width, callback, delay) => {
|
|
89
89
|
const throttledCallback = React.useMemo(() => {
|
|
90
90
|
return callback ? throttle(callback, delay || THROTTLE_DELAY) : undefined;
|
|
91
|
-
}, [callback]);
|
|
91
|
+
}, [callback, delay]);
|
|
92
92
|
React.useEffect(() => {
|
|
93
93
|
throttledCallback && typeof width !== 'number' && window.addEventListener('resize', throttledCallback);
|
|
94
94
|
return () => throttledCallback && window.removeEventListener('resize', throttledCallback);
|
|
@@ -726,7 +726,7 @@ function degreesToRadians(degrees) {
|
|
|
726
726
|
}
|
|
727
727
|
|
|
728
728
|
function _templateObject$5() {
|
|
729
|
-
const data = _taggedTemplateLiteralLoose(["\n .", " {\n fill: #4a4a4a;\n }\n .", " {\n position: absolute;\n max-width: 128px;\n }\n .", " {\n stroke: #000;\n }\n"]);
|
|
729
|
+
const data = _taggedTemplateLiteralLoose(["\n .", " {\n fill: #4a4a4a;\n }\n .", " {\n position: absolute;\n max-width: 128px;\n }\n .", " {\n stroke: #000;\n }\n .", " {\n fill: transparent;\n cursor: pointer;\n }\n"]);
|
|
730
730
|
|
|
731
731
|
_templateObject$5 = function _templateObject() {
|
|
732
732
|
return data;
|
|
@@ -748,9 +748,10 @@ const pieChartclassNames = {
|
|
|
748
748
|
pieTooltipItem: 'pieTooltipItem',
|
|
749
749
|
pieTooltipName: 'pieTooltipName',
|
|
750
750
|
pieTooltipValue: 'pieTooltipValue',
|
|
751
|
-
pieTooltipColorBox: 'pieTooltipColorBox'
|
|
751
|
+
pieTooltipColorBox: 'pieTooltipColorBox',
|
|
752
|
+
pieFullChartTooltipCircle: 'pieFullChartTooltipCircle'
|
|
752
753
|
};
|
|
753
|
-
const SvgWrapper$1 = /*#__PURE__*/styled__default(Wrapper)( /*#__PURE__*/_templateObject$5(), pieChartclassNames.pieSliceLabel, pieChartclassNames.pieRadialLabel, pieChartclassNames.pieRadialLink);
|
|
754
|
+
const SvgWrapper$1 = /*#__PURE__*/styled__default(Wrapper)( /*#__PURE__*/_templateObject$5(), pieChartclassNames.pieSliceLabel, pieChartclassNames.pieRadialLabel, pieChartclassNames.pieRadialLink, pieChartclassNames.pieFullChartTooltipCircle);
|
|
754
755
|
|
|
755
756
|
const getMidFactor = d => d.startAngle + (d.endAngle - d.startAngle) / 2 < Math.PI ? 1 : -1;
|
|
756
757
|
const getAlign = d => {
|
|
@@ -979,7 +980,10 @@ const drawTooltip = (_ref) => {
|
|
|
979
980
|
renderTooltip,
|
|
980
981
|
arc,
|
|
981
982
|
allSlices,
|
|
982
|
-
tooltipStyle
|
|
983
|
+
tooltipStyle,
|
|
984
|
+
width,
|
|
985
|
+
height,
|
|
986
|
+
radius
|
|
983
987
|
} = _ref;
|
|
984
988
|
const container = tooltipRoot || document.querySelector('body');
|
|
985
989
|
const format = d3.format(',');
|
|
@@ -1066,11 +1070,15 @@ const drawTooltip = (_ref) => {
|
|
|
1066
1070
|
|
|
1067
1071
|
if (fullChartTooltip) {
|
|
1068
1072
|
global.on('mouseover.fulltooltip', event => setTooltip(event));
|
|
1069
|
-
global.on('
|
|
1073
|
+
global.on('mouseout.fulltooltip', () => {
|
|
1070
1074
|
tooltipContainer.html('');
|
|
1071
1075
|
setVisible();
|
|
1072
1076
|
});
|
|
1073
1077
|
|
|
1078
|
+
if (width && height) {
|
|
1079
|
+
global.append('circle').attr('class', pieChartclassNames.pieFullChartTooltipCircle).attr('r', radius).attr('cx', 0).attr('cy', 0);
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1074
1082
|
if (!tooltipBind) {
|
|
1075
1083
|
global.on('touchmove.tooltipBind mousemove.tooltipBind', event => setPosition(event));
|
|
1076
1084
|
}
|
|
@@ -1215,7 +1223,10 @@ const draw$1 = (node, props) => {
|
|
|
1215
1223
|
renderTooltip,
|
|
1216
1224
|
allSlices,
|
|
1217
1225
|
arc,
|
|
1218
|
-
tooltipStyle
|
|
1226
|
+
tooltipStyle,
|
|
1227
|
+
width,
|
|
1228
|
+
height,
|
|
1229
|
+
radius
|
|
1219
1230
|
});
|
|
1220
1231
|
}
|
|
1221
1232
|
|
|
@@ -1710,16 +1721,21 @@ const drawTooltip$1 = (_ref) => {
|
|
|
1710
1721
|
const mouseRect = mouseGlobal.append('rect').attr('width', x2 - x1).attr('height', Math.abs(y1 - y2)).attr('class', lineChartClassNames.lineChartMouseRect).attr('transform', "translate(" + x1 + ", " + y2 + ")");
|
|
1711
1722
|
const mouseLine = mouseGlobal.append('path').attr('class', lineChartClassNames.lineChartMouseLine).style('opacity', '0');
|
|
1712
1723
|
const lines = svg.selectAll("." + lineChartClassNames.lineChartLine).nodes();
|
|
1713
|
-
const circles = mouseGlobal.selectAll('circle').data(chartData
|
|
1724
|
+
const circles = mouseGlobal.selectAll('circle').data(chartData.filter((_ref3) => {
|
|
1714
1725
|
let {
|
|
1715
|
-
|
|
1726
|
+
dynamicDotOff
|
|
1716
1727
|
} = _ref3;
|
|
1717
|
-
return
|
|
1718
|
-
}).attr('
|
|
1728
|
+
return !dynamicDotOff;
|
|
1729
|
+
})).join('circle').attr('class', lineChartClassNames.lineChartMouseCircle).attr('r', dynamicCircleRadius).attr('fill', (_ref4) => {
|
|
1719
1730
|
let {
|
|
1720
1731
|
stroke
|
|
1721
1732
|
} = _ref4;
|
|
1722
1733
|
return stroke || 'none';
|
|
1734
|
+
}).attr('stroke', (_ref5) => {
|
|
1735
|
+
let {
|
|
1736
|
+
stroke
|
|
1737
|
+
} = _ref5;
|
|
1738
|
+
return stroke || 'none';
|
|
1723
1739
|
}).style('opacity', '0');
|
|
1724
1740
|
let labelContainer = d3.select("." + lineChartClassNames.lineChartMouseLabelContainer);
|
|
1725
1741
|
|
|
@@ -1780,27 +1796,27 @@ const drawTooltip$1 = (_ref) => {
|
|
|
1780
1796
|
circles.attr('transform', (lineChartData, index) => {
|
|
1781
1797
|
const value = getValue(lineChartData.values);
|
|
1782
1798
|
return positions[index] && value ? 'translate(' + x + ',' + positions[index].y + ')' : 'translate(-9999, -9999)';
|
|
1783
|
-
}).attr('style', (
|
|
1799
|
+
}).attr('style', (_ref6) => {
|
|
1784
1800
|
let {
|
|
1785
1801
|
dynamicDotStyle
|
|
1786
|
-
} =
|
|
1802
|
+
} = _ref6;
|
|
1787
1803
|
return dynamicDotStyle || '';
|
|
1788
1804
|
});
|
|
1789
|
-
const datas = chartData.map((
|
|
1805
|
+
const datas = chartData.map((_ref7, i) => {
|
|
1790
1806
|
let {
|
|
1791
1807
|
values
|
|
1792
|
-
} =
|
|
1793
|
-
rest = _objectWithoutPropertiesLoose(
|
|
1808
|
+
} = _ref7,
|
|
1809
|
+
rest = _objectWithoutPropertiesLoose(_ref7, ["values"]);
|
|
1794
1810
|
|
|
1795
1811
|
return _extends({}, rest, {
|
|
1796
1812
|
value: getValue(values),
|
|
1797
1813
|
invertValue: positions[i] ? yScale.invert(positions[i].y) : 0
|
|
1798
1814
|
});
|
|
1799
1815
|
});
|
|
1800
|
-
const noHasData = datas.every((
|
|
1816
|
+
const noHasData = datas.every((_ref8) => {
|
|
1801
1817
|
let {
|
|
1802
1818
|
value
|
|
1803
|
-
} =
|
|
1819
|
+
} = _ref8;
|
|
1804
1820
|
return isVoid(value);
|
|
1805
1821
|
});
|
|
1806
1822
|
|
|
@@ -1815,7 +1831,8 @@ const drawTooltip$1 = (_ref) => {
|
|
|
1815
1831
|
|
|
1816
1832
|
const prevValue = (_datas$Number = datas[Number(acc)]) == null ? void 0 : _datas$Number.value;
|
|
1817
1833
|
const value = (_datas$Number2 = datas[Number(key)]) == null ? void 0 : _datas$Number2.value;
|
|
1818
|
-
|
|
1834
|
+
const dynamicDotOff = argData == null ? void 0 : argData[index].dynamicDotOff;
|
|
1835
|
+
return index === 0 || isVoid(value) || dynamicDotOff ? acc : isVoid(prevValue) || positions[acc].y > positions[key].y ? key : acc;
|
|
1819
1836
|
}, '0');
|
|
1820
1837
|
const labelTexts = labels && labels.style('left', left + "px").style('top', (_, i) => {
|
|
1821
1838
|
const index = typeof stackedTooltipIndex === 'number' ? stackedTooltipIndex : stackedTooltip ? topIndex : i;
|
|
@@ -2061,7 +2078,7 @@ const draw$3 = (node, props) => {
|
|
|
2061
2078
|
filter
|
|
2062
2079
|
} = dot;
|
|
2063
2080
|
const dotsGroup = dotsGlobal.append('g').attr('class', lineChartClassNames.lineChartDotsGlobal);
|
|
2064
|
-
dotsGroup.selectAll('circle').data(values).join('circle').attr('cx', (_, index) => xScale(index)).attr('class', lineChartClassNames.lineChartDot).attr('cy', d => yScale(d)).attr('r', radius).attr('style', style || '');
|
|
2081
|
+
dotsGroup.selectAll('circle').data(values).join('circle').attr('cx', (_, index) => xScale(index)).attr('class', lineChartClassNames.lineChartDot).attr('cy', d => yScale(d)).attr('r', radius || 0).attr('style', style || '');
|
|
2065
2082
|
|
|
2066
2083
|
if (filter) {
|
|
2067
2084
|
dotsGroup.selectAll('circle').select((_, i, g) => filter(item, i, g) ? g[i] : null).remove();
|
|
@@ -2215,8 +2232,18 @@ const drawLines = (_ref) => {
|
|
|
2215
2232
|
};
|
|
2216
2233
|
};
|
|
2217
2234
|
|
|
2235
|
+
function _templateObject2$4() {
|
|
2236
|
+
const data = _taggedTemplateLiteralLoose(["\n .", " {\n z-index: 1;\n transition: all linear 144ms;\n\n .", " {\n margin-bottom: 4px;\n :last-of-type {\n margin-bottom: 0;\n }\n }\n }\n"]);
|
|
2237
|
+
|
|
2238
|
+
_templateObject2$4 = function _templateObject2() {
|
|
2239
|
+
return data;
|
|
2240
|
+
};
|
|
2241
|
+
|
|
2242
|
+
return data;
|
|
2243
|
+
}
|
|
2244
|
+
|
|
2218
2245
|
function _templateObject$a() {
|
|
2219
|
-
const data = _taggedTemplateLiteralLoose(["\n line {\n stroke-width: 1px;\n shape-rendering: crispEdges;\n }\n .", ",\n .", " {\n stroke: rgba(48, 69, 79, 0.06);\n }\n .", " {\n }\n .", " {\n fill: none;\n pointer-events: all;\n }\n .", " {\n
|
|
2246
|
+
const data = _taggedTemplateLiteralLoose(["\n line {\n stroke-width: 1px;\n shape-rendering: crispEdges;\n }\n .", ",\n .", " {\n stroke: rgba(48, 69, 79, 0.06);\n }\n .", " {\n }\n .", " {\n fill: none;\n pointer-events: all;\n }\n .", " {\n stroke-width: 1.5px;\n stroke-linejoin: round;\n stroke-linecap: round;\n }\n .", " {\n shape-rendering: auto;\n }\n .", " {\n fill-opacity: 0.24;\n }\n"]);
|
|
2220
2247
|
|
|
2221
2248
|
_templateObject$a = function _templateObject() {
|
|
2222
2249
|
return data;
|
|
@@ -2255,7 +2282,8 @@ const barChartClassNames = /*#__PURE__*/_extends({
|
|
|
2255
2282
|
barChartGridLineYZero: 'barChartGridLineYZero',
|
|
2256
2283
|
barChartGridLineY: 'barChartGridLineY'
|
|
2257
2284
|
}, tooltipClassnames, labelClassnames, barChartLinesClassNames);
|
|
2258
|
-
const SvgWrapper$4 = /*#__PURE__*/styled__default(Wrapper)( /*#__PURE__*/_templateObject$a(), barChartClassNames.barChartGridLineX, barChartClassNames.barChartGridLineY, barChartClassNames.barChartMouseRect, barChartClassNames.barChartMouseRect, barChartClassNames.
|
|
2285
|
+
const SvgWrapper$4 = /*#__PURE__*/styled__default(Wrapper)( /*#__PURE__*/_templateObject$a(), barChartClassNames.barChartGridLineX, barChartClassNames.barChartGridLineY, barChartClassNames.barChartMouseRect, barChartClassNames.barChartMouseRect, barChartClassNames.barChartLinesGlobal, barChartClassNames.barChartLine, barChartClassNames.barChartArea);
|
|
2286
|
+
const TooltipStyles$1 = /*#__PURE__*/styled.createGlobalStyle( /*#__PURE__*/_templateObject2$4(), barChartClassNames.barChartMouseTooltip, barChartClassNames.barChartTooltipItem);
|
|
2259
2287
|
|
|
2260
2288
|
const drawGrid$1 = (_ref) => {
|
|
2261
2289
|
let {
|
|
@@ -2440,7 +2468,9 @@ const drawTooltip$2 = (_ref) => {
|
|
|
2440
2468
|
setTooltipPosition,
|
|
2441
2469
|
onLabelItem,
|
|
2442
2470
|
isBarTooltip,
|
|
2443
|
-
bars
|
|
2471
|
+
bars,
|
|
2472
|
+
tooltipRoot,
|
|
2473
|
+
tooltipClassName
|
|
2444
2474
|
} = _ref;
|
|
2445
2475
|
d3.select(node).select("." + barChartClassNames.barChartMouseContainer).remove();
|
|
2446
2476
|
const xScaleBandDomain = xScale.domain();
|
|
@@ -2473,19 +2503,21 @@ const drawTooltip$2 = (_ref) => {
|
|
|
2473
2503
|
}, []);
|
|
2474
2504
|
const mouseGlobal = svg.append('g').attr('class', 'lineChartMouseGlobal');
|
|
2475
2505
|
const mouseRect = mouseGlobal.append('rect').attr('width', x2 - x1).attr('height', Math.abs(y1 - y2)).attr('class', barChartClassNames.barChartMouseRect).attr('transform', "translate(" + x1 + ", " + y2 + ")");
|
|
2476
|
-
const container = d3.select(node).append('div').attr('class', barChartClassNames.barChartMouseContainer);
|
|
2477
2506
|
|
|
2478
2507
|
if (dynamicTooltipEnable) {
|
|
2479
|
-
const
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2508
|
+
const tooltipContainer = tooltipRoot || document.querySelector('body');
|
|
2509
|
+
let tooltip = d3.select("." + barChartClassNames.barChartMouseTooltip);
|
|
2510
|
+
|
|
2511
|
+
if (tooltip.size() === 0) {
|
|
2512
|
+
tooltip = d3.select(tooltipContainer).append('div').attr('class', barChartClassNames.barChartMouseTooltip).style('opacity', '0').style('position', 'absolute').html(() => {
|
|
2513
|
+
const html = ReactDOMServer.renderToString(React__default.createElement(TooltipFlex, {
|
|
2514
|
+
className: barChartClassNames.barChartTooltipFlex
|
|
2515
|
+
}));
|
|
2516
|
+
return html;
|
|
2517
|
+
});
|
|
2518
|
+
}
|
|
2519
|
+
|
|
2487
2520
|
const barChartTootipFlex = tooltip.select("." + barChartClassNames.barChartTooltipFlex);
|
|
2488
|
-
const barChartTooltip = tooltip.select("." + barChartClassNames.barChartTooltip);
|
|
2489
2521
|
let isVisible = false;
|
|
2490
2522
|
let flagCurrIndex = null;
|
|
2491
2523
|
|
|
@@ -2495,20 +2527,25 @@ const drawTooltip$2 = (_ref) => {
|
|
|
2495
2527
|
tooltip.style('opacity', opacity);
|
|
2496
2528
|
|
|
2497
2529
|
if (!isVisible) {
|
|
2530
|
+
tooltip.attr('class', barChartClassNames.barChartMouseTooltip);
|
|
2498
2531
|
flagCurrIndex = null;
|
|
2499
2532
|
tooltip.style('transition', 'none');
|
|
2500
2533
|
tooltip.style('top', null);
|
|
2501
2534
|
tooltip.style('left', null);
|
|
2502
2535
|
} else {
|
|
2536
|
+
tooltip.attr('class', barChartClassNames.barChartMouseTooltip + " " + (tooltipClassName || ''));
|
|
2503
2537
|
tooltip.style('transition', null);
|
|
2504
2538
|
}
|
|
2505
2539
|
};
|
|
2506
2540
|
|
|
2507
2541
|
mouseRect.on('mouseout.tooltip', () => setVisible());
|
|
2508
2542
|
mouseRect.on('touchmove.tooltip mousemove.tooltip', event => {
|
|
2543
|
+
const [docX, docY] = d3.pointer(event, document);
|
|
2509
2544
|
const [rectrX] = d3.pointer(event, mouseRect);
|
|
2510
|
-
const [nodeX] = d3.pointer(event, node);
|
|
2545
|
+
const [nodeX, nodeY] = d3.pointer(event, node);
|
|
2511
2546
|
const x = rectrX - (rectrX - nodeX);
|
|
2547
|
+
const offsetX = docX - nodeX;
|
|
2548
|
+
const offsetY = docY - nodeY;
|
|
2512
2549
|
const currIndex = groups.findIndex(value => x <= value);
|
|
2513
2550
|
|
|
2514
2551
|
if (isBarTooltip) {
|
|
@@ -2528,8 +2565,8 @@ const drawTooltip$2 = (_ref) => {
|
|
|
2528
2565
|
}
|
|
2529
2566
|
}
|
|
2530
2567
|
|
|
2531
|
-
const top = typeof tooltipY === 'number' ? tooltipY : topYDomain[currIndex] - y2;
|
|
2532
|
-
const left = tooltipBind ? (xScale(currIndex.toString()) || 0) + bandwidth / 2 : x;
|
|
2568
|
+
const top = (typeof tooltipY === 'number' ? tooltipY : topYDomain[currIndex] - y2) + offsetY;
|
|
2569
|
+
const left = (tooltipBind ? (xScale(currIndex.toString()) || 0) + bandwidth / 2 : x) + offsetX;
|
|
2533
2570
|
|
|
2534
2571
|
if (tooltipBind && flagCurrIndex === currIndex) {
|
|
2535
2572
|
return;
|
|
@@ -2587,8 +2624,10 @@ const drawTooltip$2 = (_ref) => {
|
|
|
2587
2624
|
setVisible(true);
|
|
2588
2625
|
}
|
|
2589
2626
|
|
|
2590
|
-
|
|
2591
|
-
const html = ReactDOMServer.renderToString(React__default.createElement(
|
|
2627
|
+
barChartTootipFlex.html(() => {
|
|
2628
|
+
const html = ReactDOMServer.renderToString(React__default.createElement(TooltipContainer, {
|
|
2629
|
+
className: barChartClassNames.barChartTooltip
|
|
2630
|
+
}, currData && currData[0] && React__default.createElement(TooltipGroupName, {
|
|
2592
2631
|
className: barChartClassNames.barChartTooltipGroupName
|
|
2593
2632
|
}, currData[0].groupName), currData && currData.map((_ref5) => {
|
|
2594
2633
|
let {
|
|
@@ -2632,6 +2671,7 @@ const drawTooltip$2 = (_ref) => {
|
|
|
2632
2671
|
});
|
|
2633
2672
|
}
|
|
2634
2673
|
|
|
2674
|
+
const container = d3.select(node).append('div').attr('class', barChartClassNames.barChartMouseContainer);
|
|
2635
2675
|
const labelContainer = container.append('div').attr('class', barChartClassNames.barChartLabelContainer).style('position', 'absolute').style('top', y2 + "px");
|
|
2636
2676
|
|
|
2637
2677
|
if (labelPosition) {
|
|
@@ -2763,7 +2803,9 @@ const draw$4 = (node, props) => {
|
|
|
2763
2803
|
setTooltipPosition,
|
|
2764
2804
|
onLabelItem,
|
|
2765
2805
|
isBarTooltip,
|
|
2766
|
-
xScaleItemWidth
|
|
2806
|
+
xScaleItemWidth,
|
|
2807
|
+
tooltipRoot,
|
|
2808
|
+
tooltipClassName
|
|
2767
2809
|
} = props;
|
|
2768
2810
|
|
|
2769
2811
|
if (node !== null && data.length) {
|
|
@@ -2918,7 +2960,9 @@ const draw$4 = (node, props) => {
|
|
|
2918
2960
|
setTooltipPosition,
|
|
2919
2961
|
onLabelItem,
|
|
2920
2962
|
isBarTooltip,
|
|
2921
|
-
bars: groups
|
|
2963
|
+
bars: groups,
|
|
2964
|
+
tooltipRoot,
|
|
2965
|
+
tooltipClassName
|
|
2922
2966
|
});
|
|
2923
2967
|
}
|
|
2924
2968
|
|
|
@@ -2949,7 +2993,7 @@ const BarChart = props => {
|
|
|
2949
2993
|
return React__default.createElement("div", {
|
|
2950
2994
|
className: className,
|
|
2951
2995
|
style: style
|
|
2952
|
-
}, React__default.createElement(SvgWrapper$4, {
|
|
2996
|
+
}, React__default.createElement(TooltipStyles$1, null), React__default.createElement(SvgWrapper$4, {
|
|
2953
2997
|
ref: ref
|
|
2954
2998
|
}, children));
|
|
2955
2999
|
};
|
|
@@ -3076,10 +3120,10 @@ function _templateObject3$2() {
|
|
|
3076
3120
|
return data;
|
|
3077
3121
|
}
|
|
3078
3122
|
|
|
3079
|
-
function _templateObject2$
|
|
3123
|
+
function _templateObject2$5() {
|
|
3080
3124
|
const data = _taggedTemplateLiteralLoose(["\n text-align: right;\n"]);
|
|
3081
3125
|
|
|
3082
|
-
_templateObject2$
|
|
3126
|
+
_templateObject2$5 = function _templateObject2() {
|
|
3083
3127
|
return data;
|
|
3084
3128
|
};
|
|
3085
3129
|
|
|
@@ -3118,7 +3162,7 @@ const horizontalBarChartClassNames = {
|
|
|
3118
3162
|
horizontalBarChartTooltipValue: 'horizontalBarChartTooltipValue'
|
|
3119
3163
|
};
|
|
3120
3164
|
const Table = /*#__PURE__*/styled__default.table( /*#__PURE__*/_templateObject$b());
|
|
3121
|
-
const LabelCell = /*#__PURE__*/styled__default.div( /*#__PURE__*/_templateObject2$
|
|
3165
|
+
const LabelCell = /*#__PURE__*/styled__default.div( /*#__PURE__*/_templateObject2$5());
|
|
3122
3166
|
const BarFlex = /*#__PURE__*/styled__default.div( /*#__PURE__*/_templateObject3$2());
|
|
3123
3167
|
const BarsTd = /*#__PURE__*/styled__default.td( /*#__PURE__*/_templateObject4$2());
|
|
3124
3168
|
const TooltipFlex$1 = /*#__PURE__*/styled__default(TooltipFlex)( /*#__PURE__*/_templateObject5$2());
|
|
@@ -3155,7 +3199,7 @@ const Tooltip = (_ref) => {
|
|
|
3155
3199
|
}
|
|
3156
3200
|
}), name && React__default.createElement(Name$1, {
|
|
3157
3201
|
className: horizontalBarChartClassNames.horizontalBarChartTooltipName
|
|
3158
|
-
},
|
|
3202
|
+
}, name), React__default.createElement(Value, {
|
|
3159
3203
|
className: horizontalBarChartClassNames.horizontalBarChartTooltipValue
|
|
3160
3204
|
}, format(value)));
|
|
3161
3205
|
})));
|
|
@@ -3168,7 +3212,8 @@ const useTooltip = (_ref) => {
|
|
|
3168
3212
|
tooltipBind,
|
|
3169
3213
|
tooltipStyle,
|
|
3170
3214
|
tooltipRoot,
|
|
3171
|
-
tooltipClassName
|
|
3215
|
+
tooltipClassName,
|
|
3216
|
+
hideTooltip
|
|
3172
3217
|
} = _ref;
|
|
3173
3218
|
React.useEffect(() => {
|
|
3174
3219
|
const container = tooltipRoot || document.querySelector('body');
|
|
@@ -3207,8 +3252,9 @@ const useTooltip = (_ref) => {
|
|
|
3207
3252
|
const onMouseLeave = React.useCallback(() => {
|
|
3208
3253
|
if (rootElement) {
|
|
3209
3254
|
rootElement.style.visibility = 'hidden';
|
|
3255
|
+
hideTooltip && hideTooltip();
|
|
3210
3256
|
}
|
|
3211
|
-
}, []);
|
|
3257
|
+
}, [hideTooltip]);
|
|
3212
3258
|
return [onMouseMove, onMouseLeave];
|
|
3213
3259
|
};
|
|
3214
3260
|
|
|
@@ -3308,10 +3354,10 @@ function _templateObject3$3() {
|
|
|
3308
3354
|
return data;
|
|
3309
3355
|
}
|
|
3310
3356
|
|
|
3311
|
-
function _templateObject2$
|
|
3357
|
+
function _templateObject2$6() {
|
|
3312
3358
|
const data = _taggedTemplateLiteralLoose(["\n position: relative;\n height: 1rem;\n"]);
|
|
3313
3359
|
|
|
3314
|
-
_templateObject2$
|
|
3360
|
+
_templateObject2$6 = function _templateObject2() {
|
|
3315
3361
|
return data;
|
|
3316
3362
|
};
|
|
3317
3363
|
|
|
@@ -3328,7 +3374,7 @@ function _templateObject$d() {
|
|
|
3328
3374
|
return data;
|
|
3329
3375
|
}
|
|
3330
3376
|
const TickTd = /*#__PURE__*/styled__default.td( /*#__PURE__*/_templateObject$d());
|
|
3331
|
-
const Ticks = /*#__PURE__*/styled__default.div( /*#__PURE__*/_templateObject2$
|
|
3377
|
+
const Ticks = /*#__PURE__*/styled__default.div( /*#__PURE__*/_templateObject2$6());
|
|
3332
3378
|
const Tick = /*#__PURE__*/styled__default.div( /*#__PURE__*/_templateObject3$3());
|
|
3333
3379
|
|
|
3334
3380
|
const XScale = (_ref) => {
|
|
@@ -3388,7 +3434,8 @@ const HorizontalBarChart = (_ref) => {
|
|
|
3388
3434
|
thead,
|
|
3389
3435
|
withoutXScale,
|
|
3390
3436
|
stackedTooltip,
|
|
3391
|
-
fullChartTooltip
|
|
3437
|
+
fullChartTooltip,
|
|
3438
|
+
hideTooltip
|
|
3392
3439
|
} = _ref;
|
|
3393
3440
|
const {
|
|
3394
3441
|
fullMax,
|
|
@@ -3403,7 +3450,8 @@ const HorizontalBarChart = (_ref) => {
|
|
|
3403
3450
|
renderTooltip,
|
|
3404
3451
|
tooltipBind,
|
|
3405
3452
|
tooltipStyle,
|
|
3406
|
-
tooltipClassName
|
|
3453
|
+
tooltipClassName,
|
|
3454
|
+
hideTooltip
|
|
3407
3455
|
});
|
|
3408
3456
|
const Stack = useStackWrapper(stackedTooltip);
|
|
3409
3457
|
return React__default.createElement(Table, {
|
|
@@ -3484,10 +3532,10 @@ HorizontalBarChart.defaultProps = {
|
|
|
3484
3532
|
withoutXScale: false
|
|
3485
3533
|
};
|
|
3486
3534
|
|
|
3487
|
-
function _templateObject2$
|
|
3535
|
+
function _templateObject2$7() {
|
|
3488
3536
|
const data = _taggedTemplateLiteralLoose(["\n .", " {\n position: absolute;\n transition: opacity 150ms cubic-bezier(0.2, 1, 0.6, 1);\n pointer-events: none;\n z-index: 1;\n }\n"]);
|
|
3489
3537
|
|
|
3490
|
-
_templateObject2$
|
|
3538
|
+
_templateObject2$7 = function _templateObject2() {
|
|
3491
3539
|
return data;
|
|
3492
3540
|
};
|
|
3493
3541
|
|
|
@@ -3518,7 +3566,7 @@ const bubbleChartClassNames = {
|
|
|
3518
3566
|
bubbleChartTip: 'bubbleChartTip'
|
|
3519
3567
|
};
|
|
3520
3568
|
const SvgWrapper$5 = /*#__PURE__*/styled__default(Wrapper)( /*#__PURE__*/_templateObject$e(), bubbleChartClassNames.bubbleChartYAxis, bubbleChartClassNames.bubbleChartXAxis, bubbleChartClassNames.bubbleChartGridGlobal, bubbleChartClassNames.bubbleChartGridLineX, bubbleChartClassNames.bubbleChartGridLineY, bubbleChartClassNames.bubbleChartYScaleLabel);
|
|
3521
|
-
const TooltipStyles$
|
|
3569
|
+
const TooltipStyles$2 = /*#__PURE__*/styled.createGlobalStyle( /*#__PURE__*/_templateObject2$7(), bubbleChartClassNames.bubbleChartTooltipContainer);
|
|
3522
3570
|
|
|
3523
3571
|
const drawGrid$2 = (_ref) => {
|
|
3524
3572
|
let {
|
|
@@ -3800,7 +3848,7 @@ const BubbleChart = props => {
|
|
|
3800
3848
|
return React__default.createElement("div", {
|
|
3801
3849
|
className: className,
|
|
3802
3850
|
style: style
|
|
3803
|
-
}, React__default.createElement(TooltipStyles$
|
|
3851
|
+
}, React__default.createElement(TooltipStyles$2, null), React__default.createElement(SvgWrapper$5, {
|
|
3804
3852
|
ref: ref
|
|
3805
3853
|
}, children));
|
|
3806
3854
|
};
|