1818
1919var fs = require ( 'fs' ) ;
2020const jsdom = require ( 'jsdom' ) ;
21- const { v4 : uuidv4 } = require ( 'uuid' ) ;
2221
2322/* Renders JSON data for a Plotly.js plot into a SVG file.
2423
2524 Parameters:
2625 jsonData - (string) the JSON data required by Plotly.js
27- filename - (string) desired output file name for the SVG file
28- width - (number) width of the SVG file in pixels
29- height - (number) height of the SVG file in pixels
26+ width - (number) width of the SVG image in pixels
27+ height - (number) height of the SVG image in pixels
3028
3129 Returns:
3230 object that contains two members:
@@ -35,24 +33,13 @@ const { v4: uuidv4 } = require('uuid');
3533 failure - (string) reason for render failure; only present after failed
3634 rendering, may be cryptic and is not necessarily human-friendly
3735*/
38- exports . render = async function ( jsonData , filename , width , height ) {
39- const unique_id = uuidv4 ( ) ;
40-
41- if ( ! filename ) {
42- filename = 'graph-' + unique_id + '.svg' ;
43- }
36+ exports . render = async function ( jsonData , width , height ) {
4437 if ( typeof jsonData !== 'string' ) {
4538 return {
4639 success : false ,
4740 failure : 'json-not-a-string'
4841 } ;
4942 }
50- if ( typeof filename !== 'string' ) {
51- return {
52- success : false ,
53- failure : 'filename-not-a-string'
54- } ;
55- }
5643
5744 const parsed_width = parseInt ( width , 10 ) ;
5845 if ( isNaN ( parsed_width ) || parsed_width <= 0 ) {
0 commit comments