Skip to content

Commit

Permalink
fix: Horizontal chart with axis yaxis same label and truncation fixed (
Browse files Browse the repository at this point in the history
…#30031)

* fix:[HorChartWAxis][RTL] y axis same text and truncation fixed

* yarn change
  • Loading branch information
harsh9975 authored Dec 18, 2023
1 parent c0e7c90 commit 197dfaa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix:[HorChartWAxis][RTL] y axis same text and truncation fixed",
"packageName": "@fluentui/react-charting",
"email": "[email protected]",
"dependentChangeType": "patch"
}
8 changes: 5 additions & 3 deletions packages/react-charting/src/utilities/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,9 @@ export function createYAxisLabels(
axisNode.selectAll('.tick text').each(function () {
const text = d3Select(this);
const totalWord = text.text();
const truncatedWord = `${text.text().slice(0, noOfCharsToTruncate)}...`;
const truncatedWord = isRtl
? `...${text.text().slice(0, noOfCharsToTruncate)}`
: `${text.text().slice(0, noOfCharsToTruncate)}...`;
const totalWordLength = text.text().length;
const padding = truncateLabel ? 1.5 : 1; // ems
const y = text.attr('y');
Expand All @@ -737,7 +739,7 @@ export function createYAxisLabels(
text
.append('tspan')
.attr('id', 'showDots')
.attr('x', x)
.attr('x', isRtl ? 0 : x)
.attr('y', y)
.attr('dy', dy)
.attr('dx', padding + dx + 'em')
Expand All @@ -747,7 +749,7 @@ export function createYAxisLabels(
.attr('text-align', 'start')
.append('tspan')
.attr('id', 'LessLength')
.attr('x', isRtl ? xValue : x)
.attr('x', isRtl ? 0 : x)
.attr('y', y)
.attr('dx', padding + dx + 'em')
.text(totalWord);
Expand Down

0 comments on commit 197dfaa

Please sign in to comment.