@gravity-ui/charts 1.34.9 → 1.34.10
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/cjs/components/Tooltip/DefaultTooltipContent/index.js +2 -1
- package/dist/cjs/components/Tooltip/styles.css +7 -0
- package/dist/cjs/utils/chart/text.js +14 -9
- package/dist/esm/components/Tooltip/DefaultTooltipContent/index.js +2 -1
- package/dist/esm/components/Tooltip/styles.css +7 -0
- package/dist/esm/utils/chart/text.js +14 -9
- package/package.json +1 -1
|
@@ -89,7 +89,8 @@ export const DefaultTooltipContent = ({ hovered, pinned, rowRenderer, totals, va
|
|
|
89
89
|
}
|
|
90
90
|
}, [pinned]);
|
|
91
91
|
return (React.createElement("div", { className: b('content'), "data-qa": qa },
|
|
92
|
-
formattedHeadValue && (React.createElement("div", { className: b('series-name')
|
|
92
|
+
formattedHeadValue && (React.createElement("div", { className: b('series-name') },
|
|
93
|
+
React.createElement("div", { className: b('series-name-text'), dangerouslySetInnerHTML: { __html: formattedHeadValue } }))),
|
|
93
94
|
React.createElement("div", { className: b('content-rows', { pinned }), ref: contentRowsRef, style: { maxHeight: maxContentRowsHeight } },
|
|
94
95
|
visibleHovered.map((seriesItem, i) => {
|
|
95
96
|
var _a;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
box-shadow: 0 2px 12px var(--g-color-sfx-shadow);
|
|
4
4
|
}
|
|
5
5
|
.gcharts-tooltip__popup-content {
|
|
6
|
+
max-width: 450px;
|
|
6
7
|
text-wrap: nowrap;
|
|
7
8
|
border-radius: 4px;
|
|
8
9
|
background-color: var(--g-color-infographics-tooltip-bg);
|
|
@@ -24,6 +25,12 @@
|
|
|
24
25
|
font-size: 13px;
|
|
25
26
|
font-weight: 600;
|
|
26
27
|
}
|
|
28
|
+
.gcharts-tooltip__series-name-text {
|
|
29
|
+
display: block;
|
|
30
|
+
overflow: hidden;
|
|
31
|
+
white-space: nowrap;
|
|
32
|
+
text-overflow: ellipsis;
|
|
33
|
+
}
|
|
27
34
|
.gcharts-tooltip__content-row {
|
|
28
35
|
display: flex;
|
|
29
36
|
align-items: center;
|
|
@@ -205,18 +205,23 @@ export function getTextSizeFn({ style }) {
|
|
|
205
205
|
// We ignore an inaccuracy of less than a pixel.
|
|
206
206
|
// To do this, we round the font size down when comparing it, and the size of the allowed space up.
|
|
207
207
|
export async function getTextWithElipsis({ text: originalText, getTextWidth, maxWidth, }) {
|
|
208
|
-
|
|
208
|
+
const textWidth = Math.floor(await getTextWidth(originalText));
|
|
209
209
|
const textMaxWidth = Math.ceil(maxWidth);
|
|
210
210
|
if (textWidth <= textMaxWidth) {
|
|
211
211
|
return originalText;
|
|
212
212
|
}
|
|
213
|
-
let
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
213
|
+
let low = 0;
|
|
214
|
+
let high = originalText.length;
|
|
215
|
+
while (low < high) {
|
|
216
|
+
const mid = Math.floor((low + high + 1) / 2);
|
|
217
|
+
const candidate = originalText.slice(0, mid) + '…';
|
|
218
|
+
const candidateWidth = Math.floor(await getTextWidth(candidate));
|
|
219
|
+
if (candidateWidth <= textMaxWidth) {
|
|
220
|
+
low = mid;
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
high = mid - 1;
|
|
224
|
+
}
|
|
220
225
|
}
|
|
221
|
-
return
|
|
226
|
+
return low > 0 ? originalText.slice(0, low) + '…' : '';
|
|
222
227
|
}
|
|
@@ -89,7 +89,8 @@ export const DefaultTooltipContent = ({ hovered, pinned, rowRenderer, totals, va
|
|
|
89
89
|
}
|
|
90
90
|
}, [pinned]);
|
|
91
91
|
return (React.createElement("div", { className: b('content'), "data-qa": qa },
|
|
92
|
-
formattedHeadValue && (React.createElement("div", { className: b('series-name')
|
|
92
|
+
formattedHeadValue && (React.createElement("div", { className: b('series-name') },
|
|
93
|
+
React.createElement("div", { className: b('series-name-text'), dangerouslySetInnerHTML: { __html: formattedHeadValue } }))),
|
|
93
94
|
React.createElement("div", { className: b('content-rows', { pinned }), ref: contentRowsRef, style: { maxHeight: maxContentRowsHeight } },
|
|
94
95
|
visibleHovered.map((seriesItem, i) => {
|
|
95
96
|
var _a;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
box-shadow: 0 2px 12px var(--g-color-sfx-shadow);
|
|
4
4
|
}
|
|
5
5
|
.gcharts-tooltip__popup-content {
|
|
6
|
+
max-width: 450px;
|
|
6
7
|
text-wrap: nowrap;
|
|
7
8
|
border-radius: 4px;
|
|
8
9
|
background-color: var(--g-color-infographics-tooltip-bg);
|
|
@@ -24,6 +25,12 @@
|
|
|
24
25
|
font-size: 13px;
|
|
25
26
|
font-weight: 600;
|
|
26
27
|
}
|
|
28
|
+
.gcharts-tooltip__series-name-text {
|
|
29
|
+
display: block;
|
|
30
|
+
overflow: hidden;
|
|
31
|
+
white-space: nowrap;
|
|
32
|
+
text-overflow: ellipsis;
|
|
33
|
+
}
|
|
27
34
|
.gcharts-tooltip__content-row {
|
|
28
35
|
display: flex;
|
|
29
36
|
align-items: center;
|
|
@@ -205,18 +205,23 @@ export function getTextSizeFn({ style }) {
|
|
|
205
205
|
// We ignore an inaccuracy of less than a pixel.
|
|
206
206
|
// To do this, we round the font size down when comparing it, and the size of the allowed space up.
|
|
207
207
|
export async function getTextWithElipsis({ text: originalText, getTextWidth, maxWidth, }) {
|
|
208
|
-
|
|
208
|
+
const textWidth = Math.floor(await getTextWidth(originalText));
|
|
209
209
|
const textMaxWidth = Math.ceil(maxWidth);
|
|
210
210
|
if (textWidth <= textMaxWidth) {
|
|
211
211
|
return originalText;
|
|
212
212
|
}
|
|
213
|
-
let
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
213
|
+
let low = 0;
|
|
214
|
+
let high = originalText.length;
|
|
215
|
+
while (low < high) {
|
|
216
|
+
const mid = Math.floor((low + high + 1) / 2);
|
|
217
|
+
const candidate = originalText.slice(0, mid) + '…';
|
|
218
|
+
const candidateWidth = Math.floor(await getTextWidth(candidate));
|
|
219
|
+
if (candidateWidth <= textMaxWidth) {
|
|
220
|
+
low = mid;
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
high = mid - 1;
|
|
224
|
+
}
|
|
220
225
|
}
|
|
221
|
-
return
|
|
226
|
+
return low > 0 ? originalText.slice(0, low) + '…' : '';
|
|
222
227
|
}
|