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).

Live server

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.

Local 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:

  1. Download and install Node.js.

  2. Open a terminal window on your computer.

  3. 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.

  4. Enter npx http-server to install and start the server.

  5. Load a template in your web browser using the localhost hostname and port 8080. For example, enter the following in your browser's address bar:

    http://localhost:8080/helloworld.html
    

Network server

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:

  1. Copy the folder containing the library to the root of your web server (see the Installing section of the Getting the SDK tutorial).

  2. 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:

    http://mydomain/chartiq/helloworld.html