Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(charts): Create chart web components - Donut and Horizontal Bar Chart #33084

Open
wants to merge 68 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
e94bacf
Basic implementation of horizontal bar chart
AtishayMsft Sep 14, 2024
e26840b
Add logic for multistacked bar chart
AtishayMsft Sep 16, 2024
027a7ef
Render multi stacked bars
AtishayMsft Sep 16, 2024
ee296c0
Color the bars as per provided colors
AtishayMsft Sep 17, 2024
01ca8e4
Charts as Web component (#32866)
Anush2303 Oct 11, 2024
ffe7e6f
added callout to multi stacked bar chart (#33013)
Anush2303 Oct 14, 2024
4de6c3f
Add web component for donut chart (#33011)
krkshitij Oct 14, 2024
aa872c6
Added legend functionality to Horizontal Bar chart (#33051)
Anush2303 Oct 17, 2024
0008ba9
Add more functionalities to donut chart (#33039)
krkshitij Oct 18, 2024
66b134b
Move data for HBC to stories
AtishayMsft Oct 19, 2024
0be5e78
Fix styles to use tokens
AtishayMsft Oct 19, 2024
6dc6cb1
Add change file
AtishayMsft Oct 19, 2024
8e14e14
Update d3 dependencies
AtishayMsft Oct 19, 2024
d2f76b4
Fix build errors
AtishayMsft Oct 19, 2024
faaa036
Fix build errors in HBC
AtishayMsft Oct 19, 2024
9d387da
NM Variant of MultiStacked bar chart (#33086)
Anush2303 Oct 21, 2024
f1c9234
Horizontal Bar chart as Web component (#33096)
Anush2303 Oct 22, 2024
ce231ed
Add color palette for data visualization (#33095)
krkshitij Oct 23, 2024
17ffa27
Single Bar HBC NM Variant (#33116)
Anush2303 Oct 24, 2024
86df4de
Fix bugs in donut-chart web component (#33118)
krkshitij Oct 25, 2024
7d7a3c8
Fix error
AtishayMsft Oct 27, 2024
b50e4ba
Move container div to the template
AtishayMsft Oct 27, 2024
ee2aacb
Remove unnecessary calls
AtishayMsft Oct 28, 2024
546029d
Add event listeners to legend buttons (#33150)
krkshitij Oct 28, 2024
475f338
Enable gradient in horizontalbarchart (#33151)
krkshitij Oct 28, 2024
d0551b8
Update single bar story to use gradient
AtishayMsft Oct 28, 2024
c14c048
Resolve review comments
AtishayMsft Oct 28, 2024
415c165
Refactor donut-chart web component (#33149)
krkshitij Oct 30, 2024
86aac7c
Refactor horizontalbarchart web component (#33169)
krkshitij Oct 30, 2024
29da77b
Merge branch 'master' into charting/web-components
AtishayMsft Nov 1, 2024
10c7981
Move charts t web components to own package
AtishayMsft Nov 1, 2024
6baa5bd
Fix CSS class names (#33196)
krkshitij Nov 7, 2024
bab162d
Resolve review comments (#33199)
krkshitij Nov 7, 2024
e5f44c0
Add benchmark triangle in horizontal-bar-chart (#33207)
krkshitij Nov 7, 2024
72edf75
Add support for custom chart data text in horizontal-bar-chart (#33212)
krkshitij Nov 12, 2024
b99009b
bug fixes for horizontal bar chart web component (#33233)
Anush2303 Nov 12, 2024
33a5f67
Add change file
AtishayMsft Nov 13, 2024
6bdaee9
Merge branch 'charting/web-components' of https://github.com/microsof…
AtishayMsft Nov 13, 2024
1915d1b
Resolve review comments (#33215)
krkshitij Nov 13, 2024
4753fca
Resolve review comments (#33264)
krkshitij Nov 13, 2024
499b1d2
Merge branch 'master' into charting/web-components
AtishayMsft Nov 13, 2024
66923a5
Update yarn lock
AtishayMsft Nov 13, 2024
a57df11
Fix build errors
AtishayMsft Nov 13, 2024
a02289e
Added basic test cases to donut chart (#33127)
v-baambati Nov 14, 2024
3049038
Merge master
AtishayMsft Nov 14, 2024
949ff13
Merge branch 'charting/web-components' of https://github.com/microsof…
AtishayMsft Nov 14, 2024
194c051
Fix merge conflict in tsconfig.base.all file
AtishayMsft Nov 14, 2024
5c37d48
Enable chart web components on docsite
AtishayMsft Nov 18, 2024
099247e
removed tabster dependency. (#33285)
Anush2303 Nov 18, 2024
8357fcf
Temp change to fix heap out of memory
AtishayMsft Nov 18, 2024
cad0f85
Merge branch 'charting/web-components' of https://github.com/microsof…
AtishayMsft Nov 18, 2024
b861245
Try updating path
AtishayMsft Nov 18, 2024
ef6c184
Test change for react components
AtishayMsft Nov 18, 2024
45db92b
Fix lint errors
AtishayMsft Nov 18, 2024
24d5295
Fix packaging error
AtishayMsft Nov 18, 2024
00511fc
Fix type check error
AtishayMsft Nov 18, 2024
2c24106
Revert adding to web components docsite
AtishayMsft Nov 18, 2024
3abf8b5
Fix errors in tests
AtishayMsft Nov 18, 2024
bb66e2f
Test change to fix heap out of memery error
AtishayMsft Nov 18, 2024
2022db6
Set role and aria-label for charts (#33294)
krkshitij Nov 20, 2024
2eda223
Merge master
AtishayMsft Nov 20, 2024
4f40ca8
Merge branch 'charting/web-components' of https://github.com/microsof…
AtishayMsft Nov 20, 2024
7d88390
Revert temp changes
AtishayMsft Nov 20, 2024
785ef83
Update api report
AtishayMsft Nov 21, 2024
fcf1184
Update text inside Donut chart fix (#33302)
Anush2303 Nov 21, 2024
85a3aa1
Update api report
AtishayMsft Nov 21, 2024
48799bd
high contrast bug fixes (#33326)
Anush2303 Nov 22, 2024
a0dd0e8
Order of Stories (#33330)
Anush2303 Nov 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
AtishayMsft marked this conversation as resolved.
Show resolved Hide resolved
AtishayMsft marked this conversation as resolved.
Show resolved Hide resolved
"type": "prerelease",
"comment": "feat(charts): Create web components for donut chart and horizontal bar chart.",
"packageName": "@fluentui/web-components",
"email": "[email protected]",
"dependentChangeType": "patch"
}
5 changes: 3 additions & 2 deletions packages/web-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
"clean": "node ./scripts/clean dist",
"generate-api": "api-extractor run --local",
"build": "yarn compile && yarn rollup -c && yarn generate-api",
"lint": "eslint . --ext .ts",
AtishayMsft marked this conversation as resolved.
Show resolved Hide resolved
"lint:fix": "eslint . --ext .ts --fix",
"format": "prettier -w src/**/*.{ts,html} --ignore-path ../../.prettierignore",
"format:check": "yarn format -c",
Expand All @@ -100,7 +99,9 @@
"@microsoft/fast-web-utilities": "^6.0.0",
"@fluentui/tokens": "1.0.0-alpha.16",
"tabbable": "^6.2.0",
"tslib": "^2.1.0"
"tslib": "^2.1.0",
"@types/d3": "^7.0.0",
"d3": "^7.0.0"
},
"peerDependencies": {
"@microsoft/fast-element": "^2.0.0-beta.26 || ^2.0.0"
Expand Down
4 changes: 4 additions & 0 deletions packages/web-components/src/donut-chart/define.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { FluentDesignSystem } from '../fluent-design-system.js';
import { definition } from './donut-chart.definition.js';

definition.define(FluentDesignSystem.registry);
12 changes: 12 additions & 0 deletions packages/web-components/src/donut-chart/donut-chart.bench.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { FluentDesignSystem } from '../fluent-design-system.js';
import { definition } from './donut-chart.definition.js';

definition.define(FluentDesignSystem.registry);

const itemRenderer = () => {
const donutChart = document.createElement('fluent-donut-chart');
return donutChart;
};

export default itemRenderer;
export { tests } from '../utils/benchmark-wrapper.js';
18 changes: 18 additions & 0 deletions packages/web-components/src/donut-chart/donut-chart.definition.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { FluentDesignSystem } from '../fluent-design-system.js';
import { DonutChart } from './donut-chart.js';
import { styles } from './donut-chart.styles.js';
import { template } from './donut-chart.template.js';

/**
* @public
* @remarks
* HTML Element: `<fluent-donut-chart>`
*/
export const definition = DonutChart.compose({
name: `${FluentDesignSystem.prefix}-donut-chart`,
AtishayMsft marked this conversation as resolved.
Show resolved Hide resolved
template,
styles,
shadowOptions: {
delegatesFocus: true,
},
});
40 changes: 40 additions & 0 deletions packages/web-components/src/donut-chart/donut-chart.options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
export interface IChartDataPoint {
AtishayMsft marked this conversation as resolved.
Show resolved Hide resolved
/**
* Legend text for the datapoint in the chart
*/
legend?: string;

/**
* data the datapoint in the chart
*/
data?: number;

/**
* Color for the legend in the chart. If not provided, it will fallback on the default color palette.
*/
color?: string;

/**
* Callout data for x axis
* This is an optional prop, If haven;t given legend will take
*/
xAxisCalloutData?: string;

/**
* Callout data for y axis
* This is an optional prop, If haven't given data will take
*/
yAxisCalloutData?: string;
}

export interface IChartProps {
/**
* chart title for the chart
*/
chartTitle?: string;

/**
* data for the points in the chart
*/
chartData?: IChartDataPoint[];
}
42 changes: 42 additions & 0 deletions packages/web-components/src/donut-chart/donut-chart.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { html } from '@microsoft/fast-element';
import type { Meta, Story, StoryArgs } from '../helpers.stories.js';
import { renderComponent } from '../helpers.stories.js';
import { DonutChart as FluentDonutChart } from './donut-chart.js';
import { IChartDataPoint, IChartProps } from './donut-chart.options.js';

const points: IChartDataPoint[] = [
{
legend: 'first',
data: 20000,
color: '#0099BC',
},
{
legend: 'second',
data: 39000,
color: '#77004D',
},
];

const data: IChartProps = {
chartTitle: 'Donut chart basic example',
chartData: points,
};

const storyTemplate = html<StoryArgs<FluentDonutChart>>`
<fluent-donut-chart data="${JSON.stringify(data)}" value-inside-donut="35,000" inner-radius="55">
</fluent-donut-chart>
`;

export default {
title: 'Components/DonutChart',
} as Meta<FluentDonutChart>;

export const Basic: Story<FluentDonutChart> = renderComponent(storyTemplate).bind({});

export const RTL: Story<FluentDonutChart> = renderComponent(html<StoryArgs<FluentDonutChart>>`
<div style="display: flex; flex-direction: column; gap: 1rem;" dir="rtl">
<div>
<fluent-donut-chart data="${JSON.stringify(data)}" inner-radius="55"> </fluent-donut-chart>
</div>
</div>
`);
112 changes: 112 additions & 0 deletions packages/web-components/src/donut-chart/donut-chart.styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import { css } from '@microsoft/fast-element';
import { display } from '../utils/display.js';
import {
borderRadiusMedium,
colorNeutralBackground1,
colorNeutralForeground1,
colorNeutralForeground2,
colorNeutralShadowAmbient,
colorNeutralShadowKey,
colorTransparentStroke,
spacingHorizontalL,
spacingHorizontalS,
spacingVerticalL,
spacingVerticalMNudge,
} from '../theme/design-tokens.js';
import { typographyBody1Styles, typographyCaption1Styles, typographyTitle2Styles } from '../styles/index.js';

/**
* Styles for the DonutChart component.
*
* @public
*/
export const styles = css`
${display('inline-block')}

.root {
${typographyBody1Styles}
align-items: center;
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
position: relative;
}

.chart {
box-sizing: content-box;
overflow: visible;
alignment-adjust: center;
display: block;
}

.legendContainer {
padding-top: ${spacingVerticalL};

AtishayMsft marked this conversation as resolved.
Show resolved Hide resolved
white-space: nowrap;
width: 100%;
align-items: center;
margin: -8px 0 0 -8px;

flex-wrap: wrap;
display: flex;
}

.insideDonutString {
${typographyTitle2Styles}
fill: ${colorNeutralForeground1};
}

.legend {
display: flex;
align-items: center;
cursor: pointer;
border: none;
padding: ${spacingHorizontalS};
background: none;
text-transform: capitalize;
}

.legendRect {
width: 12px;
height: 12px;
margin-right: ${spacingHorizontalS};
border: 1px solid;
}

.legendText {
${typographyCaption1Styles}
color: ${colorNeutralForeground1};
}

.calloutContentRoot {
display: grid;
overflow: hidden;
padding: ${spacingVerticalMNudge} ${spacingHorizontalL};
background-color: ${colorNeutralBackground1};
background-blend-mode: normal, luminosity;

border-radius: ${borderRadiusMedium};
border: 1px solid ${colorTransparentStroke};
filter: drop-shadow(0 0 2px ${colorNeutralShadowAmbient}) drop-shadow(0 8px 16px ${colorNeutralShadowKey});

position: absolute;
opacity: 0;
z-index: 1;
pointer-events: none;
}

.calloutBlockContainer {
padding-left: ${spacingHorizontalS};
color: ${colorNeutralForeground2};
}

.calloutLegendText {
${typographyCaption1Styles}
color: ${colorNeutralForeground2};
}

.calloutContentY {
${typographyTitle2Styles}
}
`;
16 changes: 16 additions & 0 deletions packages/web-components/src/donut-chart/donut-chart.template.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { ElementViewTemplate, html, ref, slotted } from '@microsoft/fast-element';
import type { DonutChart } from './donut-chart.js';

/**
* Generates a template for the DonutChart component.
*
* @public
*/
export function donutChartTemplate<T extends DonutChart>(): ElementViewTemplate<T> {
return html<T>``;
AtishayMsft marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* @internal
*/
export const template: ElementViewTemplate<DonutChart> = donutChartTemplate();
Loading
Loading