Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/theodorton/chart-merger
https://github.com/theodorton/chart-merger
Last synced: 20 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/theodorton/chart-merger
- Owner: theodorton
- License: mit
- Created: 2015-12-30T22:45:29.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2015-12-30T23:10:50.000Z (almost 9 years ago)
- Last Synced: 2024-11-10T23:13:26.582Z (about 1 month ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Codeship](https://img.shields.io/codeship/063a09f0-9176-0133-dd26-02f6f3a4e3c7.svg)](https://codeship.com/projects/124625)
# chart-merger
Merge data from different streams of data with `x` and `y` keys.
## Multiply some streams
```javascript
var multiplyStreams = require('chart-merger').multiply;var streamA = [
{ x: 1, y: 3 },
{ x: 2, y: 4 },
{ x: 3, y: 2 }
];
var streamB = [
{ x: 1, y: 2 },
{ x: 2, y: 3 },
{ x: 3, y: 4 },
];var multipliedStreams = multiplyStreams(streamA, streamB);
console.log(multipliedStreams);
// [
// { x: 1, y: 6 },
// { x: 2, y: 12 },
// { x: 3, y: 8 }
// ]
```## Divide some streams
```javascript
var dividedStreams = require('chart-merger').divide;var streamA = [
{ x: 1, y: 3 },
{ x: 2, y: 4 },
{ x: 3, y: 2 }
];
var streamB = [
{ x: 1, y: 2 },
{ x: 2, y: 3 },
{ x: 3, y: 4 },
];var dividedStreams = divideStreams(streamA, streamB);
console.log(dividedStreams);
// [
// { x: 1, y: 1.5 },
// { x: 2, y: 1.33 },
// { x: 3, y: 0.5 }
// ]
```## Sum some streams
```javascript
var sumStreams = require('chart-merger').sum;var streamA = [
{ x: 1, y: 3 },
{ x: 2, y: 4 },
{ x: 3, y: 2 }
];
var streamB = [
{ x: 1, y: 2 },
{ x: 2, y: 3 },
{ x: 3, y: 4 },
];var summedStreams = sumStreams(streamA, streamB);
console.log(summedStreams);
// [
// { x: 1, y: 5 },
// { x: 2, y: 7 },
// { x: 3, y: 6 }
// ]
```## Average some streams
```javascript
var averageStreams = require('chart-merger').average;var streamA = [
{ x: 1, y: 3 },
{ x: 2, y: 4 },
{ x: 3, y: 2 }
];
var streamB = [
{ x: 1, y: 2 },
{ x: 2, y: 3 },
{ x: 3, y: 4 },
];var averagedStreams = averageStreams(streamA, streamB);
console.log(averagedStreams);
// [
// { x: 1, y: 2.5 },
// { x: 2, y: 3.5 },
// { x: 3, y: 3 }
// ]
```