Skip to content

Commit 33a9457

Browse files
♻️ add beta note, fix markdown, formatting, & score
- added uniform note about developer preview & link to 1.19 release notes - update release notes to link to the tutorial - fix various markdown issues - fix formatting issues - fix issues found by Acrolinx - added additional code to show how to implement the side-by-side view
1 parent 27b0683 commit 33a9457

File tree

1 file changed

+68
-69
lines changed

1 file changed

+68
-69
lines changed
Lines changed: 68 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
---
22
title: Create a Data Visualization Adaptive Card Extension
3-
description: Step by step guide on creating Data Visualization Adaptive Card Extension.
4-
ms.date: 03/03/2024
3+
description: Step-by-step guide on creating Data Visualization Adaptive Card Extension.
4+
ms.date: 04/05/2024
55
ms.localizationpriority: high
66
---
77
# Create a Data Visualization Adaptive Card Extension
88

9-
SharePoint Framework 1.19 introduces a new Data Visualization Template that can be used to implement line charts.
10-
This tutorial provides step-by-step guidance on implementing Data Visualization with ACEs.
9+
The [SharePoint Framework v1.19](../../release-1.19.md) introduces a new Data Visualization Template that can be used to implement line charts. This tutorial provides step-by-step guidance on implementing Data Visualization with Adaptive Card Extensions (ACEs).
10+
11+
[!INCLUDE [developer-preview-notice](../../../../includes/snippets/developer-preview-notice.md)]
1112

1213
> [!NOTE]
13-
> This tutorial assumes that you have installed the SPFx v1.19
14-
>
15-
Before you start, complete the procedures in the following articles to ensure that you understand the basic flow of creating a custom Adaptive Card Extension
16-
- [Build your first SharePoint Adaptive Card Extension](./build-first-sharepoint-adaptive-card-extension.md)
14+
> Before you start, complete the procedures in the following articles to ensure that you understand the basic flow of creating a custom Adaptive Card Extension: [Build your first SharePoint Adaptive Card Extension](./build-first-sharepoint-adaptive-card-extension.md)
1715
1816
## Scaffold an Adaptive Card Extension project
1917

@@ -25,16 +23,16 @@ Create a new project by running the Yeoman SharePoint Generator from within the
2523
yo @microsoft/sharepoint
2624
```
2725

28-
When prompted, enter the following values (select the default option for all prompts omitted below):
26+
When prompted, enter the following values (select the default option for all other prompts):
2927

3028
- **What is your solution name?** dataVisualization-tutorial
3129
- **Which type of client-side component to create?** Adaptive Card Extension
32-
- **Which template do you want to use?** Data Visualization Card Template (preview)
30+
- **Which template do you want to use?** Data Visualization Card Template (preview)
3331
- **What is your Adaptive Card Extension name?** DataVisualization
3432

3533
At this point, Yeoman installs the required dependencies and scaffolds the solution files. This process might take few minutes.
3634

37-
## Update your project's hosted workbench URL.
35+
## Update your project's hosted workbench URL
3836

3937
When you use the gulp task **serve**, by default it will launch a browser with the specified hosted workbench URL specified in your project. The default URL for the hosted workbench in a new project points to an invalid URL.
4038

@@ -52,51 +50,26 @@ When you use the gulp task **serve**, by default it will launch a browser with t
5250

5351
- Change the `{tenantDomain}` ___domain to the URL of your SharePoint tenant and site you want to use for testing. For example: `https://contoso.sharepoint.com/sites/devsite/_layouts/workbench.aspx`.
5452

55-
At this point, if you do `gulp serve`, then you will see the **Data Visualization** card:
53+
At this point, if you do `gulp serve`, and select the add icon in the hosted workbench to open the toolbox, you'll see the **Data Visualization** card:
5654

5755
![See the Data Visualization card icon in the workbench toolbox](../../../../docs/images/viva-extensibility/data-visualization/toolbox.png)
5856

59-
If you add the ACE to the workbench, you will see it already prepared for mock line chart:
57+
Select the **DataVisualization** component to add it to the workbench. The default rendering renders the line chart using mock data:
58+
6059
![Default Data Visualization card](../../../../docs/images/viva-extensibility/data-visualization/ace-default.png)
6160

6261
## Explore the scaffolded code
62+
6363
### Explore the Card View
64-
Locate and open the following file in your project: **./src/adaptiveCardExtensions/dataVisualization/cardView/CardView.ts**.
65-
The card view implements `BaseComponentsCardView` class and implements `cardViewParameters` getter to specify the card configuration:
66-
```ts
67-
// Sample Data
64+
65+
Locate and open the following file: **./src/adaptiveCardExtensions/dataVisualization/cardView/CardView.ts**. The card view implements the `BaseComponentsCardView` base class `cardViewParameters` getter to specify the card configuration:
66+
67+
```typescript
6868
const seriesData : IDataPoint<Date>[] = [
69-
{
70-
x: new Date(2024, 1, 1),
71-
y: 1000
72-
},
73-
{
74-
x: new Date(2024, 2, 1),
75-
y: 2400
76-
},
77-
{
78-
x: new Date(2024, 3, 1),
79-
y: 2000
80-
},
81-
{
82-
x: new Date(2024, 4, 1),
83-
y: 2900
84-
},
85-
{
86-
x: new Date(2024, 5, 1),
87-
y: 3000
88-
},
89-
{
90-
x: new Date(2024, 6, 1),
91-
y: 3100
92-
}
69+
... // omitted for brevity
9370
];
9471

