How to use pondjs - 10 common examples

To help you get started, we’ve selected a few pondjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github esnet / react-timeseries-charts / src / website / examples / stockchart / Index.js View on Github external
const name = "AAPL-price";
const columns = ["time", "open", "close", "low", "high"];
const events = aapl.map(item => {
    const timestamp = moment(new Date(item.date));
    const { open, close, low, high } = item;
    return new TimeEvent(timestamp.toDate(), {
        open: +open,
        close: +close,
        low: +low,
        high: +high
    });
});
const collection = new Collection(events);
const sortedCollection = collection.sortByTime();
const series = new TimeSeries({ name, columns, collection: sortedCollection });

//
// Volume
//

const volumeEvents = aapl.map(item => {
    const index = item.date.replace(/\//g, "-");
    const { volume } = item;
    return new IndexedEvent(index, { volume: +volume });
});
const volumeCollection = new Collection(volumeEvents);
const sortedVolumeCollection = volumeCollection.sortByTime();

const seriesVolume = new TimeSeries({
    name: "AAPL-volume",
    utc: false,
github esnet / react-timeseries-charts / src / website / packages / charts / examples / stockchart / Index.js View on Github external
const name = "AAPL-price";
const columns = ["time", "open", "close", "low", "high"];
const events = aapl.map(item => {
    const timestamp = moment(new Date(item.date));
    const { open, close, low, high } = item;
    return new TimeEvent(timestamp.toDate(), {
        open: +open,
        close: +close,
        low: +low,
        high: +high
    });
});
const collection = new Collection(events);
const sortedCollection = collection.sortByTime();
const series = new TimeSeries({ name, columns, collection: sortedCollection });

//
// Volume
//

const volumeEvents = aapl.map(item => {
    const index = item.date.replace(/\//g, "-");
    const { volume } = item;
    return new IndexedEvent(index, { volume: +volume });
});
const volumeCollection = new Collection(volumeEvents);
const sortedVolumeCollection = volumeCollection.sortByTime();

const seriesVolume = new TimeSeries({
    name: "AAPL-volume",
    utc: false,
github esnet / react-timeseries-charts / src / website / packages / charts / examples / nyc / Index.js View on Github external
return new IndexedEvent(
        date,
        {
            temp: [
                +record_min_temp, //eslint-disable-line
                +actual_min_temp, //eslint-disable-line
                +actual_max_temp, //eslint-disable-line
                +record_max_temp //eslint-disable-line
            ]
        },
        false
    );
});

const collection = new Collection(events);
const series = new TimeSeries({ name, collection });

//
// Styles
//

class nyc extends React.Component {
    //eslint-disable-line
    state = {
        timerange: new TimeRange([1425168000000, 1433116800000]),
        selection: null
    };

    handleTimeRangeChange = timerange => {
        this.setState({ timerange });
    };
github esnet / react-timeseries-charts / packages / react-timeseries-charts / src / MultiBrush.tsx View on Github external
: tb;
                newEnd =
                    this.state.brushingInitializationSite === "brush" ||
                    this.state.brushingInitializationSite === "handle-right"
                        ? Math.round(te - endOffsetConstrain)
                        : te;

                // Swap if needed
                if (newBegin > newEnd) {
                    [newBegin, newEnd] = [newEnd, newBegin];
                }
            }

            if (this.props.onTimeRangeChanged) {
                this.props.onTimeRangeChanged(
                    new TimeRange(newBegin, newEnd),
                    this.state.brushIndex
                );
            }
        }
    }
github esnet / react-timeseries-charts / lib / components / MultiBrush.js View on Github external
}

                    newBegin = this.state.brushingInitializationSite === "brush" || this.state.brushingInitializationSite === "handle-left" ? parseInt(tb - startOffsetConstraint, 10) : tb;
                    newEnd = this.state.brushingInitializationSite === "brush" || this.state.brushingInitializationSite === "handle-right" ? parseInt(te - endOffsetConstrain, 10) : te;

                    // Swap if needed
                    if (newBegin > newEnd) {
                        ;
                        var _ref = [newEnd, newBegin];
                        newBegin = _ref[0];
                        newEnd = _ref[1];
                    }
                }

                if (this.props.onTimeRangeChanged) {
                    this.props.onTimeRangeChanged(new _pondjs.TimeRange(newBegin, newEnd), this.state.brushIndex);
                }
            }
        }
