Scatter Chart: Data Push

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; }

I got it working now guys. If anyone might be interested, please leave a comment :slight_smile:

I am interested!!! What I need is to connect a chart to a dataset. Basically I want the chart to display the average conversion rate from my users (which is entered through a form into the dataset) but I can’t figure out the code to call the dataset, calculate the average and then display it in the chart.

How do you made?