svg - acfr/snark GitHub Wiki
csv-to-svg: renders csv data into a complete svg document supporting the following shapes:
- points
- circles
- lines
- polygons
output the svg header
csv-to-svg header --width 800px --height 600px --viewbox "0 0 800 600"
output the beginning of a group block
csv-to-svg group_begin --style "stroke:black"
output a coloured polygon
echo -e "10,10\n790,10\n790,590\n10,590" | csv-to-svg polygon --style "fill:#D0EEEE"
output a polyline
echo -e "15,15\n785,15\n785,585\n15,585" | csv-to-svg polyline --style "fill:none" --stroke-width 5
output the close of a group block
csv-to-svg group_end
output 3 blue points
echo -e "100,100\n200,200\n400,300" | csv-to-svg point --point-size 20 --colour blue
output 2 grey lines
echo -e "100,100,200,200\n200,200,400,300" | csv-to-svg line --colour grey --stroke-width 10
output 8 circles coloured using the jet colour map
echo -e "50,500,30,0\n150,500,30,1\n250,500,30,2\n350,500,30,3\n450,500,30,4\n550,500,30,5\n650,500,30,6\n750,500,30,7" | csv-to-svg circle --fields x,y,r,scalar --colour 0:10,jet --stroke-width 4 --style "stroke:crimson"
output the svg footer
csv-to-svg footer
any additional attributes for an svg element may be supplied by using the --attributes option. The options --id, --class, --colour, --stroke-width, --style, --transform are simply convenience options.
csv-to-svg group_begin --attributes 'transform="scale(1,-1)" onmouseover="toggle(evt)"'
css may be linked to externally or added within the svg document
# linked
csv-to-svg header --width 800px --height 600px --viewbox "0 0 800 600" --css path/to/styles.css
# embedded
csv-to-svg style_begin
cat styles.css
csv-to-svg style_end
javascript may be linked to externally or added within the svg document
# linked
csv-to-svg script --file path/to/script.js
# embedded
csv-to-svg script_begin
cat script.js
csv-to-svg script_end
svg has certain default styles for various shapes which you may wish to override. e.g.
- stroke:none for <line>, <polyline>, <polygon>
- fill:black for <polyline>, <polygon>