Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 | 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 82x 82x 2x 80x 3x 82x 24x 287x 252x 216x 36x 24x 323x 172x 21x 151x 24x 41x 41x 41x 41x 41x 41x 24x 22x 22x 70x 70x 70x 70x 70x 70x 70x 70x 70x 70x 70x 140x 206x 206x 1x 5x 1x 1x 1x 41x 119x 119x 41x 73x 396x 32x 41x 41x 72x 72x 72x 207x 207x 207x 72x 2x 2x 72x 72x 72x 72x 209x 209x 209x 209x 72x 72x 72x 72x 41x 70x 70x 70x 70x 70x 70x 1x 1x 1x 41x 70x 2x 68x 200x 3x 1x 2x 1x 1x 68x 41x 412x 41x 400x 41x 2x 41x 2x 41x 10x 41x 3x 41x 41x 12x 3x 9x 9x 9x 27x 27x 9x 41x 5x 5x 41x 55x 55x 55x 23x 32x 32x 32x 58x 58x 58x 58x 32x 41x 6x 6x 18x 18x 18x 24x 9x 9x 22x 24x 18x 18x 18x 18x 18x 18x 18x 24x | import * as React from 'react'; import { arc as d3Arc } from 'd3-shape'; import { classNamesFunction, getRTL } from '@fluentui/react/lib/Utilities'; import { IGaugeChartProps, IGaugeChartSegment, IGaugeChartStyleProps, IGaugeChartStyles, GaugeValueFormat, GaugeChartVariant, } from './GaugeChart.types'; import { IProcessedStyleSet } from '@fluentui/react/lib/Styling'; import { convertToLocaleString } from '../../utilities/locale-util'; import { Points, formatValueWithSIPrefix, getAccessibleDataObject, getColorFromToken, getNextColor, pointTypes, } from '../../utilities/index'; import { ILegend, LegendShape, Legends, Shape } from '../Legends/index'; import { FocusZone, FocusZoneDirection } from '@fluentui/react-focus'; import { Callout, DirectionalHint } from '@fluentui/react/lib/Callout'; import { IYValueHover } from '../../index'; import { SVGTooltipText } from '../../utilities/SVGTooltipText'; import { select as d3Select } from 'd3-selection'; const GAUGE_MARGIN = 16; const LABEL_WIDTH = 36; const LABEL_HEIGHT = 16; const LABEL_OFFSET = 4; const TITLE_OFFSET = 11; const EXTRA_NEEDLE_LENGTH = 4; export const ARC_PADDING = 2; export const BREAKPOINTS = [ { minRadius: 52, arcWidth: 12, fontSize: 20 }, { minRadius: 70, arcWidth: 16, fontSize: 24 }, { minRadius: 88, arcWidth: 20, fontSize: 32 }, { minRadius: 106, arcWidth: 24, fontSize: 32 }, { minRadius: 124, arcWidth: 28, fontSize: 40 }, { minRadius: 142, arcWidth: 32, fontSize: 40 }, ]; const getClassNames = classNamesFunction<IGaugeChartStyleProps, IGaugeChartStyles>(); export const calcNeedleRotation = (chartValue: number, minValue: number, maxValue: number) => { let needleRotation = ((chartValue - minValue) / (maxValue - minValue)) * 180; if (needleRotation < 0) { needleRotation = 0; } else if (needleRotation > 180) { needleRotation = 180; } return needleRotation; }; export const getSegmentLabel = ( segment: IExtendedSegment, minValue: number, maxValue: number, variant?: GaugeChartVariant, isAriaLabel: boolean = false, ) => { if (isAriaLabel) { return minValue === 0 && variant === GaugeChartVariant.SingleSegment ? `${segment.legend}, ${segment.size} out of ${maxValue} or ${((segment.size / maxValue) * 100).toFixed()}%` : `${segment.legend}, ${segment.start} to ${segment.end}`; } return minValue === 0 && variant === GaugeChartVariant.SingleSegment ? `${segment.size} (${((segment.size / maxValue) * 100).toFixed()}%)` : `${segment.start} - ${segment.end}`; }; export const getChartValueLabel = ( chartValue: number, minValue: number, maxValue: number, chartValueFormat?: GaugeValueFormat | ((sweepFraction: [number, number]) => string), forCallout: boolean = false, ): string => { if (forCallout) { // When displaying the chart value as a percentage, use fractions in the callout, and vice versa. // This helps clarify the actual value and avoid repetition. return minValue !== 0 ? chartValue.toString() : chartValueFormat === GaugeValueFormat.Fraction ? `${((chartValue / maxValue) * 100).toFixed()}%` : `${chartValue}/${maxValue}`; } return typeof chartValueFormat === 'function' ? chartValueFormat([chartValue - minValue, maxValue - minValue]) : minValue !== 0 ? chartValue.toString() : chartValueFormat === GaugeValueFormat.Fraction ? `${chartValue}/${maxValue}` : `${((chartValue / maxValue) * 100).toFixed()}%`; }; interface IYValue extends Omit<IYValueHover, 'y'> { y?: string | number; } export interface IGaugeChartState { hoveredLegend: string; selectedLegend: string; focusedElement?: string; // eslint-disable-next-line @typescript-eslint/no-explicit-any calloutTarget: any; isCalloutVisible: boolean; hoverXValue: string | number; hoverYValues: IYValue[]; width: number; height: number; } export interface IExtendedSegment extends IGaugeChartSegment { start: number; end: number; } export class GaugeChartBase extends React.Component<IGaugeChartProps, IGaugeChartState> { private _classNames: IProcessedStyleSet<IGaugeChartStyles>; private _isRTL: boolean; private _innerRadius: number; private _outerRadius: number; private _minValue: number; private _maxValue: number; private _segments: IExtendedSegment[]; private _calloutAnchor: string; private _rootElem: HTMLDivElement | null; private _margins: { left: number; right: number; top: number; bottom: number }; private _legendsHeight: number; constructor(props: IGaugeChartProps) { super(props); this._margins = this._getMargins(); this._legendsHeight = !props.hideLegend ? 24 : 0; this.state = { hoveredLegend: '', selectedLegend: '', focusedElement: '', calloutTarget: null, isCalloutVisible: false, hoverXValue: '', hoverYValues: [], width: 140 + this._margins.left + this._margins.right, height: 70 + this._margins.top + this._margins.bottom + this._legendsHeight, }; this._isRTL = getRTL(props.theme); this._calloutAnchor = ''; } public componentDidMount(): void { if (this._rootElem) { this.setState({ width: this._rootElem.clientWidth, height: this._rootElem.clientHeight, }); } } public render(): React.ReactNode { this._margins = this._getMargins(); this._legendsHeight = !this.props.hideLegend ? 24 : 0; const width = this.props.width || this.state.width; const height = this.props.height || this.state.height; this._outerRadius = Math.min( (width - (this._margins.left + this._margins.right)) / 2, height - (this._margins.top + this._margins.bottom + this._legendsHeight), ); const { arcWidth, chartValueSize } = this._getStylesBasedOnBreakpoint(); this._innerRadius = this._outerRadius - arcWidth; const { arcs } = this._processProps(); this._classNames = getClassNames(this.props.styles!, { theme: this.props.theme!, className: this.props.className, chartWidth: width, chartHeight: height - this._legendsHeight, chartValueSize, }); return ( <div className={this._classNames.root} ref={el => (this._rootElem = el)}> <FocusZone direction={FocusZoneDirection.horizontal}> <svg className={this._classNames.chart} aria-label={`This is a gauge chart with ${this._segments.length} section represented.`} onMouseLeave={this._handleMouseOut} > <g transform={`translate(${width / 2}, ${height - (this._margins.bottom + this._legendsHeight)})`}> {this.props.chartTitle && ( <text x={0} y={-(this._outerRadius + TITLE_OFFSET)} textAnchor="middle" className={this._classNames.chartTitle} > {this.props.chartTitle} </text> )} {!this.props.hideMinMax && ( <> <text x={(this._isRTL ? 1 : -1) * (this._outerRadius + LABEL_OFFSET)} y={0} textAnchor="end" className={this._classNames.limits} role="img" aria-label={`Min value: ${this._minValue}`} > {formatValueWithSIPrefix(this._minValue)} </text> <text x={(this._isRTL ? -1 : 1) * (this._outerRadius + LABEL_OFFSET)} y={0} textAnchor="start" className={this._classNames.limits} role="img" aria-label={`Max value: ${this._maxValue}`} > {formatValueWithSIPrefix(this._maxValue)} </text> </> )} {arcs.map((arc, index) => { const segment = this._segments[arc.segmentIndex]; return ( <path key={index} d={arc.d} fill={segment.color} fillOpacity={this._legendHighlighted(segment.legend) || this._noLegendHighlighted() ? 1 : 0.1} strokeWidth={this.state.focusedElement === segment.legend ? ARC_PADDING : 0} className={this._classNames.segment} {...getAccessibleDataObject( { ariaLabel: getSegmentLabel(segment, this._minValue, this._maxValue, this.props.variant, true), ...segment.accessibilityData, }, 'img', true, )} onFocus={e => this._handleFocus(e, segment.legend)} onBlur={this._handleBlur} onMouseEnter={e => this._handleMouseOver(e, segment.legend)} onMouseMove={e => this._handleMouseOver(e, segment.legend)} data-is-focusable={this._legendHighlighted(segment.legend) || this._noLegendHighlighted()} /> ); })} {this._renderNeedle()} <g onMouseEnter={e => this._handleMouseOver(e, 'Chart value')} onMouseMove={e => this._handleMouseOver(e, 'Chart value')} > <SVGTooltipText content={getChartValueLabel( this.props.chartValue, this._minValue, this._maxValue, this.props.chartValueFormat, )} textProps={{ x: 0, y: 0, textAnchor: 'middle', className: this._classNames.chartValue, role: 'img', 'aria-label': 'Current value: ' + getChartValueLabel( this.props.chartValue, this._minValue, this._maxValue, this.props.chartValueFormat, ), }} maxWidth={this._innerRadius * 2 - 24} wrapContent={this._wrapContent} /> </g> {this.props.sublabel && ( <SVGTooltipText content={this.props.sublabel} textProps={{ x: 0, y: 4, textAnchor: 'middle', dominantBaseline: 'hanging', className: this._classNames.sublabel, role: 'img', 'aria-label': this.props.sublabel, }} maxWidth={this._innerRadius * 2} wrapContent={this._wrapContent} /> )} </g> </svg> </FocusZone> {this._renderLegends()} {!this.props.hideTooltip && this.state.isCalloutVisible && ( <Callout target={this.state.calloutTarget} directionalHint={DirectionalHint.topAutoEdge} gapSpace={15} isBeakVisible={false} onDismiss={this._handleCalloutDismiss} {...this.props.calloutProps} > {this._multiValueCallout({ hoverXValue: this.state.hoverXValue, YValueHover: this.state.hoverYValues, })} </Callout> )} </div> ); } private _getMargins = () => { const { hideMinMax, chartTitle, sublabel } = this.props; return { left: (!hideMinMax ? LABEL_OFFSET + LABEL_WIDTH : 0) + GAUGE_MARGIN, right: (!hideMinMax ? LABEL_OFFSET + LABEL_WIDTH : 0) + GAUGE_MARGIN, top: (chartTitle ? TITLE_OFFSET + LABEL_HEIGHT : EXTRA_NEEDLE_LENGTH / 2) + GAUGE_MARGIN, bottom: (sublabel ? LABEL_OFFSET + LABEL_HEIGHT : 0) + GAUGE_MARGIN, }; }; private _getStylesBasedOnBreakpoint = () => { for (let index = BREAKPOINTS.length - 1; index >= 0; index -= 1) { if (this._outerRadius >= BREAKPOINTS[index].minRadius) { return { arcWidth: BREAKPOINTS[index].arcWidth, chartValueSize: BREAKPOINTS[index].fontSize, }; } } return { arcWidth: BREAKPOINTS[0].arcWidth, chartValueSize: BREAKPOINTS[0].fontSize, }; }; private _processProps = () => { const { minValue = 0, maxValue, theme } = this.props; let total = minValue; const segments: IExtendedSegment[] = this.props.segments.map((segment, index) => { const size = Math.max(segment.size, 0); total += size; return { legend: segment.legend, size, color: typeof segment.color !== 'undefined' ? getColorFromToken(segment.color, theme!.isInverted) : getNextColor(index, 0, theme!.isInverted), accessibilityData: segment.accessibilityData, start: total - size, end: total, }; }); if (typeof maxValue !== 'undefined' && total < maxValue) { segments.push({ legend: 'Unknown', size: maxValue - total, color: theme!.palette.neutralLight, start: total, end: maxValue, }); total = maxValue; } const arcGenerator = d3Arc() .padAngle(ARC_PADDING / this._outerRadius) .padRadius(this._outerRadius); const rtlSafeSegments = this._isRTL ? Array.from(segments).reverse() : segments; let prevAngle = -Math.PI / 2; const arcs = rtlSafeSegments.map((segment, index) => { const endAngle = prevAngle + (segment.size / (total - minValue)) * Math.PI; const d = arcGenerator({ innerRadius: this._innerRadius, outerRadius: this._outerRadius, startAngle: prevAngle, endAngle, })!; prevAngle = endAngle; return { d, segmentIndex: this._isRTL ? segments.length - 1 - index : index, }; }); this._minValue = minValue; this._maxValue = total; this._segments = segments; return { arcs, }; }; private _renderNeedle = () => { const needleRotation = calcNeedleRotation(this.props.chartValue, this._minValue, this._maxValue); const rtlSafeNeedleRotation = this._isRTL ? 180 - needleRotation : needleRotation; const strokeWidth = 2; const halfStrokeWidth = strokeWidth / 2; const needleLength = this._outerRadius - this._innerRadius + EXTRA_NEEDLE_LENGTH; return ( <g transform={`rotate(${rtlSafeNeedleRotation}, 0, 0)`}> <path d={` M 0,${-halfStrokeWidth - 3} L ${-needleLength},${-halfStrokeWidth - 1} A ${halfStrokeWidth + 1},${halfStrokeWidth + 1},0,0,0,${-needleLength},${halfStrokeWidth + 1} L 0,${halfStrokeWidth + 3} A ${halfStrokeWidth + 3},${halfStrokeWidth + 3},0,0,0,0,${-halfStrokeWidth - 3} `} strokeWidth={strokeWidth} className={this._classNames.needle} transform={`translate(${-this._innerRadius + EXTRA_NEEDLE_LENGTH / 2})`} data-is-focusable={true} onFocus={e => this._handleFocus(e, 'Needle')} onBlur={this._handleBlur} onMouseEnter={e => this._handleMouseOver(e, 'Needle')} onMouseMove={e => this._handleMouseOver(e, 'Needle')} /> </g> ); }; private _renderLegends = () => { if (this.props.hideLegend) { return null; } const legends: ILegend[] = this._segments.map(segment => { return { title: segment.legend, color: segment.color!, action: () => { if (this.state.selectedLegend === segment.legend) { this.setState({ selectedLegend: '' }); } else { this.setState({ selectedLegend: segment.legend }); } }, hoverAction: () => { this.setState({ hoveredLegend: segment.legend }); }, onMouseOutAction: () => { this.setState({ hoveredLegend: '' }); }, }; }); return ( <div className={this._classNames.legendsContainer}> <Legends legends={legends} centerLegends {...this.props.legendProps} /> </div> ); }; /** * This function checks if the given legend is highlighted or not. * A legend can be highlighted in 2 ways: * 1. selection: if the user clicks on it * 2. hovering: if there is no selected legend and the user hovers over it */ private _legendHighlighted = (legend: string) => { return ( this.state.selectedLegend === legend || (this.state.selectedLegend === '' && this.state.hoveredLegend === legend) ); }; /** * This function checks if none of the legends is selected or hovered. */ private _noLegendHighlighted = () => { return this.state.selectedLegend === '' && this.state.hoveredLegend === ''; }; private _handleFocus = (focusEvent: React.FocusEvent<SVGElement>, focusedElement: string) => { this._showCallout(focusEvent.target, focusedElement, true); }; private _handleBlur = () => { this._hideCallout(true); }; private _handleMouseOver = (mouseEvent: React.MouseEvent<SVGElement>, hoveredElement: string) => { this._showCallout(mouseEvent.target, hoveredElement, false); }; private _handleMouseOut = () => { this._hideCallout(false); }; private _handleCalloutDismiss = () => { this._hideCallout(false); }; // eslint-disable-next-line @typescript-eslint/no-explicit-any private _showCallout = (target: any, legend: string, isFocusEvent: boolean) => { if (this._calloutAnchor === legend) { return; } this._calloutAnchor = legend; const hoverXValue: string = 'Current value is ' + getChartValueLabel(this.props.chartValue, this._minValue, this._maxValue, this.props.chartValueFormat, true); const hoverYValues: IYValue[] = this._segments.map(segment => { const yValue: IYValue = { legend: segment.legend, y: getSegmentLabel(segment, this._minValue, this._maxValue, this.props.variant), color: segment.color, }; return yValue; }); this.setState({ calloutTarget: target, /** Show the callout if highlighted arc is hovered/focused and Hide it if unhighlighted arc is hovered/focused */ isCalloutVisible: ['Needle', 'Chart value'].includes(legend) || this.state.selectedLegend === '' || this.state.selectedLegend === legend, hoverXValue, hoverYValues, ...(isFocusEvent ? { focusedElement: legend } : {}), }); }; private _hideCallout = (isBlurEvent?: boolean) => { this._calloutAnchor = ''; this.setState({ calloutTarget: null, isCalloutVisible: false, hoverXValue: '', hoverYValues: [], ...(isBlurEvent ? { focusedElement: '' } : {}), }); }; private _wrapContent = (content: string, id: string, maxWidth: number) => { const textElement = d3Select<SVGTextElement, {}>(`#${id}`); textElement.text(content); if (!textElement.node()) { return false; } let isOverflowing = false; let textLength = textElement.node()!.getComputedTextLength(); while (textLength > maxWidth && content.length > 0) { content = content.slice(0, -1); textElement.text(content + '...'); isOverflowing = true; textLength = textElement.node()!.getComputedTextLength(); } return isOverflowing; }; // TO DO: Write a common functional component for Multi value callout and divide sub count method // eslint-disable-next-line @typescript-eslint/no-explicit-any private _multiValueCallout = (calloutProps: any) => { const yValueHoverSubCountsExists: boolean = this._yValueHoverSubCountsExists(calloutProps.YValueHover); return ( <div className={this._classNames.calloutContentRoot}> <div className={this._classNames.calloutDateTimeContainer} style={yValueHoverSubCountsExists ? { marginBottom: '11px' } : {}} > <div className={this._classNames.calloutContentX} {...getAccessibleDataObject(calloutProps!.xAxisCalloutAccessibilityData, 'text', false)} > {convertToLocaleString(calloutProps!.hoverXValue, this.props.culture)} </div> </div> <div className={this._classNames.calloutInfoContainer} style={yValueHoverSubCountsExists ? { display: 'flex' } : {}} > {calloutProps!.YValueHover && calloutProps!.YValueHover.map((yValue: IYValueHover, index: number, yValues: IYValueHover[]) => { const isLast: boolean = index + 1 === yValues.length; const { shouldDrawBorderBottom = false } = yValue; return ( <div {...getAccessibleDataObject(yValue.callOutAccessibilityData, 'text', false)} key={`callout-content-${index}`} style={ yValueHoverSubCountsExists ? { display: 'inline-block', ...(shouldDrawBorderBottom && { borderBottom: `1px solid ${this.props.theme!.semanticColors.menuDivider}`, paddingBottom: '10px', }), } : { ...(shouldDrawBorderBottom && { borderBottom: `1px solid ${this.props.theme!.semanticColors.menuDivider}`, paddingBottom: '10px', }), } } > {this._getCalloutContent(yValue, index, yValueHoverSubCountsExists, isLast)} </div> ); })} {!!calloutProps.descriptionMessage && ( <div className={this._classNames.descriptionMessage}>{calloutProps.descriptionMessage}</div> )} </div> </div> ); }; private _yValueHoverSubCountsExists(yValueHover?: IYValueHover[]) { if (yValueHover) { return yValueHover.some( (yValue: { legend?: string; y?: number; color?: string; yAxisCalloutData?: string | { [id: string]: number }; }) => yValue.yAxisCalloutData && typeof yValue.yAxisCalloutData !== 'string', ); } return false; } private _getCalloutContent( xValue: IYValueHover, index: number, yValueHoverSubCountsExists: boolean, isLast: boolean, ): React.ReactNode { const marginStyle: React.CSSProperties = isLast ? {} : { marginRight: '16px' }; const toDrawShape = xValue.index !== undefined && xValue.index !== -1; const _classNames = getClassNames(this.props.styles!, { theme: this.props.theme!, lineColor: xValue.color, toDrawShape, }); const { culture } = this.props; const yValue = convertToLocaleString(xValue.y, culture); if (!xValue.yAxisCalloutData || typeof xValue.yAxisCalloutData === 'string') { return ( <div style={yValueHoverSubCountsExists ? marginStyle : {}}> {yValueHoverSubCountsExists && ( <div className="ms-fontWeight-semibold" style={{ fontSize: '12pt' }}> {xValue.legend!} ({yValue}) </div> )} <div id={`${index}_${xValue.y}`} className={_classNames.calloutBlockContainer}> {toDrawShape && ( <Shape svgProps={{ className: _classNames.shapeStyles, }} pathProps={{ fill: xValue.color }} shape={Points[xValue.index! % Object.keys(pointTypes).length] as LegendShape} /> )} <div> <div className={_classNames.calloutlegendText}> {xValue.legend}</div> <div className={_classNames.calloutContentY}> {convertToLocaleString( xValue.yAxisCalloutData ? xValue.yAxisCalloutData : xValue.y || xValue.data, culture, )} </div> </div> </div> </div> ); } else E{ const subcounts: { [id: string]: number } = xValue.yAxisCalloutData as { [id: string]: number }; return ( <div style={marginStyle}> <div className="ms-fontWeight-semibold" style={{ fontSize: '12pt' }}> {xValue.legend!} ({yValue}) </div> {Object.keys(subcounts).map((subcountName: string) => { return ( <div key={subcountName} className={_classNames.calloutBlockContainer}> <div className={_classNames.calloutlegendText}> {convertToLocaleString(subcountName, culture)}</div> <div className={_classNames.calloutContentY}> {convertToLocaleString(subcounts[subcountName], culture)} </div> </div> ); })} </div> ); } } } |