Skip to content

Commit 1cc2120

Browse files
committed
Update Get Started examples for Dashboard and Table View
1 parent 0e0ff02 commit 1cc2120

File tree

5 files changed

+70
-68
lines changed

5 files changed

+70
-68
lines changed

dashboard-table-view/html-css-js/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
Survey.slk("YjA3ZGFkZTMtNjU5NS00YTYxLTkzZmEtYWJiOThjMWVhNjk3JmRvbWFpbnM6c3VydmV5anM7MT0yMDM0LTEwLTE2LDI9MjAzNC0xMC0xNiw0PTIwMzQtMTAtMTY=");
2+
13
const surveyJson = {
24
elements: [{
35
name: "satisfaction-score",

get-started-analytics/angular/src/app/app.component.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,22 @@ const surveyJson = {
2525
completedHtml: "Thank you for your feedback!",
2626
};
2727

28-
const surveyResults = [{
29-
"satisfaction-score": 5,
30-
"nps-score": 10
31-
}, {
32-
"satisfaction-score": 5,
33-
"nps-score": 9
34-
}, {
35-
"satisfaction-score": 3,
36-
"nps-score": 6
37-
}, {
38-
"satisfaction-score": 3,
39-
"nps-score": 6
40-
}, {
41-
"satisfaction-score": 2,
42-
"nps-score": 3
43-
}];
28+
function randomIntFromInterval(min: number, max: number): number {
29+
return Math.floor(Math.random() * (max - min + 1) + min);
30+
}
31+
32+
function generateData() {
33+
const data = [];
34+
for (let index = 0; index < 100; index++) {
35+
const satisfactionScore = randomIntFromInterval(index % 3 ? 1 : 3, 5);
36+
const npsScore = satisfactionScore > 3 ? randomIntFromInterval(7, 10) : randomIntFromInterval(0, 6);
37+
data.push({
38+
"satisfaction-score": satisfactionScore,
39+
"nps-score": npsScore
40+
});
41+
}
42+
return data;
43+
}
4444

4545
const vizPanelOptions = {
4646
allowHideQuestions: false
@@ -56,7 +56,7 @@ export class AppComponent implements AfterViewInit {
5656
const survey = new Model(surveyJson);
5757
const vizPanel = new VisualizationPanel(
5858
survey.getAllQuestions(),
59-
surveyResults,
59+
generateData(),
6060
vizPanelOptions
6161
);
6262
vizPanel.render("surveyVizPanel");

get-started-analytics/html-css-js/index.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,30 @@ const surveyJson = {
2525

2626
const survey = new Survey.Model(surveyJson);
2727

28-
const surveyResults = [{
29-
"satisfaction-score": 5,
30-
"nps-score": 10
31-
}, {
32-
"satisfaction-score": 5,
33-
"nps-score": 9
34-
}, {
35-
"satisfaction-score": 3,
36-
"nps-score": 6
37-
}, {
38-
"satisfaction-score": 3,
39-
"nps-score": 6
40-
}, {
41-
"satisfaction-score": 2,
42-
"nps-score": 3
43-
}];
28+
function randomIntFromInterval(min, max) {
29+
return Math.floor(Math.random() * (max - min + 1) + min);
30+
}
31+
32+
function generateData() {
33+
const data = [];
34+
for (let index = 0; index < 100; index++) {
35+
const satisfactionScore = randomIntFromInterval(index % 3 ? 1 : 3, 5);
36+
const npsScore = satisfactionScore > 3 ? randomIntFromInterval(7, 10) : randomIntFromInterval(0, 6);
37+
data.push({
38+
"satisfaction-score": satisfactionScore,
39+
"nps-score": npsScore
40+
});
41+
}
42+
return data;
43+
}
4444

4545
const vizPanelOptions = {
4646
allowHideQuestions: false
4747
}
4848

4949
const vizPanel = new SurveyAnalytics.VisualizationPanel(
5050
survey.getAllQuestions(),
51-
surveyResults,
51+
generateData(),
5252
vizPanelOptions
5353
);
5454

get-started-analytics/react/src/components/Dashboard.tsx

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,22 @@ const surveyJson = {
2828
completedHtml: "Thank you for your feedback!",
2929
};
3030

31-
const surveyResults = [{
32-
"satisfaction-score": 5,
33-
"nps-score": 10
34-
}, {
35-
"satisfaction-score": 5,
36-
"nps-score": 9
37-
}, {
38-
"satisfaction-score": 3,
39-
"nps-score": 6
40-
}, {
41-
"satisfaction-score": 3,
42-
"nps-score": 6
43-
}, {
44-
"satisfaction-score": 2,
45-
"nps-score": 3
46-
}];
31+
function randomIntFromInterval(min: number, max: number): number {
32+
return Math.floor(Math.random() * (max - min + 1) + min);
33+
}
34+
35+
function generateData() {
36+
const data = [];
37+
for (let index = 0; index < 100; index++) {
38+
const satisfactionScore = randomIntFromInterval(index % 3 ? 1 : 3, 5);
39+
const npsScore = satisfactionScore > 3 ? randomIntFromInterval(7, 10) : randomIntFromInterval(0, 6);
40+
data.push({
41+
"satisfaction-score": satisfactionScore,
42+
"nps-score": npsScore
43+
});
44+
}
45+
return data;
46+
}
4747

4848
const vizPanelOptions: IVisualizationPanelOptions = {
4949
allowHideQuestions: false
@@ -60,7 +60,7 @@ export default function DashboardComponent() {
6060
if (!vizPanel && !!survey) {
6161
const vizPanel = new VisualizationPanel(
6262
survey.getAllQuestions(),
63-
surveyResults,
63+
generateData(),
6464
vizPanelOptions
6565
);
6666
setVizPanel(vizPanel);

get-started-analytics/vue3/src/components/SurveyDashboard.vue

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,22 @@ const surveyJson = {
2727
completedHtml: "Thank you for your feedback!",
2828
};
2929
30-
const surveyResults = [{
31-
"satisfaction-score": 5,
32-
"nps-score": 10
33-
}, {
34-
"satisfaction-score": 5,
35-
"nps-score": 9
36-
}, {
37-
"satisfaction-score": 3,
38-
"nps-score": 6
39-
}, {
40-
"satisfaction-score": 3,
41-
"nps-score": 6
42-
}, {
43-
"satisfaction-score": 2,
44-
"nps-score": 3
45-
}];
30+
function randomIntFromInterval(min: number, max: number): number {
31+
return Math.floor(Math.random() * (max - min + 1) + min);
32+
}
33+
34+
function generateData() {
35+
const data = [];
36+
for (let index = 0; index < 100; index++) {
37+
const satisfactionScore = randomIntFromInterval(index % 3 ? 1 : 3, 5);
38+
const npsScore = satisfactionScore > 3 ? randomIntFromInterval(7, 10) : randomIntFromInterval(0, 6);
39+
data.push({
40+
"satisfaction-score": satisfactionScore,
41+
"nps-score": npsScore
42+
});
43+
}
44+
return data;
45+
}
4646
4747
const vizPanelOptions = {
4848
allowHideQuestions: false
@@ -52,7 +52,7 @@ onMounted(() => {
5252
const survey = new Model(surveyJson);
5353
const vizPanel = new VisualizationPanel(
5454
survey.getAllQuestions(),
55-
surveyResults,
55+
generateData(),
5656
vizPanelOptions
5757
);
5858
vizPanel.render("surveyVizPanel");

0 commit comments

Comments
 (0)