Home

Awesome

Liquify

Live charts

CI npm version

Liquify: fast, multi-threaded visualization of stream data with ChartJS & Angular.

The aim of Liquify is to provide a fast, customizable and easy way to use the ChartJS library to show and update many charts that consume stream data from web socket. Liquify may display and update 50 to 100 charts with enjoyable frame rates. See performance measurements below.

Liquify is built as an Angular library, that has two main parts: the liquify component, that provides the API of the library, and the webworker, that draws the chart.

System requirements

The library supports the Angular applications, and it requires the installation of the ai/offscreen-canvas library. In order to display the charts, the webpage needs to be opened in a web browser, that supports the webworker and offscreen-canvas technologies and getting the 2D rendering context of the offscreen-canvas.

Usage

To install Liquify to your application, run:

npm install @sakos95/liquify

Add LiquifyModule to your app.module.ts:

@NgModule({
...
imports: [
    ...
    LiquifyModule
],
...
})

Add lib-liquify to your html code, and specify the input and output arguments:

<lib-liquify
    [addresses]="addresses"
    [xAxisType]="'time'"
    [yAxisType]="'linear'"
    [chartType]="'line'"
    [width]="width"
    [height]="height"
    [duration]="10000"
    [suspended]="false"
    [timeBackward]="false"
    [functionSource]="functionSource"
    [dataSetIDs]="dataSetIDs"
    [colors]="colors"
    [specialMessages]="specialMessages"
    (latency)="latencyHandler($event)"
></lib-liquify>

The input arguments of Liquify are the following:

Bar chart Bubble chart Line chart

The latency output argument can be handled by function, that takes the emitted event as an argument. The latency argument returns the time difference between the measurement time of the latest data and the current time of the computer. It can be useful to keep track of how much time it takes to an element of data to get from the server to the client. It can also be useful for debugging purposes. For example, it can reveal, if the server is slow, or sends outdated data.

Performance

The method of testing

I measured the performance of Liquify with the help of the stats.js library. The test project created the given number of charts on the same page. At first it used Chart.js without webworkers, and then it used Liquify with webworkers. Then the charts connected to the test server, which started sending new data points to the charts. The test server ran with two different settings. At first it was set to produce a new data point every 100 millisecond. Then it was set to produce a new data point every 10 milliseconds. After the page was loaded, all the charts connected, and the charts received more than 10 seconds of data, I measured the average frame per second (FPS) of a 10-second time interval.

Results

The following results were measured on a HP Probook 470 G1, that had the following specs:

Number of ChartsData frequencyAverage FPSAverage FPS
without workerwith worker
1100 ms59.960.1
2100 ms41.759.9
3100 ms33.359.8
5100 ms24.159.7
10100 ms14.259.1
20100 ms9.350.4
30100 ms4.750.1
50100 ms2.243.0
100100 ms0.817.7
110 ms14.160.0
510 ms5.159.4
1010 ms3.955.6
2010 ms0.645.0
3010 ms0.438.2
5010 ms0.0935.8
10010 ms0.0115.8

Development

Requirements

The automated tests run in Google Chrome, so it should be installed on your computer.

Before starting the development of Liquify, the source code has to be cloned with a version control system, and its packages have to be installed by issuing the "npm install" command from the library of the workspace. There are 3 projects in the workspace:

Running tests

Build and run the test server before running tests:

cd ./projects/liquify/src/test_server
npm install
npm run build
npm start

You can run automated tests with the following command

ng test liquify

For performance measurements you can use the test-liquify project:

 cd ./projects/test-liquify
 npm install
 ng serve --open

Publishing to npm

ng build liquify --prod
cd dist/liquify
npm init
npm pack
npm login
npm publish --access=public

Architecture

General architecture

Liquify is built as an Angular library, that has two main parts:

Communication

When the liquify component is created it creates a webworker with the given arguments using the offscreen-canvas library, while also sending the buildChart message, so that the worker builds the chart on the provided canvas. When the input arguments change the component sends a message to the worker containing the updated arguments. When the component is destroyed, it sends a close message to the worker.

The chart-worker part connects to the given websocket addresses, processes the received data, draws and updates the chart, handles the messages of the liquify component, and regularly sends back the latency to the liquify component.

<p style="text-align: center;">

The typical messages among a container component, the Liquify component and the worker

The typical messages among a container component, the Liquify component and the worker

</p> The worker handles the following messages:

The worker uses the functions of the FunctionOverrideInterface, which can be overridden.

The FunctionOverrideInterface contains the following functions:

Contributing

We are looking for contributors! Please consider submitting a PR or your ideas for improvement!

Support

If you are interested in support contact hello@enliven.systems

Received support from

This project received funding from the Hungarian Government through EFOP-3.6.3-VEKOP-16-2017-00002: "Integrált kutatói utánpótlás-képzési program az informatika és számítástudomány diszciplináris területein" as well as support from Enliven Systems (https://enliven.systems).