GithubHelp home page GithubHelp logo

sveinn-steinarsson / flot-downsample Goto Github PK

View Code? Open in Web Editor NEW
271.0 17.0 38.0 176 KB

Downsample plugin for Flot charts.

CSS 15.06% HTML 26.52% JavaScript 58.43%
downsample time-series timeseries algorithm javascript flot

flot-downsample's People

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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flot-downsample's Issues

Small Optimization

A small suggestion: the calculation of the triangular area could be changed to a calculation of a rectangular area and thus get rid of the *.5 ( or division by 2), since the size of the area is only used to compare...

Ported to R

Hello! I just wanted to let you know that I've written an implementation in R, in case it is of interest. I don't know JavaScript, so this was mostly based on the description in your thesis, but it appears to be working correctly.

I don't suppose you have a test data set for validating alternate implementations?

Volatility in results

The resulting path seems to jump a little bit around when changing threshold, probably because different points get picked each time.

Here is a slightly different take on the same, using Visvalingam’s algorithm. Here there is less volatility, as the points are in specific order based on information content. Not sure if it's correctly implemented or even whether it's better or worse:

http://bl.ocks.org/ZJONSSON/raw/5581551/
code: https://gist.github.com/ZJONSSON/5581551#file-simplify-js

It will be better to have Downsample disabled by default

I think it will be better to have Downsample disabled by default (threshold set to 0 in initial options), to not affect all plots (especially pie charts), which might be created without any knowledge about this plugin.
IMHO it's better if developer intentionally turns on this functionality on specified charts.

iPhone 6 Issue

Thanks for the great plugin! I'm receiving a strange error only on iPhone 6 devices, the same exact code works perfectly on earlier iPhone devices: TypeError: undefined is not an object (evaluating 'data[ range_offs ][ 1 ]')on line 82. I can provide more detailed information if needed. The logic is a bit confusing, but it doesn't seem like your code is using anything 'special' that would change between iPhone versions. Maybe their implementation of floor changed?

Null/Nan handling

Many plotting libraries support having a null with a timestamp to break a trend. (Leaving a gap, preventing interpolation)
Imagine you have time series data and its divided in three buckets:

values         dates
1              2021-11...
2              2021-11...
5              2021-11...

2              2021-11...
null           2021-11...
5              2021-11...

6              2021-11...
2              2021-11...
7              2021-11...

I can think of two ways on how to handle this but I'm not sure what would be ideal:

  1. Since the algorithm will always choose a time-value pair from the dataset (Because C is either calculated the next pass as B or it's the last datapoint), as long as there as there are no duplicate data points (two values on the same date/timestamp) it's safe to remove the nulls first, run LTTB and then add them back in.
  2. The other option would be to split the dataset into two and apply lttb to each of them, then at the end add the resulting datasets together and the nulls, this would keep the first and last data points before/after trend breaks (the nulls)

Any thoughts?

Error on IE8 (quirks mode)

In some situations (in IE) flot-downsample will show errors at this line.

avg_x += data[ avg_range_start ][ 0 ] * 1;

The error is: Unable to get property '0' of undefined or null reference.

I have tested on Firefox and Chrome, but errors appear only on IE.

Any thoughts?

There is no support for nulls in data array

Nice plugin, but has one disadvantage. According to Flot documentation, null value passed as one of points means that surrounding points should not be connected. Downsample seems to do not support it (error in javascript).

Question: Performance metrics

Hi, this looks interesting. How you already got any metrics to show Flot's performance is enhanced using this plugin? It's pretty fast already.

Or are there other reasons for using it? E.g. better aesthetics or other?

I'd look into it more but am travelling with work, plus you might have this information already.

Thanks, Adrian

Assumes data is already ordered correctly

Not a major bug but figured I should at least document incase anyone else encounters. If the data array is not already ordered flot by itself still plots the line chart correctly. The plugin however does some crazy things with my data if the order of the data does not match the x axis order.

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.