Comparing version 3.0.2 to 3.1.0
@@ -24,2 +24,3 @@ import Chart from 'chart.js/auto' | ||
type: context.chartType, | ||
spanGaps: true, | ||
options: { | ||
@@ -39,5 +40,9 @@ title: { | ||
const { left, right } = context.yAxisAlignment || {} | ||
if (context.disableAnimation) { | ||
chartConfig.options.animation = false | ||
} | ||
if (right && right.length > 0) { | ||
const { left, right } = context.yAxisAlignment | ||
if (right.length > 0) { | ||
chartConfig.options.scales.yRight = { | ||
@@ -62,2 +67,4 @@ position: 'right', | ||
let label = `dataset #${i + 1}` | ||
const dataset = { | ||
@@ -68,12 +75,15 @@ yAxisID: 'yLeft', | ||
borderWidth: 1, | ||
pointRadius: 2, | ||
fill: !context.noFill, | ||
tension: 0.2, | ||
label: `dataset #${i + 1}`, | ||
data: [] | ||
} | ||
if (right && right.includes(i)) { | ||
if (right.includes(i)) { | ||
dataset.yAxisID = 'yRight' | ||
label = `${label} (right)` | ||
} | ||
dataset.label = label | ||
chartData.datasets.push(dataset) | ||
@@ -80,0 +90,0 @@ } |
@@ -44,4 +44,7 @@ const rc = require('rc') | ||
// size of the buffer | ||
windowSize: 50, | ||
windowSize: 200, | ||
// use this flag in increase performance of the chart | ||
disableAnimation: false, | ||
// delay (in ms) before shutting down server once ths input stream ended | ||
@@ -48,0 +51,0 @@ shutdownDelay: 1000, |
26
index.js
@@ -140,6 +140,7 @@ const hcat = require('hcat') | ||
const parsed = state.parseFunction(data) | ||
const sliced = state.dataFunction(parsed) | ||
if (config.fieldCount === 'auto') { | ||
debug('fieldCount is set to "auto"') | ||
const parsed = state.parseFunction(data) | ||
const sliced = state.dataFunction(parsed) | ||
config.fieldCount = sliced.length | ||
@@ -150,13 +151,16 @@ debug('setting fieldCount to "%d", deduced from first row of data', sliced.length) | ||
let yAxisAlignment | ||
if (!config.disableAutoAlignYAxis) { | ||
debug('autoAlignYAxis is enabled') | ||
const parsed = state.parseFunction(data) | ||
const sliced = state.dataFunction(parsed) | ||
const nMags = sliced.map(calcNumberMagnitude) | ||
const magAvg = average(nMags) | ||
debug('values magnitude vector is %o, magnitude average is %s', nMags, magAvg) | ||
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: [] } | ||
} | ||
@@ -172,2 +176,3 @@ | ||
showValueLabels: config.showValueLabels, | ||
disableAnimation: config.disableAnimation, | ||
yAxisAlignment | ||
@@ -311,4 +316,4 @@ } | ||
function splitByAverage(values, avg) { | ||
const left = [] | ||
const right = [] | ||
let left = [] | ||
let right = [] | ||
@@ -320,2 +325,9 @@ for (let i = 0; i < values.length; i++) { | ||
// switch sides if dataset 0 is selected to be on the right side | ||
if (right.includes(0)) { | ||
const temp = right | ||
right = left | ||
left = temp | ||
} | ||
return { right, left } | ||
@@ -322,0 +334,0 @@ } |
{ | ||
"name": "catchart", | ||
"version": "3.0.2", | ||
"version": "3.1.0", | ||
"description": "Pipe something from command line to a browser chart", | ||
@@ -14,3 +14,4 @@ "license": "MIT", | ||
"scripts": { | ||
"build_client": "npx webpack" | ||
"build": "npx webpack", | ||
"build_dev": "env BUILD_MODE=development npx webpack" | ||
}, | ||
@@ -17,0 +18,0 @@ "dependencies": { |
@@ -24,2 +24,3 @@ const program = require('commander') | ||
.option('--noFill', 'Do not fill the area under the chart line with color', config.noFill) | ||
.option('--disableAnimation', 'use this flag in increase performance of the chart', config.disableAnimation) | ||
.option('--usePatterns', 'Fill the area under the chart line with a pattern, this is meant for individuals who suffer from color blindness', config.usePatterns) | ||
@@ -26,0 +27,0 @@ .option('--fieldCount <fieldCount>', 'The number of fields that are piped to catchart in each row, "auto" will try to deduce this value from the first row of data', config.fieldCount) |
module.exports = { | ||
mode: 'production', | ||
mode: process.env.BUILD_MODE || 'production', | ||
entry: './client.js', | ||
@@ -4,0 +4,0 @@ output: { |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
565369
648
0