<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Using enigma.js to create a chart instantly in Qlik Automate</title>
    <link>https://community.qlik.com/t5/Qlik-Automate/Using-enigma-js-to-create-a-chart-instantly/m-p/2443765#M3727</link>
    <description>&lt;P&gt;Hello,&amp;nbsp;&lt;BR /&gt;I have been working on integrating an Angular application with Qlik Sense. The objective is to establish a connection, create an application, set up the script, reload the data, and build a sheet containing a chart. &lt;BR /&gt;However, I have encountered an issue with chart creation. &lt;BR /&gt;The chart is being created, but it doesn't appear within the designated sheet.&lt;BR /&gt;I have used enigma.js. and below is the code snippet I have utilized to generate the sheet and the pie chart:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;async function createNewAppAndLoadData(global: any, newAppName: string): Promise&amp;lt;any&amp;gt; {
  // Create a new app
  const newApp = await global.createApp({ qAppName: newAppName });
  // Open the newly created app to get the full app object
  const openedApp = await global.openDoc(newApp.qAppId);
  console.log('Opened app:', openedApp);

  const scriptContent = `
    TempTable:
    Load
      RecNo() as ID,
      Rand() as Value
    AutoGenerate 100;
  `;

  // Set the script of the opened app
  await openedApp.setScript(scriptContent);
  console.log('Script set on the opened app');
  
  // Reload the opened app
  await openedApp.doReload();
  console.log('Reload complete for the opened app');

  const newSheet = await openedApp.createObject({
    qInfo: {
      qType: 'sheet',
    },
    qMetaDef: {
      title: 'My new sheet created',
    },
    
    
  });
  console.log('New sheet created:', newSheet);
  const sheetId = newSheet.id
  console.log('New sheet created:', sheetId);
 
 const chartDef = {
    "qInfo": {
        "qType": "piechart"
    },
    "qHyperCubeDef": {
        "qDimensions": [
            {
                "qDef": {
                    "qFieldDefs": ["ID"],
                    "qSortCriterias": [
                    ]
                },
            }
        ],
        "qMeasures": [
            {
                "qDef":{
                    "qDef": "=Sum(Value)"
                }
            }
        ],
        "qInitialDataFetch": [
            {
                "qLeft": 0,
                "qWidth": 10,
                "qTop": 0,
                "qHeight": 100
            }
        ]
    }
  };

  const chartHandle = await openedApp.createSessionObject(chartDef);
  console.log(chartHandle);
  const chartLayout = await chartHandle.getLayout(); 
  console.log(chartLayout);

  await openedApp.doSave();
  console.log('App saved');
  return openedApp;
  
}
 &lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Can somebody help me?. &lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 23 Apr 2024 06:55:21 GMT</pubDate>
    <dc:creator>Nikpapi</dc:creator>
    <dc:date>2024-04-23T06:55:21Z</dc:date>
    <item>
      <title>Using enigma.js to create a chart instantly</title>
      <link>https://community.qlik.com/t5/Qlik-Automate/Using-enigma-js-to-create-a-chart-instantly/m-p/2443765#M3727</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;BR /&gt;I have been working on integrating an Angular application with Qlik Sense. The objective is to establish a connection, create an application, set up the script, reload the data, and build a sheet containing a chart. &lt;BR /&gt;However, I have encountered an issue with chart creation. &lt;BR /&gt;The chart is being created, but it doesn't appear within the designated sheet.&lt;BR /&gt;I have used enigma.js. and below is the code snippet I have utilized to generate the sheet and the pie chart:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;async function createNewAppAndLoadData(global: any, newAppName: string): Promise&amp;lt;any&amp;gt; {
  // Create a new app
  const newApp = await global.createApp({ qAppName: newAppName });
  // Open the newly created app to get the full app object
  const openedApp = await global.openDoc(newApp.qAppId);
  console.log('Opened app:', openedApp);

  const scriptContent = `
    TempTable:
    Load
      RecNo() as ID,
      Rand() as Value
    AutoGenerate 100;
  `;

  // Set the script of the opened app
  await openedApp.setScript(scriptContent);
  console.log('Script set on the opened app');
  
  // Reload the opened app
  await openedApp.doReload();
  console.log('Reload complete for the opened app');

  const newSheet = await openedApp.createObject({
    qInfo: {
      qType: 'sheet',
    },
    qMetaDef: {
      title: 'My new sheet created',
    },
    
    
  });
  console.log('New sheet created:', newSheet);
  const sheetId = newSheet.id
  console.log('New sheet created:', sheetId);
 
 const chartDef = {
    "qInfo": {
        "qType": "piechart"
    },
    "qHyperCubeDef": {
        "qDimensions": [
            {
                "qDef": {
                    "qFieldDefs": ["ID"],
                    "qSortCriterias": [
                    ]
                },
            }
        ],
        "qMeasures": [
            {
                "qDef":{
                    "qDef": "=Sum(Value)"
                }
            }
        ],
        "qInitialDataFetch": [
            {
                "qLeft": 0,
                "qWidth": 10,
                "qTop": 0,
                "qHeight": 100
            }
        ]
    }
  };

  const chartHandle = await openedApp.createSessionObject(chartDef);
  console.log(chartHandle);
  const chartLayout = await chartHandle.getLayout(); 
  console.log(chartLayout);

  await openedApp.doSave();
  console.log('App saved');
  return openedApp;
  
}
 &lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Can somebody help me?. &lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2024 06:55:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Qlik-Automate/Using-enigma-js-to-create-a-chart-instantly/m-p/2443765#M3727</guid>
      <dc:creator>Nikpapi</dc:creator>
      <dc:date>2024-04-23T06:55:21Z</dc:date>
    </item>
    <item>
      <title>Re: Using enigma.js to create a chart instantly</title>
      <link>https://community.qlik.com/t5/Qlik-Automate/Using-enigma-js-to-create-a-chart-instantly/m-p/2493010#M5115</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;
&lt;P&gt;Did you find a solution?&lt;/P&gt;
&lt;P&gt;Curious about how, in that case.&lt;/P&gt;
&lt;P&gt;/lars&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2024 16:13:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Qlik-Automate/Using-enigma-js-to-create-a-chart-instantly/m-p/2493010#M5115</guid>
      <dc:creator>Skage</dc:creator>
      <dc:date>2024-11-15T16:13:45Z</dc:date>
    </item>
    <item>
      <title>Re: Using enigma.js to create a chart instantly</title>
      <link>https://community.qlik.com/t5/Qlik-Automate/Using-enigma-js-to-create-a-chart-instantly/m-p/2493384#M5128</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/133643"&gt;@Skage&lt;/a&gt;&amp;nbsp;unfortunately no. We've used another approach for this issue.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2024 08:13:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Qlik-Automate/Using-enigma-js-to-create-a-chart-instantly/m-p/2493384#M5128</guid>
      <dc:creator>Nikpapi</dc:creator>
      <dc:date>2024-11-19T08:13:43Z</dc:date>
    </item>
  </channel>
</rss>

