Skip to content

Commit

Permalink
docs: updates readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Kwayzaar committed Nov 19, 2024
1 parent bd2b979 commit 3b13287
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 29 deletions.
29 changes: 15 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
## How to test

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

2. have labels and data in there e.g.
2. Labels and data from `chart_data` are sent as:

```js
{
labels: ['January', 'February', 'March', 'April', 'May'],
data: {
datasets: [
{
data: [300, 300, 200]
}
]
}
}
Result: [
{ labels: 0, data: 300 },
{ labels: 1, data: 300 },
{ labels: 2, data: 283 },
{ labels: 3, data: 266 },
{ labels: 4, data: 250 },
{ labels: 5, data: 233 },
{ labels: 6, data: 216 },
{ labels: 7, data: 200 }
];
```

3. add iframe question with `answerLabel` parameter
e.g. `https://iframe_address.com?answerLabel=my_data`
3. iframe question with `answerLabel` parameter sends `chart_data` label (NOT the templated `chart_data` variable)
e.g. `https://iframe_address.com?answerLabel=chart_data`
14 changes: 0 additions & 14 deletions data.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,6 @@ const options = {
}
};

// Default values are handled in the chart_data variable
// const defaultData = {
// datasets: [
// {
// data: [1, 10]
// }
// ]
// };

(async function () {
const result = await loadClientConfig();

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

// chart_data will have labels hard-coded in
// if (labels) {
// options.scales.x.labels = labels;
// }

const ctx = document.getElementById("data");

new Chart(ctx, {
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<title>Chart.js</title>
</head>
<body>
<div style="width: 500px">
<div style="min-width: 400px">
<canvas id="data"></canvas>
</div>

Expand Down

0 comments on commit 3b13287

Please sign in to comment.