Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

catchart

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

catchart - npm Package Compare versions

Comparing version 3.1.2 to 3.2.0

4

config.js

@@ -32,2 +32,6 @@ const rc = require('rc')

// A json array expression, tells catchart which series Y values are aligned on the LEFT/RIGHT Y axis. Overrides auto align.
yLeft: undefined,
yRight: undefined,
// by default catchart will try to "guess" which side to align the Y values of a data series if there's more than one

@@ -34,0 +38,0 @@ disableAutoAlignYAxis: false,

@@ -150,4 +150,5 @@ const hcat = require('hcat')

let yAxisAlignment
if (!config.disableAutoAlignYAxis) {
let alignmentFromEnv = getAlignmentFromConfig(config)
if (!config.disableAutoAlignYAxis && !alignmentFromEnv) {
debug('autoAlignYAxis is enabled')

@@ -160,8 +161,9 @@

yAxisAlignment = splitByAverage(nMags, magAvg)
debug(`data series aligment is: left %o, right %o`, yAxisAlignment.left, yAxisAlignment.right)
} else {
// map all to left otherwise
yAxisAlignment = { left: sliced.map((v, i) => i), right: [] }
yAxisAlignment = alignmentFromEnv || { left: sliced.map((v, i) => i), right: [] }
}
debug(`data series aligment is: left %o, right %o`, yAxisAlignment.left, yAxisAlignment.right)
const clientContext = {

@@ -366,2 +368,31 @@ chartType: config.chartType,

`
}
}
function getAlignmentFromConfig(cfg) {
let left = safeJSONParse(cfg.yLeft)
let right = safeJSONParse(cfg.yRight)
debug(123123123, left, right)
if (!Array.isArray(left)) {
left = []
}
if (!Array.isArray(right)) {
right = []
}
if (left.length === 0 && right.length === 0) {
return
}
return { left, right }
}
function safeJSONParse(str) {
try {
return JSON.parse(str)
} catch (e) {
if (!(e instanceof SyntaxError)) {
throw e
}
}
}

2

package.json
{
"name": "catchart",
"version": "3.1.2",
"version": "3.2.0",
"description": "Pipe something from command line to a browser chart",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -21,2 +21,4 @@ const program = require('commander')

value in each row will be considered the label`, config.labelSource)
.option('--yLeft', 'A json array expression, tells catchart which series Y values are aligned on the LEFT Y axis. Overrides auto align.', config.yLeft)
.option('--yRight', 'A json array expression, tells catchart which series Y values are aligned on the RIGHT Y axis. Overrides auto align.', config.yRight)
.option('--disableAutoAlignYAxis', 'by default catcahrt will try to automatically align data sets to the left or right based on their values', config.disableAutoAlignYAxis)

@@ -23,0 +25,0 @@ .option('--showValueLabels', 'show labels on values in the chart', config.showValueLabels)

@@ -58,2 +58,12 @@ # catchart

## features
- support most of chart.js chart types
- support json and simple array input formats
- specify configuration through environment variables, files or cli parameters (see rc module and commander module for further information)
- fill the area until the line, also supports patterns.
- restrict the amount of displayed data using --windowSize. Catchart will dump data that falls outside of the window.
- align data to a left or right Y axis using configuration or automatically:
* `--yLeft=[0, 1, 2]` and `--yRight=[3, 4]` will make series 0, 1 and 2 be on the left and 3,4 on the right. When using this config, all the series indices must be specified.
* Auto align Y axis: a somewhat feeble/experimental attempt at grouping series with similar magnitude on the left and right Y axes. `--disableAutoAlignYAxis` to disable
## dev

@@ -63,2 +73,3 @@ - clone this repo

- npm run build_client; node emitter `<csv | singlecsv | json>` | node catchart`
- also `node emitter.js csv | node catchart.js --yLeft=[0,1] --yRight=[2,3]`
- send a PR :)

@@ -65,0 +76,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc