canvasxpress-cli
Version:
Node program to run canvasXpress in the command line
137 lines (103 loc) • 6.33 kB
JavaScript
const menus = {
main: `
canvasxpress [command] <options>
png ................ create a png CanvasXpress file from inline parameters, file or url
svg ................ create a svg CanvasXpress file from inline parameters, file or url
json ............... create a json CanvasXpress file from inline parameters, file or url
canvas ............. run scripts files to test CanvasXpres [internal]
test ............... test package. Creates images and json file in test directory
version ............ show this package version
help ............... show this help. Add command to show correponding help
`,
png: `
--input, -i ........ [optional - required] file or url:
/path/to/local/file.[json|png|csv|txt|html]
http://page/with/file.[json|png|csv|txt|html]
https://page/with/file.[json|png|csv|txt|html]
--output, -o ....... [optional] directory path to save image
{default} './'
--width, -x ........ [optional] integer for image width
{default} 800
--height, -y ....... [optional] integer for image height
{default} 800
--target, -t ....... [optional] string id for CanvasXpress
--data, -d ......... [optional - required] json string with the data for CanvasXpress
--config, -c ....... [optional] json string with configuration for CanvasXpress
--events, -e ....... [optional] json/javascript string with events for CanvasXpress
--timeout, -q ...... [optional] timeout in millisecods to close browser
{default} 500
--browser, -b ...... [optional] boolean to do not run headless and pause for debugging
Examples:
canvasxpress png -i https://canvasxpress.org/examples/bar-3.html
canvasxpress png -i ../src/area.json
canvasxpress png -i ../src/dotplot.png
canvasxpress png -d '{"y":{"vars":["Variable1"],"smps":["Sample1","Sample2","Sample3"],"data":[[33,44,55]]}}' -c '{"graphOrientation":"vertical","title":"Bar Graph Title"}'
canvasxpress png -i ../src/ToothGrowth.csv -c '{"graphType":"Boxplot","asVariableFactors":["dose"],"stringSampleFactors":["dose"],"groupingFactors":["dose"]}'
`,
svg: `
--input, -i ........ [optional - required] file or url:
/path/to/local/file.[json|png|csv|txt|html]
http://page/with/file.[json|png|csv|txt|html]
https://page/with/file.[json|png|csv|txt|html]
--output, -o ....... [optional] directory path to save image
{default} './'
--width, -x ........ [optional] integer for image width
{default} 800
--height, -y ....... [optional] integer for image height
{default} 800
--target, -t ....... [optional] string id for CanvasXpress
--data, -d ......... [optional - required] json string with the data for CanvasXpress
--config, -c ....... [optional] json string with configuration for CanvasXpress
--events, -e ....... [optional] json/javascript string with events for CanvasXpress
--timeout, -q ...... [optional] timeout in millisecods to close browser
{default} 500
--browser, -b ...... [optional] boolean to do not run headless and pause for debugging
Examples:
canvasxpress svg -i https://canvasxpress.org/examples/bar-3.html
canvasxpress svg -i ../src/area.json
canvasxpress svg -i ../src/dotplot.png
canvasxpress svg -d '{"y":{"vars":["Variable1"],"smps":["Sample1","Sample2","Sample3"],"data":[[33,44,55]]}}' -c '{"graphOrientation":"vertical","title":"Bar Graph Title"}'
canvasxpress svg -i ../src/ToothGrowth.csv -c '{"graphType":"Boxplot","asVariableFactors":["dose"],"stringSampleFactors":["dose"],"groupingFactors":["dose"]}'
`,
json: `
--input, -i ........ [optional - required] file or url:
/path/to/local/file.[json|png|csv|txt|html]
http://page/with/file.[json|png|csv|txt|html]
https://page/with/file.[json|png|csv|txt|html]
--output, -o ....... [optional] directory path to save image
{default} './'
--width, -x ........ [optional] integer for image width
{default} 800
--height, -y ....... [optional] integer for image height
{default} 800
--target, -t ....... [optional] string id for CanvasXpress
--data, -d ......... [optional - required] json string with the data for CanvasXpress
--config, -c ....... [optional] json string with configuration for CanvasXpress
--events, -e ....... [optional] json/javascript string with events for CanvasXpress
--timeout, -q ...... [optional] timeout in millisecods to close browser
{default} 500
--browser, -b ...... [optional] boolean to do not run headless and pause for debugging
Examples:
canvasxpress json -i https://canvasxpress.org/examples/bar-3.html
canvasxpress json -i ../src/area.json
canvasxpress json -i ../src/dotplot.png
canvasxpress json -d '{"y":{"vars":["Variable1"],"smps":["Sample1","Sample2","Sample3"],"data":[[33,44,55]]}}' -c '{"graphOrientation":"vertical","title":"Bar Graph Title"}'
canvasxpress json -i ../src/ToothGrowth.csv -c '{"graphType":"Boxplot","asVariableFactors":["dose"],"stringSampleFactors":["dose"],"groupingFactors":["dose"]}'
`,
canvas: `
--input, -i ........ <required> path/to/js/file
--directory, -f .... [optional] directory of CanvasXpres version to check
--graph, -g ........ [optional] graph name
--number, -n ....... [optional] number for the graph
--timeout, -q ...... [optional] timeout in millisecods to close browser
{default} 500
--browser, -b ...... [optional] boolean to do not run headless and pause for debugging
Examples:
canvasxpress canvas -i canvas/scripts/compareImages.js
canvasxpress canvas -i canvas/scripts/compareImages.js -g violin -n 11
`
}
module.exports = (args) => {
const subCmd = args._[0] === 'help' ? args._[1] : args._[0];
console.log(menus[subCmd] || menus.main);
}