@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.
@@ -2224,8 +2224,18 @@ const drawLines = (_ref) => {
2224
2224
  };
2225
2225
  };
2226
2226
 
2227
+ function _templateObject2$4() {
2228
+ 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"]);
2229
+
2230
+ _templateObject2$4 = function _templateObject2() {
2231
+ return data;
2232
+ };
2233
+
2234
+ return data;
2235
+ }
2236
+
2227
2237
  function _templateObject$a() {
2228
- 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 z-index: 1;\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 .", " {\n margin-bottom: 4px;\n :last-of-type {\n margin-bottom: 0;\n }\n }\n"]);
2238
+ 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"]);
2229
2239
 
2230
2240
  _templateObject$a = function _templateObject() {
2231
2241
  return data;
@@ -2264,7 +2274,8 @@ const barChartClassNames = /*#__PURE__*/_extends({
2264
2274
  barChartGridLineYZero: 'barChartGridLineYZero',
2265
2275
  barChartGridLineY: 'barChartGridLineY'
2266
2276
  }, tooltipClassnames, labelClassnames, barChartLinesClassNames);
2267
- const SvgWrapper$4 = /*#__PURE__*/styled(Wrapper)( /*#__PURE__*/_templateObject$a(), barChartClassNames.barChartGridLineX, barChartClassNames.barChartGridLineY, barChartClassNames.barChartMouseRect, barChartClassNames.barChartMouseRect, barChartClassNames.barChartMouseTooltip, barChartClassNames.barChartLinesGlobal, barChartClassNames.barChartLine, barChartClassNames.barChartArea, barChartClassNames.barChartTooltipItem);
2277
+ const SvgWrapper$4 = /*#__PURE__*/styled(Wrapper)( /*#__PURE__*/_templateObject$a(), barChartClassNames.barChartGridLineX, barChartClassNames.barChartGridLineY, barChartClassNames.barChartMouseRect, barChartClassNames.barChartMouseRect, barChartClassNames.barChartLinesGlobal, barChartClassNames.barChartLine, barChartClassNames.barChartArea);
2278
+ const TooltipStyles$1 = /*#__PURE__*/createGlobalStyle( /*#__PURE__*/_templateObject2$4(), barChartClassNames.barChartMouseTooltip, barChartClassNames.barChartTooltipItem);
2268
2279
 
2269
2280
  const drawGrid$1 = (_ref) => {
2270
2281
  let {
@@ -2449,7 +2460,9 @@ const drawTooltip$2 = (_ref) => {
2449
2460
  setTooltipPosition,
2450
2461
  onLabelItem,
2451
2462
  isBarTooltip,
2452
- bars
2463
+ bars,
2464
+ tooltipRoot,
2465
+ tooltipClassName
2453
2466
  } = _ref;
2454
2467
  select(node).select("." + barChartClassNames.barChartMouseContainer).remove();
2455
2468
  const xScaleBandDomain = xScale.domain();
@@ -2482,19 +2495,21 @@ const drawTooltip$2 = (_ref) => {
2482
2495
  }, []);
2483
2496
  const mouseGlobal = svg.append('g').attr('class', 'lineChartMouseGlobal');
2484
2497
  const mouseRect = mouseGlobal.append('rect').attr('width', x2 - x1).attr('height', Math.abs(y1 - y2)).attr('class', barChartClassNames.barChartMouseRect).attr('transform', "translate(" + x1 + ", " + y2 + ")");
2485
- const container = select(node).append('div').attr('class', barChartClassNames.barChartMouseContainer);
2486
2498
 
2487
2499
  if (dynamicTooltipEnable) {
2488
- const tooltip = container.append('div').attr('class', barChartClassNames.barChartMouseTooltip).style('opacity', '0').style('position', 'absolute').html(() => {
2489
- const html = ReactDOMServer.renderToString(React.createElement(TooltipFlex, {
2490
- className: barChartClassNames.barChartTooltipFlex
2491
- }, React.createElement(TooltipContainer, {
2492
- className: barChartClassNames.barChartTooltip
2493
- })));
2494
- return html;
2495
- });
2500
+ const tooltipContainer = tooltipRoot || document.querySelector('body');
2501
+ let tooltip = select("." + barChartClassNames.barChartMouseTooltip);
2502
+
2503
+ if (tooltip.size() === 0) {
2504
+ tooltip = select(tooltipContainer).append('div').attr('class', barChartClassNames.barChartMouseTooltip).style('opacity', '0').style('position', 'absolute').html(() => {
2505
+ const html = ReactDOMServer.renderToString(React.createElement(TooltipFlex, {
2506
+ className: barChartClassNames.barChartTooltipFlex
2507
+ }));
2508
+ return html;
2509
+ });
2510
+ }
2511
+
2496
2512
  const barChartTootipFlex = tooltip.select("." + barChartClassNames.barChartTooltipFlex);
2497
- const barChartTooltip = tooltip.select("." + barChartClassNames.barChartTooltip);
2498
2513
  let isVisible = false;
2499
2514
  let flagCurrIndex = null;
2500
2515
 
@@ -2504,20 +2519,25 @@ const drawTooltip$2 = (_ref) => {
2504
2519
  tooltip.style('opacity', opacity);
2505
2520
 
2506
2521
  if (!isVisible) {
2522
+ tooltip.attr('class', barChartClassNames.barChartMouseTooltip);
2507
2523
  flagCurrIndex = null;
2508
2524
  tooltip.style('transition', 'none');
2509
2525
  tooltip.style('top', null);
2510
2526
  tooltip.style('left', null);
2511
2527
  } else {
2528
+ tooltip.attr('class', barChartClassNames.barChartMouseTooltip + " " + (tooltipClassName || ''));
2512
2529
  tooltip.style('transition', null);
2513
2530
  }
2514
2531
  };
2515
2532
 
2516
2533
  mouseRect.on('mouseout.tooltip', () => setVisible());
2517
2534
  mouseRect.on('touchmove.tooltip mousemove.tooltip', event => {
2535
+ const [docX, docY] = pointer(event, document);
2518
2536
  const [rectrX] = pointer(event, mouseRect);
2519
- const [nodeX] = pointer(event, node);
2537
+ const [nodeX, nodeY] = pointer(event, node);
2520
2538
  const x = rectrX - (rectrX - nodeX);
2539
+ const offsetX = docX - nodeX;
2540
+ const offsetY = docY - nodeY;
2521
2541
  const currIndex = groups.findIndex(value => x <= value);
2522
2542
 
2523
2543
  if (isBarTooltip) {
@@ -2537,8 +2557,8 @@ const drawTooltip$2 = (_ref) => {
2537
2557
  }
2538
2558
  }
2539
2559
 
2540
- const top = typeof tooltipY === 'number' ? tooltipY : topYDomain[currIndex] - y2;
2541
- const left = tooltipBind ? (xScale(currIndex.toString()) || 0) + bandwidth / 2 : x;
2560
+ const top = (typeof tooltipY === 'number' ? tooltipY : topYDomain[currIndex] - y2) + offsetY;
2561
+ const left = (tooltipBind ? (xScale(currIndex.toString()) || 0) + bandwidth / 2 : x) + offsetX;
2542
2562
 
2543
2563
  if (tooltipBind && flagCurrIndex === currIndex) {
2544
2564
  return;
@@ -2596,8 +2616,10 @@ const drawTooltip$2 = (_ref) => {
2596
2616
  setVisible(true);
2597
2617
  }
2598
2618
 
2599
- barChartTooltip.html(() => {
2600
- const html = ReactDOMServer.renderToString(React.createElement(React.Fragment, null, currData && currData[0] && React.createElement(TooltipGroupName, {
2619
+ barChartTootipFlex.html(() => {
2620
+ const html = ReactDOMServer.renderToString(React.createElement(TooltipContainer, {
2621
+ className: barChartClassNames.barChartTooltip
2622
+ }, currData && currData[0] && React.createElement(TooltipGroupName, {
2601
2623
  className: barChartClassNames.barChartTooltipGroupName
2602
2624
  }, currData[0].groupName), currData && currData.map((_ref5) => {
2603
2625
  let {
@@ -2641,6 +2663,7 @@ const drawTooltip$2 = (_ref) => {
2641
2663
  });
2642
2664
  }
2643
2665
 
2666
+ const container = select(node).append('div').attr('class', barChartClassNames.barChartMouseContainer);
2644
2667
  const labelContainer = container.append('div').attr('class', barChartClassNames.barChartLabelContainer).style('position', 'absolute').style('top', y2 + "px");
2645
2668
 
2646
2669
  if (labelPosition) {
@@ -2772,7 +2795,9 @@ const draw$4 = (node, props) => {
2772
2795
  setTooltipPosition,
2773
2796
  onLabelItem,
2774
2797
  isBarTooltip,
2775
- xScaleItemWidth
2798
+ xScaleItemWidth,
2799
+ tooltipRoot,
2800
+ tooltipClassName
2776
2801
  } = props;
2777
2802
 
2778
2803
  if (node !== null && data.length) {
@@ -2927,7 +2952,9 @@ const draw$4 = (node, props) => {
2927
2952
  setTooltipPosition,
2928
2953
  onLabelItem,
2929
2954
  isBarTooltip,
2930
- bars: groups
2955
+ bars: groups,
2956
+ tooltipRoot,
2957
+ tooltipClassName
2931
2958
  });
2932
2959
  }
2933
2960
 
@@ -2958,7 +2985,7 @@ const BarChart = props => {
2958
2985
  return React.createElement("div", {
2959
2986
  className: className,
2960
2987
  style: style
2961
- }, React.createElement(SvgWrapper$4, {
2988
+ }, React.createElement(TooltipStyles$1, null), React.createElement(SvgWrapper$4, {
2962
2989
  ref: ref
2963
2990
  }, children));
2964
2991
  };
@@ -3085,10 +3112,10 @@ function _templateObject3$2() {
3085
3112
  return data;
3086
3113
  }
3087
3114
 
3088
- function _templateObject2$4() {
3115
+ function _templateObject2$5() {
3089
3116
  const data = _taggedTemplateLiteralLoose(["\n text-align: right;\n"]);
3090
3117
 
3091
- _templateObject2$4 = function _templateObject2() {
3118
+ _templateObject2$5 = function _templateObject2() {
3092
3119
  return data;
3093
3120
  };
3094
3121
 
@@ -3127,7 +3154,7 @@ const horizontalBarChartClassNames = {
3127
3154
  horizontalBarChartTooltipValue: 'horizontalBarChartTooltipValue'
3128
3155
  };
3129
3156
  const Table = /*#__PURE__*/styled.table( /*#__PURE__*/_templateObject$b());
3130
- const LabelCell = /*#__PURE__*/styled.div( /*#__PURE__*/_templateObject2$4());
3157
+ const LabelCell = /*#__PURE__*/styled.div( /*#__PURE__*/_templateObject2$5());
3131
3158
  const BarFlex = /*#__PURE__*/styled.div( /*#__PURE__*/_templateObject3$2());
3132
3159
  const BarsTd = /*#__PURE__*/styled.td( /*#__PURE__*/_templateObject4$2());
3133
3160
  const TooltipFlex$1 = /*#__PURE__*/styled(TooltipFlex)( /*#__PURE__*/_templateObject5$2());
@@ -3319,10 +3346,10 @@ function _templateObject3$3() {
3319
3346
  return data;
3320
3347
  }
3321
3348
 
3322
- function _templateObject2$5() {
3349
+ function _templateObject2$6() {
3323
3350
  const data = _taggedTemplateLiteralLoose(["\n position: relative;\n height: 1rem;\n"]);
3324
3351
 
3325
- _templateObject2$5 = function _templateObject2() {
3352
+ _templateObject2$6 = function _templateObject2() {
3326
3353
  return data;
3327
3354
  };
3328
3355
 
@@ -3339,7 +3366,7 @@ function _templateObject$d() {
3339
3366
  return data;
3340
3367
  }
3341
3368
  const TickTd = /*#__PURE__*/styled.td( /*#__PURE__*/_templateObject$d());
3342
- const Ticks = /*#__PURE__*/styled.div( /*#__PURE__*/_templateObject2$5());
3369
+ const Ticks = /*#__PURE__*/styled.div( /*#__PURE__*/_templateObject2$6());
3343
3370
  const Tick = /*#__PURE__*/styled.div( /*#__PURE__*/_templateObject3$3());
3344
3371
 
3345
3372
  const XScale = (_ref) => {
@@ -3497,10 +3524,10 @@ HorizontalBarChart.defaultProps = {
3497
3524
  withoutXScale: false
3498
3525
  };
3499
3526
 
3500
- function _templateObject2$6() {
3527
+ function _templateObject2$7() {
3501
3528
  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"]);
3502
3529
 
3503
- _templateObject2$6 = function _templateObject2() {
3530
+ _templateObject2$7 = function _templateObject2() {
3504
3531
  return data;
3505
3532
  };
3506
3533
 
@@ -3531,7 +3558,7 @@ const bubbleChartClassNames = {
3531
3558
  bubbleChartTip: 'bubbleChartTip'
3532
3559
  };
3533
3560
  const SvgWrapper$5 = /*#__PURE__*/styled(Wrapper)( /*#__PURE__*/_templateObject$e(), bubbleChartClassNames.bubbleChartYAxis, bubbleChartClassNames.bubbleChartXAxis, bubbleChartClassNames.bubbleChartGridGlobal, bubbleChartClassNames.bubbleChartGridLineX, bubbleChartClassNames.bubbleChartGridLineY, bubbleChartClassNames.bubbleChartYScaleLabel);
3534
- const TooltipStyles$1 = /*#__PURE__*/createGlobalStyle( /*#__PURE__*/_templateObject2$6(), bubbleChartClassNames.bubbleChartTooltipContainer);
3561
+ const TooltipStyles$2 = /*#__PURE__*/createGlobalStyle( /*#__PURE__*/_templateObject2$7(), bubbleChartClassNames.bubbleChartTooltipContainer);
3535
3562
 
3536
3563
  const drawGrid$2 = (_ref) => {
3537
3564
  let {
@@ -3813,7 +3840,7 @@ const BubbleChart = props => {
3813
3840
  return React.createElement("div", {
3814
3841
  className: className,
3815
3842
  style: style
3816
- }, React.createElement(TooltipStyles$1, null), React.createElement(SvgWrapper$5, {
3843
+ }, React.createElement(TooltipStyles$2, null), React.createElement(SvgWrapper$5, {
3817
3844
  ref: ref
3818
3845
  }, children));
3819
3846
  };