Skip to content

Instantly share code, notes, and snippets.

@moshfeu
Last active September 25, 2020 22:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moshfeu/b9d201de5806fde1f89e3267c33e41c5 to your computer and use it in GitHub Desktop.
Save moshfeu/b9d201de5806fde1f89e3267c33e41c5 to your computer and use it in GitHub Desktop.
Corvid Analytics page's code
import wixData from 'wix-data';
import _ from 'lodash';
$w.onReady(function () {
const getDataPromise = wixData.query('views').find();
// The iframe is ready
$w('#html1').onMessage(async ({ data }) => {
if (data.type === 'ready') {
const results = await getDataPromise;
// Group the rows by date and map it to DataTable format
const chartData = Object.entries(
_.groupBy(results.items, (item) => item._createdDate.toDateString())
).map(([date, entities]) => [new Date(date), entities.length]);
// Post back to the page with the data
$w('#html1').postMessage({
type: 'graph',
data: chartData,
});
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment