Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mport 'babel-polyfill';
- import picasso from 'picasso.js';
- import picassoQ from 'picasso-plugin-q';
- const enigma = require('enigma.js');
- const schema = require('enigma.js/schemas/3.2.json');
- (async () => {
- //Objective config
- const barChartObject = {
- qInfo: {
- qType: 'measure',
- qId: 'barChartExample'
- },
- type: 'my-picasso-barChart',
- qHyperCubeDef: {
- qDimensions: [
- {
- labels: true,
- qDef: {
- qFieldDefs: [
- 'Rating'
- ],
- qSortCriterias: [
- {
- qSortByAscii: 1
- }
- ]
- }
- }
- ],
- qMeasures: [
- {
- labels: true,
- qDef: {
- qLabel: 'Votes',
- qDef: 'Votes',
- autoSort: true
- }
- }
- ],
- qInitialDataFetch: [
- {
- qHeight: 15,
- qWidth: 2
- }
- ]
- }
- }
- try {
- console.log('Creating session app on engine.');
- const session = enigma.create({
- schema,
- url: 'ws://localhost:19076',
- createSocket: url => new WebSocket(url),
- });
- const qix = await session.open();
- const app = await qix.createSessionApp();
- //Inlined data
- const script = `Stars:
- LOAD * INLINE
- [
- Rating,Votes,
- 10,3404,
- 9,2234,
- 8,6243,
- 7,13785,
- 6,20325,
- 5,18046,
- 4,10179,
- 3,5844,
- 2,3244,
- 1,3208
- ];`;
- await app.setScript(script);
- await app.doReload();
- //Create objectives
- const object = await app.createSessionObject(barChartObject);
- const layout = await object.getLayout();
- } catch (err) {
- console.log('Whoops! An error occurred.', err);
- process.exit(1);
- }
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement