Giter VIP home page Giter VIP logo

timechart's Introduction

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://cdn.jsdelivr.net/npm/d3-array@3"></script>
    <script src="https://cdn.jsdelivr.net/npm/d3-color@3"></script>
    <script src="https://cdn.jsdelivr.net/npm/d3-format@3"></script>
    <script src="https://cdn.jsdelivr.net/npm/d3-interpolate@3"></script>
    <script src="https://cdn.jsdelivr.net/npm/d3-time@3"></script>
    <script src="https://cdn.jsdelivr.net/npm/d3-time-format@4"></script>
    <script src="https://cdn.jsdelivr.net/npm/d3-scale@4"></script>
    <script src="https://cdn.jsdelivr.net/npm/d3-selection@3"></script>
    <script src="https://cdn.jsdelivr.net/npm/d3-axis@3"></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

Assemble Your Own Chart

New in v1.

TimeChart comes with a modular design. Almost all functions are implemented as plugins. You can pick the plugins you need, so that you don't pay for functions you don't use.

Offical plugins:

  • lineChart: draw the line chart with WebGL, the biggest selling point of this library.
  • d3Axis: intergret with d3-axis to draw the axes.
  • legend: show a legend at top-right.
  • crosshair: show crosshair under the mouse.
  • nearestPoint: highlight the data points in each series that is nearest to the mouse.
  • chartZoom: respond to mouse, keyboard, touch event to zoom/pan the chart. See also the interaction method

As an example, to assemble your own chart with all offical plugins added:

import TimeChart from 'timechart/core';
import { lineChart } from 'timechart/plugins/lineChart';
import { d3Axis } from 'timechart/plugins/d3Axis';
import { legend } from 'timechart/plugins/legend';
import { crosshair } from 'timechart/plugins/crosshair';
import { nearestPoint } from 'timechart/plugins/nearestPoint';
import { TimeChartZoomPlugin } from 'timechart/plugins/chartZoom';

const el = document.getElementById('chart');
const chart = new TimeChart(el, {
    data: {...},
    plugins: {
        lineChart,
        d3Axis,
        legend,
        crosshair,
        nearestPoint,
        zoom: new TimeChartZoomPlugin({...}),
        tooltip: new TimeChartTooltipPlugin({...}),
    }
});

This is almost equivalent to just import TimeChart from 'timechart';, except:

  • The zoom options are now passed directly to TimeChartZoomPlugin.
  • To change the zoom options dynamically, use chart.plugins.zoom.options instead of original chart.options.zoom.

You can also write your own plugins. Read the guide.

For users who use HTML script tag to import TimeChart, use this instead:

<!-- D3 scripts -->
<script src="https://huww98.github.io/TimeChart/dist/timechart.min.js"></script>
<script>
    const el = document.getElementById('chart');
    const chart = new TimeChart.core(el, {
        data: {...},
        plugins: {
            lineChart: TimeChart.plugins.lineChart,
            ...
        }
    });
</script>

Demo

Dynamic Data

To add/remove data dynamically, just change the data array with conventional array prototype methods, then call chart.update().

Some restrictions to the data manipulations:

  • The prototype of data array will be overridden. The length of this array can only be modified with the following overrode array prototype method: push, pop, shift, unshift, splice. The behavior is undefined if the length of the array is changed by any other means.
  • Once you call update, the data will be synchronized to GPU. Then these data cannot be modified, and can only be deleted from both ends. Illegal modification by the overrode splice prototype method will lead to an exception. Other Illegal modifications will lead to undefined behavior.
  • Any data that has not been synchronized to GPU can be modified at will.
    const data = [...];  // Assume it contains 10 data points
    const chart = new TimeChart(el, {
        series: [{ data }],
    });
    data.push({x, y}, {x, y}, {x, y});  // OK
    data.splice(-2, 1);  // OK, data not synced yet
    chart.update();
    
    data.splice(-2, 1);  // RangeError
    data.splice(-2, 2);  // OK, delete the last two data points
    data.pop();          // OK, delete the last data point
    data.splice(0, 2);   // OK, delete the first two data points
    chart.update();      // See data deleted
    
    Array.prototype.pop.call(data)  // Wrong. Only the overridden methods should be used
    data.length = 3;     // Wrong. Changes cannot be tracked
    data[3] = {x, y};    // Wrong unless data[3] is already in array and not synced to GPU
  • 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.
    let startTime = Date.now(); // Set the start time e.g.   1626186924936
    
    let bar = []; // holds the series data
    
    // build the chart
    const chart = new TimeChart(el, {
        series: [{
            name: 'foo',
            data: bar
        }],
        baseTime: startTime,
    });
    
    // update data
    bar.push({x: 1, y: 10}); // 1ms after start time
    bar.push({x: 43, y: 6.04}); // 43ms after start time
    bar.push({x: 89, y: 3.95}); // 89ms after start time
    
    // update chart
    chart.update();

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'

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

    default: color CSS property value at initialization.

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

    default: 10 / 10 / 45 / 20

  • renderPaddingTop / renderPaddingRight / renderPaddingLeft / renderPaddingBottom (number): Like the padding* counterpart, but for WebGL rendering canvas.

    default: 0

  • 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

  • legend (boolean): If true, show the legend.

    default: true

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

  • lineType (number): Take one of the following:

    • LineType.Line: straight lines connecting data points
    • LineType.Step: step function, only horizontal and vertical lines
    • LineType.NativeLine: like LineType.Line, but use native WebGL line drawing capability. This is faster than LineType.Line, but the line width is fixed at 1 pixel on most devices.
    • LineType.NativePoint: draw points at each data point using native WebGL point drawing capability. lineWidth is reused to specify point size in this case.

    default: LineType.Line

  • stepLocation (number): Only effective if lineType === LineType.Step. Where to draw the vertical line. Specified as a ratio of the distance between two adjacent data points. Usually in the range of [0, 1].

    default: 0.5

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

    default: ''

  • color (CSS color specifier or d3-color instance or undefined): line color. If undefined, use global option.

    default: undefined

  • 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,
        }
    }
});

New in v1. If you are using the plugins, pass these options to the TimeChartZoomPlugin plugin.

import TimeChart from 'timechart/core';
import { TimeChartZoomPlugin } from 'timechart/plugins/chartZoom';
const chart = new TimeChart(el, {
    series: [{ data }],
    plugins: {
        zoom: new TimeChartZoomPlugin({x: {autoRange: true}})
    },
});

Then old chart.options.chart is not available. Use chart.plugins.zoom.options instead.

  • panMouseButtons (number): allowed mouth buttons to trigger panning. see MouseEvent.buttons

    default: 1 | 2 | 4

  • touchMinPoints (number): minimum number of touch points needed for the chart to respond to the gesture. Useful if you want to reserve some gesture for other plugins (e.g. selectZoom).

    default: 1

  • autoRange (boolean): Per axis. Determine maxDomain, minDomain automatically.

    default: false

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

    default: Infinity / -Infinity

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

    default: Infinity / 0

Tooltip Options

const chart = new TimeChart({
    ...,
    tooltip: { enabled: true }
})

Or

import TimeChart from 'timechart/core';
import { TimeChartTooltipPlugin } from 'timechart/plugins/tooltip';
const chart = new TimeChart(el, {
    ...,
    plugins: {
        tooltip: new TimeChartTooltipPlugin({ enabled: true, xLabel: 'Time' })
    },
});
  • enabled (boolean): Whether to enable the tooltip on hover

    default: false

  • xLabel (string): Label for the X axis in the tooltip

    default: "X"

  • xFormatter ((number) => string): Function to format the X axis value in the tooltip

    default: x => x.toLocaleString()

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

timechart's People

Contributors

debevv avatar huww98 avatar jumper385 avatar kurkle avatar temaivanoff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

timechart's Issues

Current values at mouse cursor

First of all, great work on this library - it works a treat.

Is there a way to extract the current values of each of the series at the current mouse cursor? Either by query, or an event to subscribe to?

Thanks

Traced don't appear when x is set to a time instead of a counter.

image

Chart Setup

let chart = new TimeChart(chartElement, {
        series: dataholder ,
        xRange: { min: 0, max: 30000 },
        realTime: true,
        zoom: {
            x: {
                autoRange: true,
            },
            y: {
                autoRange: true,
            }
        },
    });

Sample data input

let dataholder = [...{
   name:'category_name',
   data: [{x:1626186924936,y:6.94},{x: 1626186925193, y: 6.29}, {x: 1626186925448, y: 6.3} ...]
}]

Do you know what's going on here? could it be that the points on the line is just too small in the x-axis that WebGL just doesn't render it?

Demo doesn't work on Safari 13.1 on macOS Catalina and iOS 13.1

[Error] Error: Unable to initialize WebGL. Your browser or machine may not support it.
x (timechart.min.js:1:8925)
(anonymous function) (timechart.min.js:1:21941)
main (demo.js:7)
Global Code (demo.js:1)

Safari 13.1 on macOS Catalina

Screen Shot 2020-05-05 at 17 45 27

It's working properly on Chrome 81.

No zoom using script tags

I use HTML script tag to import TimeChart but I am unable to enable the zoom feature.
<script src="https://huww98.github.io/TimeChart/dist/timechart.min.js"></script>

Am I missing something ?

const chart = new TimeChart(el, {
  series: [{ data }],
  plugins: {
    lineChart: TimeChart.plugins.lineChart,
    d3Axis: TimeChart.plugins.d3Axis,
    legend: TimeChart.plugins.legend,
    crosshair: TimeChart.plugins.crosshair,
    nearestPoint: TimeChart.plugins.nearestPoint,
    zoom: new TimeChart.plugins.TimeChartZoomPlugin({x: {autoRange: true}, y: {autoRange: true}}),
    tooltip: TimeChart.plugins.tooltip,
  },
});

I get a wonderful and fast chart with crosshair but no zoom.
Either the doc is incomplete, the implementation is broken or I am dumb ( which may be true in all cases ).
Can you please share an example or fix the code?

Line doesn't render

When using beta 9, lines won't render. This was fixed in fabd3f0, but the fix was never published.
A temporary solution is to change package.json to download the library directly from Git Hub.

	"dependencies": {
-		"timechart": "^1.0.0-beta.9"
+		"timechart": "github:huww98/TimeChart"
	}

WebGL context stays active after removing parent div of chart.

I'm pushing your module to its limits :)

In my usecase i need to reset data from chart. As removing data is impossiible i decided to remove whole parent div (it is generated automaticly when proper function is called). With this method i can remove data but after removing div with chart and appending it again console complains about old WebGL contexts. After few resets amount of old contexts grow to 20 and more (i'm reseting multiple charts at once) and this affect performance. To remove all WebGL contexts i need to restart site.

Other but minor problem is chart.update(). After reseting a chart this function generates error about DOM.

Full errors below:
sz
wbgl

how to export as png/jpg?

the lib is great. One question though, I'd like use this lib to draw a graph and then export as png/jpg, how to achieve that?

Infinity scale x-axis

Hi, how technically difficult is it to make an infinite scale axis-x (timestamp) and generate event on update viewpoint?
there is an idea to make dynamic loading of historical data on left drag

Ability to delete data, alternatively setting a max window size and automatically trim oldest data

As the title says, I need some way of limiting the size of the dataset as the application keeps running. If I speed up the generation of data points, the application gets sluggish over time, presumably as more and more time is spent growing and copying the data buffer to make room for new data.

Is it possible to add support for trimming the beginning of the buffer, either on-demand or by setting a maximum buffer size? Perhaps the library could have an option where it uses a circular (ring) buffer for the data so no copying is needed?

Event on zoom applied

I need to make realtime smooth chart, but points add only ~once a second(depends on server-side), so i can't use built in realtime.

I made interval to solve this problem

setInterval(() => {
    var time = Date.now() - this.startTime;
    this.charts.forEach(c => {
        c.chart.options.xRange = { min: time - 60000, max: time };
        c.chart.update();
    });
}, 1000 / fps);

To use zoom I need to kill this interval and set it when user clicks button.
To do it I need to listen for event called on zoom changed/aplied

Is there any way to listen for such event or another way of solving my problem?

P.S. While exploring the code base I found onScaleUpdated in ChartZoom but I don't know how to reach it

Dynamic update series ?

How to dynamic update series ?

tried variant 1

  componentDidUpdate(prevProps) {
    if (this.props.data.series !== prevProps.data.series && this.chart !== null) {
      this.chart.options.baseTime = this.props.data.baseTime;
      this.chart.options.series = this.props.data.series;
      this.chart.update();
    }
  }

tried variant 2

  componentDidUpdate(prevProps) {
    if (this.props.data.series !== prevProps.data.series && this.chart !== null) {
      this.chart.options.series = [];
      this.chart.update();
      this.chart.options.baseTime = this.props.data.baseTime;
      this.chart.options.series = this.props.data.series;
      this.chart.update();
    }
  }

This examples duplicate series. Should it be completely destroyed ?

Relative time on X-axis

I have an problem with time on axis x. When i set up baseTime to 0 and use performance.now() to generate x values time on chart starts not from 00:00, but from 01:00.
Is there any easy solution for this problem?

Problems with 1.0.0-beta

In my project I'm using TimeChart inside a Svelkte component built with Rollup.
I tried to use the new version of the library with not too much success.

Version 1.0.0-beta1 seems to work on Firefox and Chrome, but not on another Chromium-based browser or on Android:

    Uncaught SyntaxError: Unexpected token '.'

Version 1.0.0-beta2 doesn't even build:

    Error: 'default' is not exported by node_modules\timechart\dist\timechart.min.js

I also tried the example code, which builds, but leads to an error in the browser:

    Uncaught ReferenceError: TimeChart is not defined

Any ideas?

Background grid

It would be really useful if there was an option to draw a background grid with the same lines as the tickmarks in the X/Y axis. The grid should ideally be a bit more dampened than the grid lines, eg by using thinner and/or dashed lines.

Request for new kind of charts

I need to display Series as discrete symbols ( dots, circles, square, etc . ) or bar-charts instead of line-charts.
Where should I please start to implement this new feature ?

tickFormat for x Axis

What do you think about adding timeFormay in options

Example:

const options: ChartOptions = {
  xScaleType: d3.scaleTime,
  timeFormat: "%H:%M:%S",
};

And add this to d3Axis

const xts = chart.options.xScaleType()
  .domain(xs.domain().map(d => d + chart.options.baseTime))
  .range(xs.range());
xAxis.scale(xts).tickFormat(d3.timeFormat(chart.options.timeFormat));

All i need is to format time. Maybe there is easier way to achieve this.

Shadow root remains on dispose

Hi,
First, thanks for this awesome library.

Every now and then I need to clear the chart, so I call dispose and try to re-render by rerunning TimeChart on the existing div element; however, as the shadowroot already exists I get an error.
In the constructor for TimeChart, can we test if the shadowroot property is not null before creating the shadow root and reuse it?

I've been trying to figure out a way of clearing the shadowroot, and while this can be done its challenging with frameworks like React where you don't really control DOM elements directly.
Thanks!

React examples

Any plans to add some react examples for this lib? Would be very usefull :)

Multi series sharing 1 x-axis with TimeChart

Hello, this library is downright impressive and absolutely fantastic!

Is it possible to develop such a UI with TimeChart today? The x-axis is zoomable and slide-able.

If some features are missing, what would it take to develop them? I'll be willing to contribute these features to TimeChart if we can estimate the work. Thanks!

image

Zoom/Pan multiple traces

Is it possible or can you guide me on how I could use TimeChart to create multiple traces which zoom/pan all together when panning / zooming one of the traces.

Great library btw :)

SVG Style adjustment to position:relative

How can I adjust the SVG CSS Shadow Root to position: relative?
Now, the chart takes only half of the parent div..
I am using Vue.
Thank you a lot in advance.

The picture below shows my problem:
image
The picture below shows show how to fix it:
image
The picture below shows the result of the CSS adjustment:
image

How to update series dynamically?

At first I tried to code this:

const el = document.getElementById('chart');
let x = 0, s = 0;
let series = [];
const chart = new TimeChart(el, {
    series: series,
});
let itv = setInterval(() => {
    if ((x++) % 50 == 0) {
        if ((s++) > 3) {
            window.clearInterval(itv)
            return;
        }
        series.push({
            name: "" + s,
            data: []
        });
    }
    for (let _s = 0; _s < s; _s++) {
        series[_s].data.push({
            x: x,
            y: Math.random()
        });
    }
    chart.update();
}, 20);

The chart was not updated.


Then I tried this:

const el = document.getElementById('chart');
let x = 0, s = 0;
let chart = new TimeChart(el, {
    series: [],
});
let series = chart.options.series;
let itv = setInterval(() => {
    if ((x++) % 50 == 0) {
        if ((s++) > 3) {
            window.clearInterval(itv)
            return;
        }
        series.push({
            name: "" + s,
            data: []
        });
    }
    for (let _s = 0; _s < s; _s++) {
        series[_s].data.push({
            x: x,
            y: Math.random()
        });
    }
    chart.update();
}, 20);

The chart refreshes and the data points display normally when hovering, but the lines are not visible.

What's wrong?

Point position artifact on drag

Hi,

    const data = [];

    for (let x = 0; x < 1000000; x++) {
      data.push({x, y: Math.random()});
    }

    const chart = new TimeChart.core(this.root, {
      renderPaddingLeft: 45,
      series: [{ data, name: 'Random', color: 'blue' }],
      plugins: {
        lineChart: TimeChart.plugins.lineChart,
        d3Axis: TimeChart.plugins.d3Axis,
        legend: TimeChart.plugins.legend,
        crosshair: TimeChart.plugins.crosshair,
        nearestPoint: TimeChart.plugins.nearestPoint,
        zoom: new TimeChart.plugins.TimeChartZoomPlugin({
          x: { autoRange: true }, y: { autoRange: true }
        }),
        tooltip: new TimeChart.plugins.TimeChartTooltipPlugin({
          enabled: true, xLabel: 'Time'
        }),
      }
    });
2023-01-31.17.28.16.mov

Strange behavior on Ionic Vue, small chart

When the page is load, the chart display really small, in elements inspector some dimensions have 0, but they change on resize.

I need to resize the windows, calling onResize doesn't do anything. (I'm using the code example)
image

Add optional Formatter function for x-value

When using baseTime and a time scale, the x-axis gets nicely formatted, but the tooltip still shows the raw value for the x-axis. It would be nice if it was possible to pass a formatter function, so that you could see the actual date and time.

Bug `TypeError: e is undefined`

