440
Views
1
Comments
How to import a module of Javascript File to an expression
Question

Hi guys,

I need to implement the javascript code to generate a graphic.  I include the JavaScript file (vanilla.js) as a Resource (Data tab, bottom). Specify the Deploy Action to "Deploy to Target Directory", and add a Target Directory (e.g. "js"). 


import { VerticalBarChartGrouped } from '/js/vanilla';

const chart = new VerticalBarChartGrouped({
  element: document.getElementById('simple-example'),
  data: Data,
  y: { unit: 'Billion (SEK)' }
});

chart.init();

I used an expression.

but it isn't show anything.

Thank you in advance

2020-02-28 09-46-54
Eduardo Jauch

Hi,

If you can, use the AddJavaScriptTag method from the HttpRequestHandler extension. It's easier.

In any case, remember that you need to set the Deploy To Target Directory attribute of the resource, or it will not be available.

And, to finish, I think your relative paths are not ok: https://success.outsystems.com/Documentation/11/Developing_an_Application/Use_Data/Use_Resources

Cheers!

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.