Socket
Socket
Sign inDemoInstall

@arction/xydata

Package Overview
Dependencies
0
Maintainers
3
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @arction/xydata

A random data generation library.


Version published
Weekly downloads
399
decreased by-11.33%
Maintainers
3
Install size
507 kB
Created
Weekly downloads
 

Changelog

Source

[1.4.0] - 2020-01-18

Added

  • Water Drop Data Generator.

Readme

Source

XYData generator library

A data generator library.

The generator is used to generate data for LightningChart® JS charting library. https://www.arction.com/

Installation

npm install --save @arction/xydata

Documentation

Online documentation is available at arction.github.io/xydata

Getting started

import { createProgressiveRandomGenerator } from '@arction/xydata'

// create new instance of progressive random generator
createProgressiveRandomGenerator()
    // define that 1000 points should be generated
    .setNumberOfPoints(1000)
    // generate those 1000 points
    .generate()
    // set stream to progress every 250 milliseconds
    .setStreamInterval(250)
    // set stream to output 10 points at a time
    .setStreamBatchSize(10)
    // make the stream infinite
    .setStreamRepeat(true)
    // create a new stream with previously defined stream settings
    .toStream()
    // every time the stream outputs data, run this function on each of the data points
    .forEach(data=>{
        console.log(data)
    })

This creates a basic progressive random generator and uses the Stream API to output the data to console.

Note: You should newer create a new instance of any generator using the new keyword. Generators should only be created with the create... functions.

When calling .generate() on any data generator a new instance of a 'DataHost' is returned. The .generate() function can be called multiple times to get a new set of data with same settings as before but different values each time.

Creating multiple data sets

You can call .generate() function multiple times to get new sets of data.

import { createTraceGenerator } from '@arction/xydata'

const generator = createTraceGenerator()

const dataSet1 = generator.generate()
const dataSet2 = generator.generate()

This would give you two different data sets that have been generated based on same settings but which will have different values.

Changing generator settings

When a data generator is created it has some default settings based on which generator it is. To change any of these settings call .set.... function that will create a new data generator with that setting changed. You can't change multiple settings with a single call or change settings of a generator that has been created previously. A change in settings will always result in a new generator.

import { createTraceGenerator } from '@arction/xydata'

const generator = createTraceGenerator()
   .setNumberOfPoints( 10 )

const derivedGenerator = generator.setNumberOfPoints( 20 )

const dataSet1 = derivedGenerator.generate()

const dataSet2 = generator.generate()

This would create two data sets with different values and settings. dataSet1 would have 20 data points and dataSet2 would have 10.

Data streams

The data sets have possibility to output the data as a stream of data. These streams can be used to alter the data in multiple steps.

import { createTraceGenerator } from '@arction/xydata'

createTraceGenerator()
   .setNumberOfPoints( 10 )
   .generate()
   .toStream()
   .map( value => ( { x:value.x, y: value.y * 2 } ) )
   .forEach( value => console.log(value) )

This code would create a data generator and then stream that data through two functions, map and forEach. The map function alters the data by multiplying the y value by 2 and then streams it to the forEach function. The forEach function would log each invidual point to console.

The settings for the stream are set by the Data Host that is returned from the .generate() function. The stream settings can't be changed after the stream has been generated.

Generators

GeneratorDescription
Delta FunctionGenerate mostly flat data with random spikes.
OHLCGenerate Open, High, Low, Close data.
Parametric FunctionSample user defined X and Y functions for each t step.
Progressive FunctionSample a user defined function with given X step.
Progressive RandomGenerate random progressive data that has progessive X step.
Progressive TraceGenerate random trace data from previous point that has progressive X step.
Sample DataSample given array with specified frequency and user defined step.
TraceGenerate random trace data that can go to any direction on the XY coordinates.
White NoiseGenerate white noise.
Spectrum DataGenerate spectrum data.
Water Drop DataGenerate water drop data.

Development instructions

The project is developed using TypeScript. Build system of the project heavily relies on Node.js. Dependencies are managed with npm, therefore, remember to run npm install before starting of anything else.

The project uses RollUp for creating the distributable library files.

There are several npm scripts, which are used in development process:

NameCommandDescription
testnpm testrun tests and watch
lintnpm run lintrun static analyzer and watch
ci:testnpm run ci:testrun tests once
ci:lintnpm run ci:lintrun static analyzer once
ci:watchnpm run ci:watchrun CI circle and watch
buildnpm run buildbuild the library
build:watchnpm run build:watchbuild the library and watch
docsnpm run docsbuild documentation

Keywords

FAQs

Last updated on 18 Jan 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc