All Projects → huww98 → Timechart

huww98 / Timechart

Licence: mit
An chart library specialized for large-scale time-series data, built on WebGL.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Timechart

Layaair
LayaAir is an open-source 2D/3D engine. LayaAir Engine is designed for high performance games.LayaAir support TypeScript and JavaScript、ActionScript 3.0 programming language.Can develop once, publish for multi platform.
Stars: ✭ 791 (+430.87%)
Mutual labels:  webgl, webgl2
React Ape
🦍• [Work in Progress] React Renderer to build UI interfaces using canvas/WebGL
Stars: ✭ 1,183 (+693.96%)
Mutual labels:  webgl, webgl2
Webgl2 Fundamentals
WebGL 2 lessons starting from the basics
Stars: ✭ 912 (+512.08%)
Mutual labels:  webgl, webgl2
Website
Main babylon.js website
Stars: ✭ 145 (-2.68%)
Mutual labels:  webgl, webgl2
Hedgehog Lab
Run, compile and execute JavaScript for Scientific Computing and Data Visualization TOTALLY TOTALLY TOTALLY in your BROWSER! An open source scientific computing environment for JavaScript TOTALLY in your browser, matrix operations with GPU acceleration, TeX support, data visualization and symbolic computation.
Stars: ✭ 1,797 (+1106.04%)
Mutual labels:  webgl, webgl2
Picogl.js
A minimal WebGL 2 rendering library
Stars: ✭ 671 (+350.34%)
Mutual labels:  webgl, webgl2
Sunset Cyberspace
🎮👾Retro-runner Game made in Expo, Three.js, OpenGL, WebGL, Tween. 🕹
Stars: ✭ 54 (-63.76%)
Mutual labels:  webgl, webgl2
Spritejs
A cross platform high-performance graphics system.
Stars: ✭ 4,712 (+3062.42%)
Mutual labels:  webgl, webgl2
Medium
Progressive WebGL toolkit for art.
Stars: ✭ 90 (-39.6%)
Mutual labels:  webgl, webgl2
Threejs Starter
Stars: ✭ 89 (-40.27%)
Mutual labels:  webgl, webgl2
Spector.js
Explore and Troubleshoot your WebGL scenes with ease.
Stars: ✭ 599 (+302.01%)
Mutual labels:  webgl, webgl2
Engine
Oasis Engine is a web-first and mobile-first high-performance real-time development platform.
Stars: ✭ 2,202 (+1377.85%)
Mutual labels:  webgl, webgl2
Butterchurn
Butterchurn is a WebGL implementation of the Milkdrop Visualizer
Stars: ✭ 592 (+297.32%)
Mutual labels:  webgl, webgl2
Engine
Fast and lightweight JavaScript game engine built on WebGL and glTF
Stars: ✭ 6,890 (+4524.16%)
Mutual labels:  webgl, webgl2
Glchaos.p
3D GPUs Strange Attractors and Hypercomplex Fractals explorer - up to 256 Million particles in RealTime
Stars: ✭ 590 (+295.97%)
Mutual labels:  webgl, webgl2
Curtainsjs
curtains.js is a lightweight vanilla WebGL javascript library that turns HTML DOM elements into interactive textured planes.
Stars: ✭ 1,039 (+597.32%)
Mutual labels:  webgl, webgl2
Ray Tracing Renderer
[UNMAINTAINED] Real-time path tracing on the web with three.js
Stars: ✭ 444 (+197.99%)
Mutual labels:  webgl, webgl2
Detect Gpu
Classifies GPUs based on their 3D rendering benchmark score allowing the developer to provide sensible default settings for graphically intensive applications.
Stars: ✭ 460 (+208.72%)
Mutual labels:  webgl, webgl2
Helixjs
A Javascript 3D game engine.
Stars: ✭ 84 (-43.62%)
Mutual labels:  webgl, webgl2
Sketch
Explorations on cross-hatching, engraving, and similar non-photorealistic rendering.
Stars: ✭ 136 (-8.72%)
Mutual labels:  webgl, webgl2

Time Chart

npm version GitHub Pages

An chart library specialized for large-scale time-series data, built on WebGL.

Flexable. Realtime monitor. High performance interaction.

Live Demo

Performance

Taking advantage of the newest WebGL technology, we can directly talk to GPU, pushing the limit of the performance of rendering chart in browser. This library can display almost unlimited data points, and handle user interactions (pan / zoom) at 60 fps.

We compare the performance of this library and some other popular libraries. See Performance

Usage

Installation

  • Use npm

    npm install timechart
    
  • Use HTML script tag

    This library depends on D3 to draw axes and something else. It needs to be included seperatedly.

    <script src="https://d3js.org/d3-array.v2.min.js"></script>
    <script src="https://d3js.org/d3-color.v2.min.js"></script>
    <script src="https://d3js.org/d3-format.v2.min.js"></script>
    <script src="https://d3js.org/d3-interpolate.v2.min.js"></script>
    <script src="https://d3js.org/d3-time.v2.min.js"></script>
    <script src="https://d3js.org/d3-time-format.v3.min.js"></script>
    <script src="https://d3js.org/d3-scale.v3.min.js"></script>
    <script src="https://d3js.org/d3-selection.v2.min.js"></script>
    <script src="https://d3js.org/d3-axis.v2.min.js"></script>
    <script src="https://huww98.github.io/TimeChart/dist/timechart.min.js"></script>
    

Basic

Display a basic line chart with axes.

<div id="chart" style="width: 100%; height: 640px;"></div>
const el = document.getElementById('chart');
const data = [];
for (let x = 0; x < 100; x++) {
    data.push({x, y: Math.random()});
}
const chart = new TimeChart(el, {
    series: [{ data }],
});

Live

Data

To add data dynamically, just push new data points to the data array, then call chart.update().

Some restrictions to the provided data:

  • You can only add new data. Once you call update, you can not edit or delete existing data.
  • The x value of each data point must be monotonically increasing.
  • Due to the limitation of single-precision floating-point numbers, if the absolute value of x is large (e.g. Date.now()), you may need to use baseTime option (see below) to make the chart render properly.

Global Options

Specify these options in top level option object. e.g. to specify lineWidth:

const chart = new TimeChart(el, {
    series: [{ data }],
    lineWidth: 10,
});
  • lineWidth (number): default line width for every data series.

    default: 1

  • backgroundColor (CSS color specifier or d3-color instance)

    default: 'transparent'

  • paddingTop / paddingRight / paddingLeft / paddingBottom (number): Padding to add to chart area in CSS pixel. Also reverse space for axes.

    default: 10 / 10 / 45 / 20

  • xRange / yRange ({min: number, max: number} or 'auto'): The range of x / y axes. Also use this to control pan / zoom programmatically. Specify 'auto' to calculate these range from data automatically. Data points outside these range will be drawn in padding area, to display as much data as possible to user.

    default: 'auto'

  • realTime (boolean): If true, move xRange to newest data point at every frame.

    default: false

  • baseTime (number): Milliseconds since new Date(0). Every x in data are relative to this. Set this option and keep the absolute value of x small for higher floating point precision.

    default: 0

  • xScaleType (() => Scale): A factory method that returns an object conforming d3-scale interface. Can be used to customize the appearance of x-axis. scaleTime, scaleUtc, scaleLinear from d3-scale are known to work.

    default: d3.scaleTime

  • debugWebGL (boolean): If true, detect any error in WebGL calls. Most WebGL calls are asynchronized, and detecting error will force synchronization, which may slows down the program. Mainly used in development of this library.

    default: false

Series Options

Specify these options in series option object. e.g. to specify lineWidth:

const chart = new TimeChart(el, {
    series: [{
        data,
        lineWidth: 10,
    }],
});
  • data ({x: number, y: number}[]): Array of data points to be drawn. x is the time elapsed in millisecond since baseTime

  • lineWidth (number or undefined): If undefined, use global option.

    default: undefined

  • name (string): The name of the series. Will be shown in legend and tooltips.

    default: ''

  • color (CSS color specifier or d3-color instance): line color

    default: color CSS property value at initialization.

  • visible (boolean): Whether this series is visible

    default: true

Zoom Options

These options enable the builtin touch / mouse / trackpad interaction support. The x, y axis can be enabled separately.

Specify these options in zoom option object. e.g. to specify autoRange:

const chart = new TimeChart(el, {
    series: [{ data }],
    zoom: {
        x: {
            autoRange: true,
        },
        y: {
            autoRange: true,
        }
    }
});
  • autoRange (boolean): Determine maxDomain, minDomain automatically.

    default: false

  • maxDomain / minDomain (number): The limit of xRange / yRange

    default: Infinity / -Infinity

  • maxDomainExtent / minDomainExtent (number): The limit of max - min in xRange / yRange

    default: Infinity / 0

Methods

  • chart.update(): Request update after some options have been changed. You can call this as many times as needed. The actual update will only happen once per frame.

  • chart.dispose(): Dispose all the resources used by this chart instance. Note: We use shadow root to protect the chart from unintended style conflict. However, there is no easy way to remove the shadow root after dispose. But you can reuse the same HTML element to create another TimeChart. Example

  • chart.onResize(): Calculate size after layout changes. This method is automatically called when window size changed. However, if there are some layout changes that TimeChart is unaware of, you need to call this method manually.

Interaction

With touch screen:

  • 1 finger to pan
  • 2 or more finger to pan and zoom

With mouse:

  • Left button drag to pan
  • wheel scroll translate X axis
  • Alt + wheel scroll to translate Y axis
  • Ctrl + wheel scroll to zoom X axis
  • Ctrl + Alt + wheel scroll to zoom Y axis
  • Hold Shift key to speed up translate or zoom 5 times

With trackpad:

  • Pan X or Y direction to translate X axis
  • Alt + Pan X/Y direction to translate X/Y axis
  • Pinch to zoom X axis
  • Alt + pinch to zoom Y axis
  • Hold Shift key to speed up translate or zoom 5 times

Styling

The chart is in a shadow root so that most CSS in the main document can not affect it. But we do provide some styling interface.

For example, we can support dark theme easily:

<div id="chart" class="dark-theme"></div>
.dark-theme {
    color: white;
    background: black;
    --background-overlay: black;
}

Live

The --background-overlay CSS property is used in some non-transparent element on top on the chart.

The background of the chart is transparent by default. So it's easy to change the background by setting the background of parent element.

All foreground elements will change color to match the color CSS property. However, chart is drawn in canvas and cannot respond to CSS property changes. You need to change the color manually if you want to change the color after initialiation.

Development

  • run npm install to install dependencies
  • run npm start to automatically build changes
  • run npm run demo then open http://127.0.0.1:8080/demo/index.html to test changes
  • run npm test to run automatic tests
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].