With the published version of e7b086e, as there are no source maps (#56) I can only give this unhelpful error message.

Uncaught TypeError: e is undefined
    plugins index.ts:94
    y index.ts:94
[index.ts:94:77](https://huww98.github.io/src/core/index.ts)
    plugins index.ts:94
    map self-hosted:221
    y index.ts:94

no code examples/tutorials on the README

there needs to be code examples on the README.

should i write up code samples? This stems from the demo code for disposing of the charts - it only shows disposal but it doesn't properly show how to reload it and update it.

can i set up some tutorial pages and make that a 'chapter' on the README?

Chart rendering broken on Mac

The changes in #53 seems to have broken rendering on mac for FF and Chrome.

I tested it with the latest FF 105.0.3 and Chrome 106.0.5249.103 on Mac and it doesn't show up.
It works with Safari 16.0 (17614.1.25.9.10, 17614) on Mac, or FF on windows.

Chrome chrome://gpu report for mac says WebGL2 is enabled.

Graphics Feature Status
Canvas: Hardware accelerated
Canvas out-of-process rasterization: Disabled
Direct Rendering Display Compositor: Disabled
Compositing: Hardware accelerated
Metal: Disabled
Multiple Raster Threads: Enabled
OpenGL: Enabled
Rasterization: Hardware accelerated
Raw Draw: Disabled
Video Decode: Hardware accelerated
Video Encode: Hardware accelerated
Vulkan: Disabled
WebGL: Hardware accelerated
WebGL2: Hardware accelerated
WebGPU: Disabled

I can also see the spinning cube in a webgl 2 test page https://get.webgl.org/webgl2/

Question, render to texture

Hi, I'm studying the code and see the rendering is happening through the texture. Why ? what's the secret? productivity? why not attribute?

Adding vertical lines

Is it possible to add vertical lines to the chart on click? If not, how difficult would it be to add this functionality?

Tooltips

Hi, does the library support hover tooltips? I'm asking because I read this line in the readme:

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

but I don't see any tooltip on mouse hover. Is there any non-documented option to enable them maybe?

Thanks in advance

scatter/event plot

Dear,

Sorry for the context I am a total newbie in this language. I am taking back a project from a colleague using this to display two signals in our web app (thanks for your work here).

I would like to display specific events on top of the chart with specific markers. A scatter plot would do it equivalently I think.
Do you have a way to display a scatter plot ? Or could give me some hints on where to look for it ?

Also, being able to add a title to the figure would be nice as well.

Thanks for your help.

Not appear line when series data shifted (npm version)

Hi, Thanks for works.

This is happened while using the 0.5.2 version of timechart in angular.

Untitled.mp4

vedio left side code(in vanila js - timechart.min.js)
스크린샷 2022-04-28 오후 2 54 50

vedio right side code(in angular - npm install timechart)
스크린샷 2022-04-28 오후 2 54 56

Is it that npm timechart version has not been updated?

Prepending data

Is it possible or can you guide me on how I could prepend data to a trace instead of appending it?

Any help is greatly appreciated :)

Zoom & Pause

Hi @huww98

As per my current requirements,
I need Zoom In & Zoom Out manually by clicking on the buttons (Right now it's possible thorough Mouse Scroll & Mouse Pan multi finger gesture)

I also noticed then when we zoom in the x axis, the live data stopped showing. (it stopped showing new data, after zoom In)

Your Stop is working, but when we required Resume/Start, that feature is not exist.

Let me know if that's possible.

Thank you for making amazing library.

How can I hide series depending on the Zoom scale ?

I plot 10 series but I want to hide some ( but not all ) depending on the zoom scale.
I have tried using dispose() then instantiate a new chart but the chart is not displayed even if I can find the right series in chart._options
Maybe there is a better alternative than dispose then redraw.
What would you please suggest ?
Thank you very much for TimeChart.js

Alternative Zoom mode (click+drag selection)

It would be nice to have an alternative zoom mode, i.e., creating a selection by clicking and dragging to create a time interval. Similar to what you can do in Grafana. With the current two finger zoom it can be very tedious to zoom into a small interval. As the current drag is already doing something else, maybe this can be done with Shift+Drag or something else.

When Date.now() is used as x value line chart doesn't show

Loving your work, but I can't get Date.now() passed as x value to work.

Smaller numbers works fine, performance.now() also works, but with Date.now() there is no line.

What is interesting is that this code does not work:

var time: number = Date.now();
for (var i: number = 0; i < 10000; i++) {
  chart_data.push({ x: time + i, y: i });
}

But this one renders properly:

var time: number = Date.now()\10000;
for (var i: number = 0; i < 10000; i++) {
  chart_data.push({ x: time*i, y: i });
}

OffscreenCanvas Support

Hi, Thanks for works.
There is no documentation or demo on OffscreenCanvas option. Does the library support OffscreenCanvas?

Regards,
Ibrahim

xRange/yRange: 'auto' issue

Simple problem: auto range considers invisible series.

For example:

  • seriesA Y range = {0, 100}
  • seriesB Y range = {5, 6}

Even if I toggle seriesA visibility to false, range will be calculated based on all series

Expected:
next
Reality:
prev

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.