github openpowerquality / opq / view / app / imports / ui / components / LiveData / LiveTrendDataDisplay.jsx View on Github external
{graphData.map(set => {
                  const series = new TimeSeries({
                    name: set.label,
                    columns: ['time', 'value'],
                    points: set.data,
                  });
                  const style = { value: { normal: { stroke: this.state.lineColors[set.label], strokeWidth: 2 } } };
                  return ;
                })}
github openpowerquality / opq / view / app / imports / ui / components / BoxTrends.jsx View on Github external
{graphData.map(set => {
                    const series = new TimeSeries({
                      name: set.label,
                      columns: ['time', 'value'],
                      points: set.data,
                    });
                    const style = { value: { normal: { stroke: this.state.lineColors[set.label], strokeWidth: 2 } } };
                    return ;
                  })}
github openpowerquality / opq / view / app / imports / ui / components / EventInspector / EventSummary.jsx View on Github external
constructor(props) {
    super(props);

    const { event } = props;

    const start = event.target_event_start_timestamp_ms;
    const end = event.target_event_end_timestamp_ms;

    this.state = {
      waveforms: [],
      waveformsVisible: {},
      timeRange: new TimeRange(start, end),
      start,
      end,
    };
  }
github esnet / react-timeseries-charts / src / components / EventHandler.js View on Github external
let newBegin = parseInt(this.state.initialPanBegin - timeOffset, 10);
            let newEnd = parseInt(this.state.initialPanEnd - timeOffset, 10);
            const duration = parseInt(this.state.initialPanEnd - this.state.initialPanBegin, 10);

            if (this.props.minTime && newBegin < this.props.minTime.getTime()) {
                newBegin = this.props.minTime.getTime();
                newEnd = newBegin + duration;
            }

            if (this.props.maxTime && newEnd > this.props.maxTime.getTime()) {
                newEnd = this.props.maxTime.getTime();
                newBegin = newEnd - duration;
            }

            const newTimeRange = new TimeRange(newBegin, newEnd);
            if (this.props.onZoom) {
                this.props.onZoom(newTimeRange);
            }
        } else if (this.props.onMouseMove) {
            const mousePosition = this.getOffsetMousePosition(e);
            if (this.props.onMouseMove) {
                this.props.onMouseMove(mousePosition[0], mousePosition[1]);
            }
        }
    }
github esnet / react-timeseries-charts / lib / components / EventHandler.js View on Github external
var newBegin = parseInt(this.state.initialPanBegin - timeOffset, 10);
                var newEnd = parseInt(this.state.initialPanEnd - timeOffset, 10);
                var duration = parseInt(this.state.initialPanEnd - this.state.initialPanBegin, 10);

                if (this.props.minTime && newBegin < this.props.minTime.getTime()) {
                    newBegin = this.props.minTime.getTime();
                    newEnd = newBegin + duration;
                }

                if (this.props.maxTime && newEnd > this.props.maxTime.getTime()) {
                    newEnd = this.props.maxTime.getTime();
                    newBegin = newEnd - duration;
                }

                var newTimeRange = new _pondjs.TimeRange(newBegin, newEnd);
                if (this.props.onZoom) {
                    this.props.onZoom(newTimeRange);
                }
            } else if (this.props.onMouseMove) {
                var mousePosition = this.getOffsetMousePosition(e);
                if (this.props.onMouseMove) {
                    this.props.onMouseMove(mousePosition[0], mousePosition[1]);
                }
            }
        }
    }, {

pondjs

A timeseries library build on top of immutable.js

BSD-3-Clause-LBNL
Latest version published 5 years ago

Package Health Score

42 / 100
Full package analysis

Popular pondjs functions