Skip to content

Commit

Permalink
Resolving comments
Browse files Browse the repository at this point in the history
  • Loading branch information
srmukher committed Feb 23, 2023
1 parent d1d70a7 commit 66c1fa7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
14 changes: 6 additions & 8 deletions packages/react-charting/src/components/DonutChart/Arc/Arc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { getStyles } from './Arc.styles';
import { IChartDataPoint } from '../index';
import { IArcProps, IArcStyles } from './index';
import { wrapTextInsideDonut } from '../../../utilities/index';
import { IProcessedStyleSet } from '../../../Styling';

export interface IArcState {
isCalloutVisible?: boolean;
Expand All @@ -21,7 +20,6 @@ export class Arc extends React.Component<IArcProps, IArcState> {

public state: {} = {};

private _classNames: IProcessedStyleSet<IArcStyles>;
private currentRef = React.createRef<SVGPathElement>();

public static getDerivedStateFromProps(nextProps: Readonly<IArcProps>): Partial<IArcState> | null {
Expand All @@ -40,7 +38,7 @@ export class Arc extends React.Component<IArcProps, IArcState> {
public render(): JSX.Element {
const { arc, href, focusedArcId } = this.props;
const getClassNames = classNamesFunction<IArcProps, IArcStyles>();
this._classNames = getClassNames(getStyles, {
const classNames = getClassNames(getStyles, {
color: this.props.color,
href: href!,
theme: this.props.theme!,
Expand All @@ -52,13 +50,13 @@ export class Arc extends React.Component<IArcProps, IArcState> {
return (
<g ref={this.currentRef}>
{!!focusedArcId && focusedArcId === id && (
<path id={id + 'focusRing'} d={arc(this.props.focusData)} className={this._classNames.focusRing} />
<path id={id + 'focusRing'} d={arc(this.props.focusData)} className={classNames.focusRing} />
)}
<path
id={id}
d={arc(this.props.data)}
onFocus={this._onFocus.bind(this, this.props.data!.data, id)}
className={this._classNames.root}
className={classNames.root}
data-is-focusable={true}
onMouseOver={this._hoverOn.bind(this, this.props.data!.data)}
onMouseMove={this._hoverOn.bind(this, this.props.data!.data)}
Expand All @@ -69,9 +67,9 @@ export class Arc extends React.Component<IArcProps, IArcState> {
aria-label={this._getAriaLabel()}
role="img"
/>
<g className={this._classNames.nodeTextContainer}>
<text id="Donut_center_text" textAnchor={'middle'} className={this._classNames.insideDonutString} y={5}>
{this.props.valueInsideDonut}
<g className={classNames.nodeTextContainer}>
<text id="Donut_center_text" textAnchor={'middle'} className={classNames.insideDonutString} y={5}>
{this.props.valueInsideDonut!}
</text>
</g>
</g>
Expand Down
3 changes: 2 additions & 1 deletion packages/react-charting/src/utilities/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,8 @@ export function wrapTextInsideDonut(selectorClass: string, maxWidth: number): st
line = [word];
tspanEllipsis.text(word);

// Determine if truncation is appending the text exceeds maximum width vertically or horizontally
// Determine if truncation is appending the text exceeds maximum height vertically or
// maximum width horizontally. In this case, maximum height vertically is same as maxWidth
while (
tspanEllipsis.node()!.getComputedTextLength() > maxWidth - ellipsisLength ||
tspanEllipsis.node()!.getBoundingClientRect().y > maxWidth
Expand Down

0 comments on commit 66c1fa7

Please sign in to comment.