95-
export class CardView extends BaseComponentsCardView<
96-
IDataVisualizationAdaptiveCardExtensionProps,
97-
IDataVisualizationAdaptiveCardExtensionState,
98-
IDataVisualizationCardViewParameters
99-
> {
72+
export class CardView extends BaseComponentsCardView<..> {
10073
public get cardViewParameters(): IDataVisualizationCardViewParameters {
10174
return LineChartCardView({
10275
cardBar: {
@@ -107,46 +80,72 @@ export class CardView extends BaseComponentsCardView<
10780
componentName: 'dataVisualization',
10881
dataVisualizationKind: 'line',
10982
series: [{
110-
data: seriesData,
111-
lastDataPointLabel: '3.1K'
83+
data: seriesData,
84+
lastDataPointLabel: '3.1K'
11285
}]
11386
}
11487
});
11588
}
116-
117-
public get onCardSelection(): IQuickViewCardAction | IExternalLinkCardAction | undefined {
118-
return {
119-
type: 'QuickView',
120-
parameters: {
121-
view: QUICK_VIEW_REGISTRY_ID
122-
}
123-
};
124-
}
12589
}
12690
```
127-
The **body** section of the card view specifies the dataVisualization component.
12891

129-
### Explore possible layouts ###
92+
Notice how the `body` section of the card view specifies the `dataVisualization` component.
13093

131-
Based on the configuration in cardView, a chart can be rendered in 2 layouts
94+
### Explore possible layouts
13295

133-
#### Regular ####
96+
Based on the configuration in card view, a chart can be rendered in two layouts:
13497

135-
Adding 0 or 1 components along with a dataVisualization component in the body
98+
#### Regular
13699

137-
![Regular](../../../../docs/images/viva-extensibility/data-visualization/regular-chart.png)
100+
Adding zero or one component along with a `dataVisualization` component in the body:
138101

139-
#### Right side ####
140-
141-
Adding more than 1 component in the cardView along with dataVisualization component in the body will render the chart on the right side of the card.
102+
![Regular](../../../../docs/images/viva-extensibility/data-visualization/regular-chart.png)
142103

143-
For example: Header and Footer along with dataVisualization component in body.
104+
#### Right side
105+
106+
Adding more than one component in the card view along with `dataVisualization` component in the body will render the chart on the right side of the card. For example: Header and Footer along with `dataVisualization` component in body.
107+
108+
Locate & replace the `cardViewParameters()` getter with the following code to add a `header` and `footer` to the card:
109+
110+
```typescript
111+
public get cardViewParameters(): IDataVisualizationCardViewParameters {
112+
return LineChartCardView({
113+
cardBar: {
114+
componentName: 'cardBar',
115+
title: this.properties.title
116+
},
117+
header: {
118+
componentName: 'text',
119+
text: 'Sales Projection'
120+
},
121+
body: {
122+
componentName: 'dataVisualization',
123+
dataVisualizationKind: 'line',
124+
series: [{
125+
data: seriesData,
126+
lastDataPointLabel: '3.1K'
127+
}]
128+
},
129+
footer: {
130+
componentName: 'cardButton',
131+
title: 'View Details',
132+
action: {
133+
type: 'QuickView',
134+
parameters: {
135+
view: QUICK_VIEW_REGISTRY_ID
136+
}
137+
}
138+
}
139+
});
140+
}
141+
```
144142

145143
![Chart on the right side](../../../../docs/images/viva-extensibility/data-visualization/chart-on-right-side.png)
146144

147-
148145
### Explore the Quick Views
146+
149147
The ACE class is located in the following file: **./src/adaptiveCardExtensions/dataVisualization/quickView/QuickView.ts** and mostly has the same code as [Generic Card View](./build-first-sharepoint-adaptive-card-extension.md).
150148

151149
### Explore the ACE class
152-
The ACE class is located in the following file: **./src/adaptiveCardExtensions/dataVisualization/dataVisualizationAdaptiveCardExtension.ts** and mostly has the same code as [Generic Card View](./build-first-sharepoint-adaptive-card-extension.md).
150+
151+
The ACE class is located in the following file: **./src/adaptiveCardExtensions/dataVisualization/dataVisualizationAdaptiveCardExtension.ts** and mostly has the same code as [Generic Card View](./build-first-sharepoint-adaptive-card-extension.md).

0 commit comments

Comments
 (0)