axidio-styleguide-library1-v2 0.6.79 → 0.6.80
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/esm2022/lib/group-chart/group-chart.component.mjs +53 -27
- package/esm2022/lib/horizontal-grouped-bar-with-scroll-zoom/horizontal-grouped-bar-with-scroll-zoom.component.mjs +7 -4
- package/fesm2022/axidio-styleguide-library1-v2.mjs +58 -29
- package/fesm2022/axidio-styleguide-library1-v2.mjs.map +1 -1
- package/lib/group-chart/group-chart.component.d.ts +1 -0
- package/package.json +1 -1
|
@@ -3743,7 +3743,7 @@ class GroupChartComponent extends ComponentUniqueId {
|
|
|
3743
3743
|
this.renderMultiChartXAxis(svg, x, height, data, metaData);
|
|
3744
3744
|
}
|
|
3745
3745
|
if (this.chartConfiguration.xLabelsOnSameLine) {
|
|
3746
|
-
this.renderXLabelsOnSameLine(svg, data, metaData);
|
|
3746
|
+
this.renderXLabelsOnSameLine(svg, data, metaData, x);
|
|
3747
3747
|
}
|
|
3748
3748
|
// Bottom x-axis
|
|
3749
3749
|
const xAxis2 = svg
|
|
@@ -3794,34 +3794,42 @@ class GroupChartComponent extends ComponentUniqueId {
|
|
|
3794
3794
|
}
|
|
3795
3795
|
});
|
|
3796
3796
|
}
|
|
3797
|
-
renderXLabelsOnSameLine(svg, data, metaData) {
|
|
3798
|
-
const
|
|
3799
|
-
const
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
.
|
|
3805
|
-
const
|
|
3797
|
+
renderXLabelsOnSameLine(svg, data, metaData, x) {
|
|
3798
|
+
const shortY = 8;
|
|
3799
|
+
const longY = 26;
|
|
3800
|
+
// Remove previously added split labels (important on resize)
|
|
3801
|
+
svg.selectAll('.lib-xaxis-split').remove();
|
|
3802
|
+
const ticks = svg.selectAll('g.x1.axis1 g.tick');
|
|
3803
|
+
ticks.each((d, i, nodes) => {
|
|
3804
|
+
const tick = d3.select(nodes[i]);
|
|
3805
|
+
const label = d.trim().toLowerCase();
|
|
3806
|
+
const ignore = data.some((indiv) => indiv.name.toLowerCase() === label &&
|
|
3806
3807
|
indiv[metaData.keyList[0]] === -1);
|
|
3807
|
-
if (
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
return d.trim().substring(0, d.indexOf(' ')).toLowerCase();
|
|
3808
|
+
if (ignore) {
|
|
3809
|
+
tick.select('text').text('');
|
|
3810
|
+
return;
|
|
3811
3811
|
}
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
.
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3812
|
+
const bandwidth = x?.bandwidth?.() || 60;
|
|
3813
|
+
const maxCharsPerLine = Math.floor(bandwidth / 7); // responsive
|
|
3814
|
+
const truncate = (text) => text.length > maxCharsPerLine
|
|
3815
|
+
? text.slice(0, maxCharsPerLine - 1) + '…'
|
|
3816
|
+
: text;
|
|
3817
|
+
const parts = label.split(' ');
|
|
3818
|
+
// First line
|
|
3819
|
+
tick
|
|
3820
|
+
.select('text')
|
|
3821
|
+
.attr('class', 'lib-xaxis-labels-texts-drilldown lib-xaxis-split')
|
|
3822
|
+
.attr('y', shortY)
|
|
3823
|
+
.text(truncate(parts[0]));
|
|
3824
|
+
// Second line (only if exists)
|
|
3825
|
+
if (parts.length > 1 && bandwidth > 35) {
|
|
3826
|
+
tick
|
|
3827
|
+
.append('text')
|
|
3828
|
+
.attr('class', 'lib-xaxis-labels-texts-drilldown lib-xaxis-split')
|
|
3829
|
+
.attr('y', longY)
|
|
3830
|
+
.attr('text-anchor', 'middle')
|
|
3831
|
+
.text(truncate(parts.slice(1).join(' ')));
|
|
3823
3832
|
}
|
|
3824
|
-
return '';
|
|
3825
3833
|
});
|
|
3826
3834
|
}
|
|
3827
3835
|
renderYAxis(svg, svgYAxisLeft, svgYAxisRight, y, dimensions) {
|
|
@@ -4032,6 +4040,24 @@ class GroupChartComponent extends ComponentUniqueId {
|
|
|
4032
4040
|
}
|
|
4033
4041
|
return xSubgroup.bandwidth();
|
|
4034
4042
|
}
|
|
4043
|
+
truncateTextByWidth(text, maxWidth, fontSize = 12, fontFamily = 'sans-serif') {
|
|
4044
|
+
if (!text)
|
|
4045
|
+
return '';
|
|
4046
|
+
const canvas = document.createElement('canvas');
|
|
4047
|
+
const context = canvas.getContext('2d');
|
|
4048
|
+
if (!context)
|
|
4049
|
+
return text;
|
|
4050
|
+
context.font = `${fontSize}px ${fontFamily}`;
|
|
4051
|
+
if (context.measureText(text).width <= maxWidth) {
|
|
4052
|
+
return text;
|
|
4053
|
+
}
|
|
4054
|
+
let truncated = text;
|
|
4055
|
+
while (truncated.length > 0 &&
|
|
4056
|
+
context.measureText(truncated + '…').width > maxWidth) {
|
|
4057
|
+
truncated = truncated.slice(0, -1);
|
|
4058
|
+
}
|
|
4059
|
+
return truncated + '…';
|
|
4060
|
+
}
|
|
4035
4061
|
getBarHeight(d, y, height) {
|
|
4036
4062
|
if (d.value === -1)
|
|
4037
4063
|
return height - y(0);
|
|
@@ -7814,7 +7840,7 @@ class HorizontalGroupedBarWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
7814
7840
|
// more than one subgroup so grouped bars don't get congested.
|
|
7815
7841
|
// On desktop: enable scrolling when there are many groups or
|
|
7816
7842
|
// multiple subgroups (keeps previous behavior).
|
|
7817
|
-
if ((isMobile
|
|
7843
|
+
if ((isMobile) && subgroupsCount > 1) {
|
|
7818
7844
|
innerContainer.style('overflow-x', 'auto');
|
|
7819
7845
|
innerContainer.classed('scroll-enabled', true);
|
|
7820
7846
|
}
|
|
@@ -8025,6 +8051,7 @@ class HorizontalGroupedBarWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
8025
8051
|
// }
|
|
8026
8052
|
// ✅ Tablet View — Rotate if text > 10 characters
|
|
8027
8053
|
if (isTablet) {
|
|
8054
|
+
const isria = this.customChartConfiguration.isRia;
|
|
8028
8055
|
const textNodes = svg.selectAll('g.x1.axis1 g.tick text');
|
|
8029
8056
|
textNodes.each(function (d) {
|
|
8030
8057
|
const text = d ? d.toString().trim() : '';
|
|
@@ -8034,8 +8061,10 @@ class HorizontalGroupedBarWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
8034
8061
|
if (!isDateString && text.length > 10) {
|
|
8035
8062
|
const trimmed = text.slice(0, 9) + '…';
|
|
8036
8063
|
textNodes
|
|
8037
|
-
.style('font-size', '
|
|
8038
|
-
|
|
8064
|
+
.style('font-size', '9px');
|
|
8065
|
+
if (isria) {
|
|
8066
|
+
textNodes.text(trimmed);
|
|
8067
|
+
}
|
|
8039
8068
|
}
|
|
8040
8069
|
});
|
|
8041
8070
|
}
|