Hi Parsheeta,
From looking at your code I think that the iFrame element you used is too small to fit the content.
I’d suggest to do 1 of the following options:
Increase the iFrame element height
or
decrease the height of the canvas element you used inside.
I see you used "height=“96%” on your code
No when I was running the original code I wasn’t getting the output I needed, it was showing some big number (6893 I think) in the first row of the table and nothing else. That’s why I had to change it to this. I think the reduce function was to blame for that which is why I changed it.
mmmmmm I think you will have to revisit your codes. I just tested the original vorbly graph and works just fine. I just changed one line of page code but everything else is the original code from Vorbly:
the code:
import wixData from 'wix-data';
import {monthSort} from 'public/months';
$w.onReady(function () {
$w("#table1").columns = [
{
"id": "col1",
"dataPath": "month",
"label": "Month",
"type": "string"
},
{
"id": "col2",
"dataPath": "total",
"label": "Total Expenses",
"visible": true,
"type": "number"
}
];
wixData.query("Expenses")
.ascending("month")
.limit(1000) // Max limit of 1,000 //
.find()
.then( (result) => {
const months = result.items.map(x => x.month)
.filter((obj, index, self) => index === self.indexOf(obj))
.sort(monthSort);
const aggregated = months.map(x => {
return {
month: x,
total: result.items.filter(obj => obj.month === x)
.map(z => z.amount)
.reduce((sum, current) => sum + current)
};
});
$w("#table1").rows = aggregated;
let tableArr = [];
for ( var i = 0; i < $w("#table1").rows.length; i++ ) {
tableArr.push (
$w("#table1").rows[i]["total"]
)
}
$w("#html1").postMessage(tableArr);
});
});
export function dropdown1_change(event, $w) {
let product = $w("#dropdown1").value;
$w("#table1").columns = [
{
"id": "col1",
"dataPath": "month",
"label": "Month",
"type": "string"
},
{
"id": "col2",
"dataPath": "total",
"label": "Total Expenses",
"visible": true,
"type": "number"
}
];
wixData.query("Expenses")
.ascending("month")
.eq("type", product)
.limit(1000)
.find()
.then( (result) => {
const months = result.items.map(x => x.month)
.filter((obj, index, self) => index === self.indexOf(obj))
.sort(monthSort);
const aggregated = months.map(x => {
return {
month: x,
total: result.items.filter(obj => obj.month === x)
.map(z => z.amount)
.reduce((sum, current) => sum + current)
};
});
$w("#table1").rows = aggregated;
let tableArr = [];
for ( var i = 0; i < $w("#table1").rows.length; i++ ) {
tableArr.push (
$w("#table1").rows[i]["total"]
)
}
console.log(tableArr);
$w("#html1").postMessage(tableArr);
$w("#html1").onMessage((event) => {
if (event.data.type === 'ready') {
$w("#html1").postMessage(tableArr);
}
if (event.data.type === 'click') {
$w("#text1").text = `The expenses in ${event.data.label} is ${event.data.value} rupees.`; // I use {event.data.label} instead of {months}
$w("#text1").show();
}
});
});
}
@t8311834 I used your code and I’m still not getting the right output (the chart is getting scaled properly now though). Also I noticed that the table is saying the expenses for November is 670.7 which is correct but the graph is placing that on March.
@t8311834 hey please send me a link to your editor asap. It’s urgent and I tried your code again but I’m still getting the same output that I attached earlier.