Skip to content

Commit

Permalink
Merge branch 'charting/web-components' of https://github.com/microsof…
Browse files Browse the repository at this point in the history
…t/fluentui into charting/web-components
  • Loading branch information
AtishayMsft committed Nov 20, 2024
2 parents 2eda223 + 2022db6 commit 4f40ca8
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function donutChartTemplate<T extends DonutChart>(): ElementViewTemplate<
return html<T>`
<template ${ref('rootDiv')}>
<div ${ref('chartWrapper')}>
<svg class="chart" width="${x => x.width}" height="${x => x.height}" aria-label="${x => x.data.chartTitle}">
<svg class="chart" width="${x => x.width}" height="${x => x.height}">
<g ${ref('group')} transform="translate(${x => x.width / 2}, ${x => x.height / 2})"></g>
</svg>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,17 @@ export class DonutChart extends FASTElement {
public rootDiv!: HTMLDivElement;
public chartWrapper!: HTMLDivElement;
public group!: SVGGElement;
public elementInternals: ElementInternals = this.attachInternals();

private _arcs: SVGPathElement[] = [];
private _isRTL: boolean = false;

constructor() {
super();

this.elementInternals.role = 'region';
}

connectedCallback() {
super.connectedCallback();

Expand All @@ -77,6 +84,8 @@ export class DonutChart extends FASTElement {

this.legends = this.getLegends();
this._isRTL = getRTL(this);
this.elementInternals.ariaLabel =
this.data.chartTitle || `Donut chart with ${this.data.chartData.length} segments.`;

this._render();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ export interface ChartDataPoint {

export interface ChartProps {
/**
* chart title for the chart
* title for the data series
*/
chartTitle?: string;
chartSeriesTitle?: string;

/**
* data for the points in the chart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,22 @@ const chartPoints3: ChartDataPoint[] = [

const basicChartTestData: ChartProps[] = [
{
chartTitle: 'Monitored First',
chartSeriesTitle: 'Monitored First',
chartData: chartPoints1,
},
{
chartTitle: 'Monitored Second',
chartSeriesTitle: 'Monitored Second',
chartData: chartPoints2,
},
{
chartTitle: 'Unmonitored',
chartSeriesTitle: 'Unmonitored',
chartData: chartPoints3,
},
];

const singleBarHBCData = [
{
chartTitle: 'one',
chartSeriesTitle: 'one',
chartData: [
{
legend: 'one',
Expand All @@ -99,7 +99,7 @@ const singleBarHBCData = [
],
},
{
chartTitle: 'two',
chartSeriesTitle: 'two',
chartData: [
{
legend: 'two',
Expand All @@ -110,7 +110,7 @@ const singleBarHBCData = [
],
},
{
chartTitle: 'three',
chartSeriesTitle: 'three',
chartData: [
{
legend: 'three',
Expand All @@ -121,7 +121,7 @@ const singleBarHBCData = [
],
},
{
chartTitle: 'four',
chartSeriesTitle: 'four',
chartData: [
{
legend: 'four',
Expand All @@ -132,7 +132,7 @@ const singleBarHBCData = [
],
},
{
chartTitle: 'five',
chartSeriesTitle: 'five',
chartData: [
{
legend: 'five',
Expand All @@ -143,7 +143,7 @@ const singleBarHBCData = [
],
},
{
chartTitle: 'six',
chartSeriesTitle: 'six',
chartData: [
{
legend: 'six',
Expand All @@ -154,7 +154,7 @@ const singleBarHBCData = [
],
},
{
chartTitle: 'seven',
chartSeriesTitle: 'seven',
chartData: [
{
legend: 'seven',
Expand All @@ -165,7 +165,7 @@ const singleBarHBCData = [
],
},
{
chartTitle: 'eight',
chartSeriesTitle: 'eight',
chartData: [
{
legend: 'eight',
Expand All @@ -179,7 +179,7 @@ const singleBarHBCData = [

const singleBarNMVariantData = [
{
chartTitle: 'one',
chartSeriesTitle: 'one',
chartData: [
{
legend: 'one',
Expand All @@ -190,7 +190,7 @@ const singleBarNMVariantData = [
],
},
{
chartTitle: 'two',
chartSeriesTitle: 'two',
chartData: [
{
legend: 'two',
Expand All @@ -201,7 +201,7 @@ const singleBarNMVariantData = [
],
},
{
chartTitle: 'three',
chartSeriesTitle: 'three',
chartData: [
{
legend: 'three',
Expand All @@ -212,7 +212,7 @@ const singleBarNMVariantData = [
],
},
{
chartTitle: 'four',
chartSeriesTitle: 'four',
chartData: [
{
legend: 'four',
Expand All @@ -223,7 +223,7 @@ const singleBarNMVariantData = [
],
},
{
chartTitle: 'five',
chartSeriesTitle: 'five',
chartData: [
{
legend: 'five',
Expand All @@ -234,7 +234,7 @@ const singleBarNMVariantData = [
],
},
{
chartTitle: 'six',
chartSeriesTitle: 'six',
chartData: [
{
legend: 'six',
Expand All @@ -245,7 +245,7 @@ const singleBarNMVariantData = [
],
},
{
chartTitle: 'seven',
chartSeriesTitle: 'seven',
chartData: [
{
legend: 'seven',
Expand All @@ -256,7 +256,7 @@ const singleBarNMVariantData = [
],
},
{
chartTitle: 'eight',
chartSeriesTitle: 'eight',
chartData: [
{
legend: 'eight',
Expand All @@ -270,7 +270,7 @@ const singleBarNMVariantData = [

const singlePointData = [
{
chartTitle: 'one',
chartSeriesTitle: 'one',
chartData: [
{
legend: 'one',
Expand Down
Loading

0 comments on commit 4f40ca8

Please sign in to comment.