@evergis/charts 2.0.17 → 2.0.21
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.cjs.development.js +58 -31
- 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 +58 -31
- 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;
|
|
@@ -2232,8 +2232,18 @@ const drawLines = (_ref) => {
|
|
|
2232
2232
|
};
|
|
2233
2233
|
};
|
|
2234
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
|
+
|
|
2235
2245
|
function _templateObject$a() {
|
|
2236
|
-
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"]);
|
|
2237
2247
|
|
|
2238
2248
|
_templateObject$a = function _templateObject() {
|
|
2239
2249
|
return data;
|
|
@@ -2272,7 +2282,8 @@ const barChartClassNames = /*#__PURE__*/_extends({
|
|
|
2272
2282
|
barChartGridLineYZero: 'barChartGridLineYZero',
|
|
2273
2283
|
barChartGridLineY: 'barChartGridLineY'
|
|
2274
2284
|
}, tooltipClassnames, labelClassnames, barChartLinesClassNames);
|
|
2275
|
-
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);
|
|
2276
2287
|
|
|
2277
2288
|
const drawGrid$1 = (_ref) => {
|
|
2278
2289
|
let {
|
|
@@ -2457,7 +2468,9 @@ const drawTooltip$2 = (_ref) => {
|
|
|
2457
2468
|
setTooltipPosition,
|
|
2458
2469
|
onLabelItem,
|
|
2459
2470
|
isBarTooltip,
|
|
2460
|
-
bars
|
|
2471
|
+
bars,
|
|
2472
|
+
tooltipRoot,
|
|
2473
|
+
tooltipClassName
|
|
2461
2474
|
} = _ref;
|
|
2462
2475
|
d3.select(node).select("." + barChartClassNames.barChartMouseContainer).remove();
|
|
2463
2476
|
const xScaleBandDomain = xScale.domain();
|
|
@@ -2490,19 +2503,21 @@ const drawTooltip$2 = (_ref) => {
|
|
|
2490
2503
|
}, []);
|
|
2491
2504
|
const mouseGlobal = svg.append('g').attr('class', 'lineChartMouseGlobal');
|
|
2492
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 + ")");
|
|
2493
|
-
const container = d3.select(node).append('div').attr('class', barChartClassNames.barChartMouseContainer);
|
|
2494
2506
|
|
|
2495
2507
|
if (dynamicTooltipEnable) {
|
|
2496
|
-
const
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
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
|
+
|
|
2504
2520
|
const barChartTootipFlex = tooltip.select("." + barChartClassNames.barChartTooltipFlex);
|
|
2505
|
-
const barChartTooltip = tooltip.select("." + barChartClassNames.barChartTooltip);
|
|
2506
2521
|
let isVisible = false;
|
|
2507
2522
|
let flagCurrIndex = null;
|
|
2508
2523
|
|
|
@@ -2512,20 +2527,25 @@ const drawTooltip$2 = (_ref) => {
|
|
|
2512
2527
|
tooltip.style('opacity', opacity);
|
|
2513
2528
|
|
|
2514
2529
|
if (!isVisible) {
|
|
2530
|
+
tooltip.attr('class', barChartClassNames.barChartMouseTooltip);
|
|
2515
2531
|
flagCurrIndex = null;
|
|
2516
2532
|
tooltip.style('transition', 'none');
|
|
2517
2533
|
tooltip.style('top', null);
|
|
2518
2534
|
tooltip.style('left', null);
|
|
2519
2535
|
} else {
|
|
2536
|
+
tooltip.attr('class', barChartClassNames.barChartMouseTooltip + " " + (tooltipClassName || ''));
|
|
2520
2537
|
tooltip.style('transition', null);
|
|
2521
2538
|
}
|
|
2522
2539
|
};
|
|
2523
2540
|
|
|
2524
2541
|
mouseRect.on('mouseout.tooltip', () => setVisible());
|
|
2525
2542
|
mouseRect.on('touchmove.tooltip mousemove.tooltip', event => {
|
|
2543
|
+
const [docX, docY] = d3.pointer(event, document);
|
|
2526
2544
|
const [rectrX] = d3.pointer(event, mouseRect);
|
|
2527
|
-
const [nodeX] = d3.pointer(event, node);
|
|
2545
|
+
const [nodeX, nodeY] = d3.pointer(event, node);
|
|
2528
2546
|
const x = rectrX - (rectrX - nodeX);
|
|
2547
|
+
const offsetX = docX - nodeX;
|
|
2548
|
+
const offsetY = docY - nodeY;
|
|
2529
2549
|
const currIndex = groups.findIndex(value => x <= value);
|
|
2530
2550
|
|
|
2531
2551
|
if (isBarTooltip) {
|
|
@@ -2545,8 +2565,8 @@ const drawTooltip$2 = (_ref) => {
|
|
|
2545
2565
|
}
|
|
2546
2566
|
}
|
|
2547
2567
|
|
|
2548
|
-
const top = typeof tooltipY === 'number' ? tooltipY : topYDomain[currIndex] - y2;
|
|
2549
|
-
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;
|
|
2550
2570
|
|
|
2551
2571
|
if (tooltipBind && flagCurrIndex === currIndex) {
|
|
2552
2572
|
return;
|
|
@@ -2604,8 +2624,10 @@ const drawTooltip$2 = (_ref) => {
|
|
|
2604
2624
|
setVisible(true);
|
|
2605
2625
|
}
|
|
2606
2626
|
|
|
2607
|
-
|
|
2608
|
-
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, {
|
|
2609
2631
|
className: barChartClassNames.barChartTooltipGroupName
|
|
2610
2632
|
}, currData[0].groupName), currData && currData.map((_ref5) => {
|
|
2611
2633
|
let {
|
|
@@ -2649,6 +2671,7 @@ const drawTooltip$2 = (_ref) => {
|
|
|
2649
2671
|
});
|
|
2650
2672
|
}
|
|
2651
2673
|
|
|
2674
|
+
const container = d3.select(node).append('div').attr('class', barChartClassNames.barChartMouseContainer);
|
|
2652
2675
|
const labelContainer = container.append('div').attr('class', barChartClassNames.barChartLabelContainer).style('position', 'absolute').style('top', y2 + "px");
|
|
2653
2676
|
|
|
2654
2677
|
if (labelPosition) {
|
|
@@ -2780,7 +2803,9 @@ const draw$4 = (node, props) => {
|
|
|
2780
2803
|
setTooltipPosition,
|
|
2781
2804
|
onLabelItem,
|
|
2782
2805
|
isBarTooltip,
|
|
2783
|
-
xScaleItemWidth
|
|
2806
|
+
xScaleItemWidth,
|
|
2807
|
+
tooltipRoot,
|
|
2808
|
+
tooltipClassName
|
|
2784
2809
|
} = props;
|
|
2785
2810
|
|
|
2786
2811
|
if (node !== null && data.length) {
|
|
@@ -2935,7 +2960,9 @@ const draw$4 = (node, props) => {
|
|
|
2935
2960
|
setTooltipPosition,
|
|
2936
2961
|
onLabelItem,
|
|
2937
2962
|
isBarTooltip,
|
|
2938
|
-
bars: groups
|
|
2963
|
+
bars: groups,
|
|
2964
|
+
tooltipRoot,
|
|
2965
|
+
tooltipClassName
|
|
2939
2966
|
});
|
|
2940
2967
|
}
|
|
2941
2968
|
|
|
@@ -2966,7 +2993,7 @@ const BarChart = props => {
|
|
|
2966
2993
|
return React__default.createElement("div", {
|
|
2967
2994
|
className: className,
|
|
2968
2995
|
style: style
|
|
2969
|
-
}, React__default.createElement(SvgWrapper$4, {
|
|
2996
|
+
}, React__default.createElement(TooltipStyles$1, null), React__default.createElement(SvgWrapper$4, {
|
|
2970
2997
|
ref: ref
|
|
2971
2998
|
}, children));
|
|
2972
2999
|
};
|
|
@@ -3093,10 +3120,10 @@ function _templateObject3$2() {
|
|
|
3093
3120
|
return data;
|
|
3094
3121
|
}
|
|
3095
3122
|
|
|
3096
|
-
function _templateObject2$
|
|
3123
|
+
function _templateObject2$5() {
|
|
3097
3124
|
const data = _taggedTemplateLiteralLoose(["\n text-align: right;\n"]);
|
|
3098
3125
|
|
|
3099
|
-
_templateObject2$
|
|
3126
|
+
_templateObject2$5 = function _templateObject2() {
|
|
3100
3127
|
return data;
|
|
3101
3128
|
};
|
|
3102
3129
|
|
|
@@ -3135,7 +3162,7 @@ const horizontalBarChartClassNames = {
|
|
|
3135
3162
|
horizontalBarChartTooltipValue: 'horizontalBarChartTooltipValue'
|
|
3136
3163
|
};
|
|
3137
3164
|
const Table = /*#__PURE__*/styled__default.table( /*#__PURE__*/_templateObject$b());
|
|
3138
|
-
const LabelCell = /*#__PURE__*/styled__default.div( /*#__PURE__*/_templateObject2$
|
|
3165
|
+
const LabelCell = /*#__PURE__*/styled__default.div( /*#__PURE__*/_templateObject2$5());
|
|
3139
3166
|
const BarFlex = /*#__PURE__*/styled__default.div( /*#__PURE__*/_templateObject3$2());
|
|
3140
3167
|
const BarsTd = /*#__PURE__*/styled__default.td( /*#__PURE__*/_templateObject4$2());
|
|
3141
3168
|
const TooltipFlex$1 = /*#__PURE__*/styled__default(TooltipFlex)( /*#__PURE__*/_templateObject5$2());
|
|
@@ -3327,10 +3354,10 @@ function _templateObject3$3() {
|
|
|
3327
3354
|
return data;
|
|
3328
3355
|
}
|
|
3329
3356
|
|
|
3330
|
-
function _templateObject2$
|
|
3357
|
+
function _templateObject2$6() {
|
|
3331
3358
|
const data = _taggedTemplateLiteralLoose(["\n position: relative;\n height: 1rem;\n"]);
|
|
3332
3359
|
|
|
3333
|
-
_templateObject2$
|
|
3360
|
+
_templateObject2$6 = function _templateObject2() {
|
|
3334
3361
|
return data;
|
|
3335
3362
|
};
|
|
3336
3363
|
|
|
@@ -3347,7 +3374,7 @@ function _templateObject$d() {
|
|
|
3347
3374
|
return data;
|
|
3348
3375
|
}
|
|
3349
3376
|
const TickTd = /*#__PURE__*/styled__default.td( /*#__PURE__*/_templateObject$d());
|
|
3350
|
-
const Ticks = /*#__PURE__*/styled__default.div( /*#__PURE__*/_templateObject2$
|
|
3377
|
+
const Ticks = /*#__PURE__*/styled__default.div( /*#__PURE__*/_templateObject2$6());
|
|
3351
3378
|
const Tick = /*#__PURE__*/styled__default.div( /*#__PURE__*/_templateObject3$3());
|
|
3352
3379
|
|
|
3353
3380
|
const XScale = (_ref) => {
|
|
@@ -3505,10 +3532,10 @@ HorizontalBarChart.defaultProps = {
|
|
|
3505
3532
|
withoutXScale: false
|
|
3506
3533
|
};
|
|
3507
3534
|
|
|
3508
|
-
function _templateObject2$
|
|
3535
|
+
function _templateObject2$7() {
|
|
3509
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"]);
|
|
3510
3537
|
|
|
3511
|
-
_templateObject2$
|
|
3538
|
+
_templateObject2$7 = function _templateObject2() {
|
|
3512
3539
|
return data;
|
|
3513
3540
|
};
|
|
3514
3541
|
|
|
@@ -3539,7 +3566,7 @@ const bubbleChartClassNames = {
|
|
|
3539
3566
|
bubbleChartTip: 'bubbleChartTip'
|
|
3540
3567
|
};
|
|
3541
3568
|
const SvgWrapper$5 = /*#__PURE__*/styled__default(Wrapper)( /*#__PURE__*/_templateObject$e(), bubbleChartClassNames.bubbleChartYAxis, bubbleChartClassNames.bubbleChartXAxis, bubbleChartClassNames.bubbleChartGridGlobal, bubbleChartClassNames.bubbleChartGridLineX, bubbleChartClassNames.bubbleChartGridLineY, bubbleChartClassNames.bubbleChartYScaleLabel);
|
|
3542
|
-
const TooltipStyles$
|
|
3569
|
+
const TooltipStyles$2 = /*#__PURE__*/styled.createGlobalStyle( /*#__PURE__*/_templateObject2$7(), bubbleChartClassNames.bubbleChartTooltipContainer);
|
|
3543
3570
|
|
|
3544
3571
|
const drawGrid$2 = (_ref) => {
|
|
3545
3572
|
let {
|
|
@@ -3821,7 +3848,7 @@ const BubbleChart = props => {
|
|
|
3821
3848
|
return React__default.createElement("div", {
|
|
3822
3849
|
className: className,
|
|
3823
3850
|
style: style
|
|
3824
|
-
}, React__default.createElement(TooltipStyles$
|
|
3851
|
+
}, React__default.createElement(TooltipStyles$2, null), React__default.createElement(SvgWrapper$5, {
|
|
3825
3852
|
ref: ref
|
|
3826
3853
|
}, children));
|
|
3827
3854
|
};
|