Skip to content

Commit 3b13287

Browse files
committed
docs: updates readme
1 parent bd2b979 commit 3b13287

File tree

3 files changed

+16
-29
lines changed

3 files changed

+16
-29
lines changed

README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
## How to test
22

3-
1. create a calculated variable `my_data` in variant
3+
1. Calculated variable `chart_data` in variant sends Results array
4+
link to variant: `https://studio.formsort.com/client/erictest/flow/custom-question/variant/main/variables/calculated_inline`
45

5-
2. have labels and data in there e.g.
6+
2. Labels and data from `chart_data` are sent as:
67

78
```js
8-
{
9-
labels: ['January', 'February', 'March', 'April', 'May'],
10-
data: {
11-
datasets: [
12-
{
13-
data: [300, 300, 200]
14-
}
15-
]
16-
}
17-
}
9+
Result: [
10+
{ labels: 0, data: 300 },
11+
{ labels: 1, data: 300 },
12+
{ labels: 2, data: 283 },
13+
{ labels: 3, data: 266 },
14+
{ labels: 4, data: 250 },
15+
{ labels: 5, data: 233 },
16+
{ labels: 6, data: 216 },
17+
{ labels: 7, data: 200 }
18+
];
1819
```
1920

20-
3. add iframe question with `answerLabel` parameter
21-
e.g. `https://iframe_address.com?answerLabel=my_data`
21+
3. iframe question with `answerLabel` parameter sends `chart_data` label (NOT the templated `chart_data` variable)
22+
e.g. `https://iframe_address.com?answerLabel=chart_data`

data.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,6 @@ const options = {
6060
}
6161
};
6262

63-
// Default values are handled in the chart_data variable
64-
// const defaultData = {
65-
// datasets: [
66-
// {
67-
// data: [1, 10]
68-
// }
69-
// ]
70-
// };
71-
7263
(async function () {
7364
const result = await loadClientConfig();
7465

@@ -78,11 +69,6 @@ const options = {
7869
console.log(res);
7970
console.log(clientConfig);
8071

81-
// chart_data will have labels hard-coded in
82-
// if (labels) {
83-
// options.scales.x.labels = labels;
84-
// }
85-
8672
const ctx = document.getElementById("data");
8773

8874
new Chart(ctx, {

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<title>Chart.js</title>
77
</head>
88
<body>
9-
<div style="width: 500px">
9+
<div style="min-width: 400px">
1010
<canvas id="data"></canvas>
1111
</div>
1212

0 commit comments

Comments
 (0)