Setting Up a Web Server
To view the ChartIQ sample templates, such as helloworld.html or technical-analysis-chart.html, you must load the files in a web browser using the HTTP or HTTPS protocol. You cannot use a
file:/// URI or double-click or double-tap the template files to load them.
The ChartIQ library is made up of ES6 modules. ES6 requires special HTTP headers that provide enhanced security for cross-origin resource sharing (CORS).
If your code editor includes a live server (for example, the Live Server Extension in Visual Studio Code), you can open the sample template files in your editor and run them from the editor's live server.
The npm http-server package provides a lightweight web server that you can easily install (and uninstall) on your local computer.
To install http-server:
Download and install Node.js.
Open a terminal window on your computer.
In the terminal window, navigate to the directory that contains the templates; for example, chartiq.
This directory will be the root directory of the server.
npx http-serverto install and start the server.
Load a template in your web browser using the
localhosthostname and port
8080. For example, enter the following in your browser's address bar:
If you have access to a web server on your organization's network, install ChartIQ on the web server and load the sample templates from there.
To install ChartIQ on a network web server:
Copy the folder containing the library to the root of your web server (see the Installing section of the Getting the SDK tutorial).
Load a template in your web browser using the domain name or IP address of the server. For example, enter the following in your browser's address bar: