Comparing version 1.0.2 to 1.0.3
# chartio help | ||
chartio expects csv data with the following specification. | ||
- `;` as field delimiter | ||
- `enter` as row delimiter | ||
- The first line contains the data header column titles | ||
- `;` as field delimiter | ||
- `enter` as row delimiter | ||
- The first line contains the data header column titles | ||
## Example data | ||
```bash | ||
@@ -18,3 +20,2 @@ Serial Data;Signal;AVG Filter;STD Filter | ||
## Syntax | ||
@@ -27,13 +28,15 @@ | ||
## Parameters | ||
## Parameters | ||
|Name|Description| | ||
|----|-----------| | ||
|--ouputfile |Optional ouput filename of the chart PNG image (defaults to chart.png)| | ||
|--inputfile |Optional input filename of csv data| | ||
|--width |Optional Width of image.| | ||
|--height |Optional Height of image.| | ||
|--delimiter |Optional data field delimiter defaults to `;`| | ||
|--template |Optional full path to custom HTML template.| | ||
|help, --help, /? |Show this help.| | ||
|version, --version, -v|Show version.| | ||
| Name | Description | | ||
| ---------------------- | ------------------------------------------------------------------------------------------------- | | ||
| --ouputfile | Optional ouput filename of the chart PNG image (defaults to chart.png) | | ||
| --inputfile | Optional input filename of csv data | | ||
| --width | Optional Width of image. | | ||
| --height | Optional Height of image. | | ||
| --delimiter | Optional data field delimiter defaults to `;` | | ||
| --template | Optional full path to custom HTML template. | | ||
| --headless | Optional `true` or `false`. This parm is for debug purposes to fix bugs in your custom templates. | | ||
| --slomo | Optional defaults 800ms to slow down rendering. Use this in combination with `--headless false`. | | ||
| help, --help, /? | Show this help. | | ||
| version, --version, -v | Show version. | |
@@ -7,3 +7,2 @@ #!/usr/bin/env node | ||
var fs = new require("fs"); | ||
var Chart = require("./plot.js"); | ||
var cli = new Cli({ | ||
@@ -16,2 +15,3 @@ silent: false, | ||
var Chart = require("./plot.js"); | ||
var chart = new Chart(cli.argv.template); | ||
@@ -38,7 +38,17 @@ | ||
var headlessMode = cli.argv.headless | ||
if (headlessMode !== undefined) { | ||
if (cli.argv.headless.toString().toLowerCase() !== "true" && cli.argv.headless.toString().toLowerCase() !== "false") { | ||
throw new Error('Invalid parameter value for `headless`. Value should be `true`or `false`.') | ||
} | ||
headlessMode = cli.argv.headless.toString().toLowerCase() === "true" | ||
} else { | ||
headlessMode = true | ||
} | ||
var pageParms = { | ||
headlessSettings: { | ||
//headless: false, | ||
//slowMo: 800 // slow down by 250ms | ||
headless: headlessMode, | ||
slowMo: headlessMode ? 0 : parseInt(cli.argv.slomo, 10) || 800 // slow down by 800ms | ||
}, | ||
@@ -51,3 +61,3 @@ title: cli.argv.title || new Date().toISOString(), | ||
}, | ||
outputFilename: cli.argv.outputfile, | ||
outputFilename: cli.resolvePath(cli.argv.outputfile || 'chart.png'), | ||
delimiter: cli.argv.delimiter, | ||
@@ -58,13 +68,21 @@ // rawData: 'SASerial Data;Signal;AVG Filter;STD Filter\n1;0;0;0\n1;0;0;0\n1.1;0;0;0\n1;0;0;0\n0.9;0;1.41756756756757;0.902901944349606\n1;0;0;0\n1;1;0.2;0.4\n1.1;0;0.4;0.489897948556636\n1;0;0.62;0.507543101617981\n0.9;0;0.82;0.41182520563948\n1;0;1;0.0632455532033676\n1.1;0;1;0.0632455532033676\n1;0;1.02;0.0748331477354789\n1;0;1;0.0632455532033676\n0.9;0;1;0.0632455532033676\n1;0;1;0.0632455532033676\n1;0;1;0.0632455532033676\n1.1;0;0.98;0.04\n1;0;1;0.0632455532033676\n1;0;1;0.0632455532033676\n1;0;1.02;0.04\n1;0;1.02;0.04\n1.1;0;1.02;0.04\n0.9;0;1.02;0.04\n1;0;1;0.0632455532033676\n1.1;0;1;0.0632455532033676\n1;0;1.02;0.0748331477354789\n1;0;1.02;0.0748331477354789\n0.9;0;1;0.0632455532033676\n1;0;1;0.0632455532033676\n1.1;0;1;0.0632455532033676\n1;0;1;0.0632455532033676\n1;0;1;0.0632455532033676\n1.1;0;1;0.0632455532033676\n1;0;1.04;0.0489897948556636\n0.8;-1;1.04;0.0489897948556636\n0.9;0;1.008;0.0515363949069005\n1;0;0.988;0.0676461381011511\n1.2;0;0.988;0.0676461381011511\n0.9;0;1.008;0.103227903204512\n1;0;0.988;0.112142766151009\n1;0;1;0.109544511501033\n1.1;0;1.02;0.0979795897113271\n1.2;0;1.04;0.101980390271856\n1;0;1.04;0.101980390271856\n1.5;1;1.06;0.08\n1;0;1.09;0.08\n3;1;1.09;0.08\n2;1;1.19;0.22\n5;1;1.294;0.306176419732154\n3;1;1.6348;0.598274318352376\n2;0;1.96336;0.686416111699019\n1;0;2.16336;0.49580548443921\n1;0;2.04336;0.662291082832919\n1;0;1.89936;0.78402879947104\n0.9;0;1.55856;0.72858568089141\n1;0;1.18;0.41182520563948\n1;0;0.98;0.04\n3;1;0.98;0.04\n2.6;1;1.1;0.25298221281347\n4;1;1.28;0.396988664825584\n3;1;1.606;0.5787434664858\n3.2;0;1.9402;0.613719936127221\n2;0;2.3802;0.56892544327003\n1;0;2.4602;0.473755379916682\n1;0;2.2802;0.745463721451286\n0.8;0;1.9742;0.881693007798066\n4;0;1.6;0.903327183250897\n4;0;1.76;1.19599331101808\n2;0;2.16;1.50412765415705\n2.5;0;2.36;1.39942845476287\n1;0;2.66;1.22572427568356\n1;0;2.7;1.16619037896906\n' | ||
if (cli.argv.inputfile) { | ||
console.log('start rendering based on file...') | ||
var fn = cli.resolvePath(cli.argv.inputfile); | ||
console.log("processing " + fn + "...") | ||
pageParms.rawData = fs.readFileSync(fn).toString() | ||
chart.plot(pageParms) | ||
chart.plot(pageParms, function () { | ||
console.log('done') | ||
}) | ||
} else { | ||
onStdIn(function (stdin) { | ||
if (stdin && stdin.trim() !== '') { | ||
console.log('start rendering based on stdin') | ||
pageParms.rawData = stdin | ||
chart.plot(pageParms) | ||
chart.plot(pageParms, function () { | ||
console.log('done') | ||
}) | ||
} else { | ||
process.exit(0) | ||
} | ||
}); | ||
} |
@@ -12,3 +12,2 @@ 'use strict'; | ||
Chart.prototype.plot = function (pageParms, done) { | ||
(async(self, pageParms, done) => { | ||
@@ -28,2 +27,3 @@ var self = this | ||
}); | ||
console.log('rendering image using \'' + self.defaultChartHTMLTemplate + '\'...') | ||
await page.goto('file:///' + self.defaultChartHTMLTemplate); | ||
@@ -41,2 +41,3 @@ await page.addScriptTag({ | ||
await browser.close() | ||
console.log('image rendered to ' + pageParms.outputFilename) | ||
if (done) { | ||
@@ -46,5 +47,4 @@ done() | ||
})(this, pageParms, done); | ||
// body... | ||
} | ||
module.exports = Chart |
{ | ||
"name": "chartio", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Plot serial chart data to an image and save it to filesystem from shell.", | ||
@@ -24,7 +24,5 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"marked": "^0.3.6", | ||
"marked-terminal": "^2.0.0", | ||
"n-cli": "^1.2.15", | ||
"n-cli": "^1.2.16", | ||
"puppeteer": "^0.12.0" | ||
} | ||
} |
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
2354327
2
9145
- Removedmarked@^0.3.6
- Removedmarked-terminal@^2.0.0
- Removedansi-regex@2.1.1(transitive)
- Removedansi-styles@2.2.1(transitive)
- Removedansicolors@0.2.1(transitive)
- Removedcardinal@1.0.0(transitive)
- Removedchalk@1.1.3(transitive)
- Removedcli-table@0.3.11(transitive)
- Removedcolors@1.0.3(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedesprima@3.0.0(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedlodash.assign@4.2.0(transitive)
- Removedmarked@0.3.19(transitive)
- Removedmarked-terminal@2.0.0(transitive)
- Removednode-emoji@1.11.0(transitive)
- Removedredeyed@1.0.1(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedsupports-color@2.0.0(transitive)
Updatedn-cli@^1.2.16