Dear All,
I am definitely new to coding and I am having problems in making the scatter chart from chart.js to work. Data are sent from page code as an array (. . .i think) to html iframe. The problem is getting the data from the array and push it as x and y value. I hope someone can check into my codes please and give any suggestion. Any help would be appreciated. Super thanks in advance.
here is my page code:
import wixData from ‘wix-data’;
$w.onReady( function () {
$w(‘#scatterhtml’).onMessage((event) => {
let received = event.data;
$w(‘#dataText’).text = received;
console.log(received);
})
refreshData();
});
…
…
…
function refreshData () {
wixData.query(“SalaryScatter”)
.ascending(“currentSalary”)
.find()
.then((results) => {
if (results.items.length > 0) {
var rawData = results.items;
console.log(rawData);
var arrData = JSON.stringify(rawData)
var data = arrData;
console.log(data);
$w(‘#scatterhtml’).postMessage(data);
}
})
}
and here is my html code:
Scatter Chart canvas { -moz-user-select: none; -webkit-user-select: none; -ms-user-select: none; }