Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. mport 'babel-polyfill';
  2. import picasso from 'picasso.js';
  3. import picassoQ from 'picasso-plugin-q';
  4. const enigma = require('enigma.js');
  5. const schema = require('enigma.js/schemas/3.2.json');
  6.  
  7. (async () => {
  8.  
  9. //Objective config
  10. const barChartObject = {
  11. qInfo: {
  12. qType: 'measure',
  13. qId: 'barChartExample'
  14. },
  15. type: 'my-picasso-barChart',
  16. qHyperCubeDef: {
  17. qDimensions: [
  18. {
  19. labels: true,
  20. qDef: {
  21. qFieldDefs: [
  22. 'Rating'
  23. ],
  24. qSortCriterias: [
  25. {
  26. qSortByAscii: 1
  27. }
  28. ]
  29. }
  30. }
  31. ],
  32. qMeasures: [
  33. {
  34. labels: true,
  35. qDef: {
  36. qLabel: 'Votes',
  37. qDef: 'Votes',
  38. autoSort: true
  39. }
  40. }
  41. ],
  42. qInitialDataFetch: [
  43. {
  44. qHeight: 15,
  45. qWidth: 2
  46. }
  47. ]
  48. }
  49. }
  50.  
  51. try {
  52. console.log('Creating session app on engine.');
  53. const session = enigma.create({
  54. schema,
  55. url: 'ws://localhost:19076',
  56. createSocket: url => new WebSocket(url),
  57. });
  58. const qix = await session.open();
  59. const app = await qix.createSessionApp();
  60.  
  61. //Inlined data
  62. const script = `Stars:
  63. LOAD * INLINE
  64. [
  65. Rating,Votes,
  66. 10,3404,
  67. 9,2234,
  68. 8,6243,
  69. 7,13785,
  70. 6,20325,
  71. 5,18046,
  72. 4,10179,
  73. 3,5844,
  74. 2,3244,
  75. 1,3208
  76. ];`;
  77. await app.setScript(script);
  78. await app.doReload();
  79.  
  80. //Create objectives
  81. const object = await app.createSessionObject(barChartObject);
  82. const layout = await object.getLayout();
  83.  
  84.  
  85.  
  86. } catch (err) {
  87. console.log('Whoops! An error occurred.', err);
  88. process.exit(1);
  89. }
  90. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement