Pre loader

Setup in Angular-ionic

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

1
0

I am considering applying server-side licensing for my javerScript application.

In the document below, there is a phrase “Our server-side licensing component is written in C++.”
(https://support.scichart.com/index.php?/Knowledgebase/Article/View/17256/42/)

However, there is only asp.net sample code on the provided github.
(https://github.com/ABTSoftware/SciChart.JS.Examples/tree/master/Sandbox/demo-dotnet-server-licensing)

I wonder if there is a sample code implemented in C++ for server-side licensing.

Can you provide c++ sample code?
Also, are there any examples to run on Ubuntu?

Version
3.0.266
Attachments
  • You must to post comments
1
0

Hi Eddy,

For more details about wasm deployment, see our documentation page here.

The simples way to get this working is to load wasm file from CDN. To do this, call this function once (it’s a static function) before any call to SciChartSurface.create():

import {SciChartSurface} from "scichart/Charting/Visuals/SciChartSurface"; 
SciChartSurface.useWasmFromCDN();

This will load and cache the wasm file in your browser, or chrome instance if using Electron. It does require an internet connection to work. It is also possible to package wasm with your application so that you can load SciChart.js charts without an internet connection.

We don’t have much direct experience with Ionic but another customer was able to get it to work (using react not angular) by copying the wasm and data to different places:

To do this, we use npm package copy-files-from-to and
copy-files-from-to.json with this config

{
    "copyFilesSettings": {
      "whenFileExists": "overwrite"
    },
    "copyFiles": [
      {
        "from": "./node_modules/scichart/_wasm/scichart2d.data",
        "to": "./public/scichart2d.data"
      },
      {
        "from": "./node_modules/scichart/_wasm/scichart2d.wasm",
        "to": "./public/static/js/scichart2d.wasm"
      }
    ]
  }
  

This is executed when building. See package.json scripts:

  "scripts": {
      "copyWasm": "copy-files-from-to --config copy-files-from-to.json",
      "start": "npm run copyWasm && ng serve",
      "build": "npm run copyWasm && ng build",
    },
  

The next problem you will hit is licensing. So it turns out, on the device, some part of the ionic framework – I think Capacitor – is running a local server which it uses to load and serve the html/js etc to the embedded browser in the app. From SciChart’s point of view, it appears to be running from localhost. This makes it awkward to generate a license key, as we don’t allow production deployments to localhost.

Fortunately there appears to be a workaround. The capacitor config allows you to specify the server hostname that the application will see. You set this to whatever you like, probably your application name, and then you put that same value as the domain in your license. So your capacitor.config.json should contain something like

{
     "appId": "io.ionic.starter",
    "appName": "myscichartapp",
     "webDir": "build",
     "bundledWebRuntime": false,
     "server": {
        "hostname": "myscichartapp"
      }
}

Then you can use myscichartapp as the domain name in your runtime license.

This config is documented at https://capacitorjs.com/docs/config and has this comment:
/**
* Configure the local hostname of the device.
*
* It is recommended to keep this as localhost as it allows the use of
* Web APIs that would otherwise require a secure
* context

* such as
* navigator.geolocation
* and
* MediaDevices.getUserMedia.
*
* @since 1.0.0
* @default localhost
*/

Best regards
Andrew

  • You must to post comments
1
0

Hi Andrew,

First, thanks for your response !

Yes i managed to get it worked by using the wasmFromCDN function, but the goal is to having run it with no internet connection on the targeted device, so i will have to make the copyfile method to runs.

Then i have setup my capacitor config like you said :

const config: CapacitorConfig = {
appId: ‘io.ionic.starter’,
appName: ‘scichart-ionic’,
webDir: ‘www’,
bundledWebRuntime: false,
server: {
hostname: “scichart-ionic”
}
};

And i have setup my trial license key like so :

SciChartSurface.setRuntimeLicenseKey(“licensekey”);

Then, my understanding is that ionic builds / serves into the www folder, so i modified the copy-line to get the files copied in this folder like so :

{
“copyFilesSettings”: {
“whenFileExists”: “overwrite”
},
“copyFiles”: [
{
“from”: “./node_modules/scichart/_wasm/scichart2d.data”,
“to”: “./src/scichart2d.data”
},
{
“from”: “./node_modules/scichart/_wasm/scichart2d.wasm”,
“to”: “./src/scichart2d.wasm”
},
{
“from”: “./node_modules/scichart/_wasm/scichart2d.data”,
“to”: “./www/scichart2d.data”
},
{
“from”: “./node_modules/scichart/_wasm/scichart2d.wasm”,
“to”: “./www/scichart2d.wasm”
}
]
}

But i still got the same errors :/

  • You must to post comments
0
0

Hi

I think the assumption that ionic builds / serves into the www folder might not be correct. If you look in that folder, you’ll see an assets folder and a static/js folder, which actually contains the site js. I’m only going by the example another customer managed to get working. The ionic/capacitor docs are not clear. In any case, copying to ./public and/or ./public/static/js was what worked for them.

Regards
David

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies