@gravity-ui/charts 1.6.2 → 1.6.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.
@@ -72,6 +72,8 @@ export const ChartInner = (props) => {
72
72
  React.createElement(AxisX, { leftmostLimit: svgXPos, axis: xAxis, width: boundsWidth, height: boundsHeight, scale: xScale, split: preparedSplit, plotRef: plotRef })))),
73
73
  shapes),
74
74
  preparedLegend.enabled && (React.createElement(Legend, { chartSeries: preparedSeries, boundsWidth: boundsWidth, legend: preparedLegend, items: legendItems, config: legendConfig, onItemClick: handleLegendItemClick, onUpdate: unpinTooltip }))),
75
- React.createElement("div", { className: b('html-layer'), ref: htmlLayerRef, style: { marginTop: boundsOffsetTop, marginLeft: boundsOffsetLeft } }),
75
+ React.createElement("div", { className: b('html-layer'), ref: htmlLayerRef, style: {
76
+ '--g-html-layout-transform': `translate(${boundsOffsetLeft}px, ${boundsOffsetTop}px)`,
77
+ } }),
76
78
  React.createElement(Tooltip, { dispatcher: dispatcher, tooltip: tooltip, svgContainer: svgRef.current, xAxis: xAxis, yAxis: yAxis[0], onOutsideClick: unpinTooltip, tooltipPinned: tooltipPinned })));
77
79
  };
@@ -3,12 +3,11 @@
3
3
  position: absolute;
4
4
  inset-block-start: 0;
5
5
  inset-inline-start: 0;
6
+ display: flex;
6
7
  }
7
8
  .gcharts-chart__html-layer {
8
- position: absolute;
9
- inset-block-start: 0;
10
- inset-inline-start: 0;
9
+ display: contents;
11
10
  }
12
- .gcharts-chart__html-layer > * {
13
- transform: inherit;
11
+ .gcharts-chart__html-layer-item {
12
+ transform: var(--g-html-layout-transform);
14
13
  }
@@ -20,8 +20,7 @@ export const Chart = React.forwardRef(function Chart(props, forwardedRef) {
20
20
  var _a;
21
21
  const parentElement = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.parentElement;
22
22
  if (parentElement) {
23
- const { width, height } = parentElement.getBoundingClientRect();
24
- setDimensions({ width, height });
23
+ setDimensions({ width: parentElement.clientWidth, height: parentElement.clientHeight });
25
24
  }
26
25
  }, []);
27
26
  const debuncedHandleResize = React.useMemo(() => {
@@ -1,5 +1,7 @@
1
1
  import React from 'react';
2
2
  import { Portal } from '@gravity-ui/uikit';
3
+ import { block } from '../../utils';
4
+ const b = block('chart');
3
5
  export const HtmlLayer = (props) => {
4
6
  const { htmlLayout, preparedData } = props;
5
7
  const items = React.useMemo(() => {
@@ -19,6 +21,6 @@ export const HtmlLayer = (props) => {
19
21
  return (React.createElement(Portal, { container: htmlLayout }, items.map((item, index) => {
20
22
  var _a, _b, _c;
21
23
  const style = Object.assign(Object.assign({}, item.style), { color: (_b = (_a = item.style) === null || _a === void 0 ? void 0 : _a.color) !== null && _b !== void 0 ? _b : (_c = item.style) === null || _c === void 0 ? void 0 : _c.fontColor, position: 'absolute', left: item.x, top: item.y });
22
- return (React.createElement("div", { key: index, dangerouslySetInnerHTML: { __html: item.content }, style: style }));
24
+ return (React.createElement("div", { className: b('html-layer-item'), key: index, dangerouslySetInnerHTML: { __html: item.content }, style: style }));
23
25
  })));
24
26
  };
@@ -72,6 +72,8 @@ export const ChartInner = (props) => {
72
72
  React.createElement(AxisX, { leftmostLimit: svgXPos, axis: xAxis, width: boundsWidth, height: boundsHeight, scale: xScale, split: preparedSplit, plotRef: plotRef })))),
73
73
  shapes),
74
74
  preparedLegend.enabled && (React.createElement(Legend, { chartSeries: preparedSeries, boundsWidth: boundsWidth, legend: preparedLegend, items: legendItems, config: legendConfig, onItemClick: handleLegendItemClick, onUpdate: unpinTooltip }))),
75
- React.createElement("div", { className: b('html-layer'), ref: htmlLayerRef, style: { marginTop: boundsOffsetTop, marginLeft: boundsOffsetLeft } }),
75
+ React.createElement("div", { className: b('html-layer'), ref: htmlLayerRef, style: {
76
+ '--g-html-layout-transform': `translate(${boundsOffsetLeft}px, ${boundsOffsetTop}px)`,
77
+ } }),
76
78
  React.createElement(Tooltip, { dispatcher: dispatcher, tooltip: tooltip, svgContainer: svgRef.current, xAxis: xAxis, yAxis: yAxis[0], onOutsideClick: unpinTooltip, tooltipPinned: tooltipPinned })));
77
79
  };
@@ -3,12 +3,11 @@
3
3
  position: absolute;
4
4
  inset-block-start: 0;
5
5
  inset-inline-start: 0;
6
+ display: flex;
6
7
  }
7
8
  .gcharts-chart__html-layer {
8
- position: absolute;
9
- inset-block-start: 0;
10
- inset-inline-start: 0;
9
+ display: contents;
11
10
  }
12
- .gcharts-chart__html-layer > * {
13
- transform: inherit;
11
+ .gcharts-chart__html-layer-item {
12
+ transform: var(--g-html-layout-transform);
14
13
  }
@@ -20,8 +20,7 @@ export const Chart = React.forwardRef(function Chart(props, forwardedRef) {
20
20
  var _a;
21
21
  const parentElement = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.parentElement;
22
22
  if (parentElement) {
23
- const { width, height } = parentElement.getBoundingClientRect();
24
- setDimensions({ width, height });
23
+ setDimensions({ width: parentElement.clientWidth, height: parentElement.clientHeight });
25
24
  }
26
25
  }, []);
27
26
  const debuncedHandleResize = React.useMemo(() => {
@@ -1,5 +1,7 @@
1
1
  import React from 'react';
2
2
  import { Portal } from '@gravity-ui/uikit';
3
+ import { block } from '../../utils';
4
+ const b = block('chart');
3
5
  export const HtmlLayer = (props) => {
4
6
  const { htmlLayout, preparedData } = props;
5
7
  const items = React.useMemo(() => {
@@ -19,6 +21,6 @@ export const HtmlLayer = (props) => {
19
21
  return (React.createElement(Portal, { container: htmlLayout }, items.map((item, index) => {
20
22
  var _a, _b, _c;
21
23
  const style = Object.assign(Object.assign({}, item.style), { color: (_b = (_a = item.style) === null || _a === void 0 ? void 0 : _a.color) !== null && _b !== void 0 ? _b : (_c = item.style) === null || _c === void 0 ? void 0 : _c.fontColor, position: 'absolute', left: item.x, top: item.y });
22
- return (React.createElement("div", { key: index, dangerouslySetInnerHTML: { __html: item.content }, style: style }));
24
+ return (React.createElement("div", { className: b('html-layer-item'), key: index, dangerouslySetInnerHTML: { __html: item.content }, style: style }));
23
25
  })));
24
26
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/charts",
3
- "version": "1.6.2",
3
+ "version": "1.6.4",
4
4
  "description": "React component used to render charts",
5
5
  "license": "MIT",
6
6
  "main": "dist/cjs/index.js",