Published
Edited
May 4, 2021
1 fork
Insert cell
md`# Enigma.js - GetObject() with all data`
Insert cell
element = html`<div></div>`
Insert cell
import { enigmaApp } from "@yianni-ververis/enigma-js"
Insert cell
{
const app = await enigmaApp;
const model = await app.getObject('rJFbvG'); // It's a table
const modelLayout = await model.getLayout();
const data = [];
const columns = modelLayout.qHyperCube.qSize.qcx;
const totalheight = modelLayout.qHyperCube.qSize.qcy;
// Replace pageheight & numberOfPages number with the comments to get all data
const pageheight = 5 // Math.floor(10000 / columns);
const numberOfPages = 3 // Math.ceil(totalheight / pageheight);
for (let i = 0; i < numberOfPages; i++) {
const page = {
qTop: pageheight * i,
qLeft: 0,
qWidth: columns,
qHeight: pageheight,
};
const row = await model.getHyperCubeData('/qHyperCubeDef', [page]);
data.push(...row[0].qMatrix);
}
const table = data.map(x => `<tr><td>${x[0].qText}</td><td>${x[1].qText}</td><td>${x[2].qText}</td></tr>`);
return html`
<table style="width:100%">
<tr>
<th>Department</th>
<th>Priority</th>
<th>Avg Duration</th>
</tr>
${table}
</table>
`
}
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more