diff --git a/README.md b/README.md index 0670267c..95a27533 100644 --- a/README.md +++ b/README.md @@ -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` diff --git a/data.js b/data.js index bc5b365c..c228e06e 100644 --- a/data.js +++ b/data.js @@ -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(); @@ -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, { diff --git a/index.html b/index.html index 99aa59bf..a6f89d0b 100644 --- a/index.html +++ b/index.html @@ -6,7 +6,7 @@