Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions lib/node_modules/@stdlib/plot/vega/base/spec2svg-file/lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2026 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

/**
* Render a Vega specification to an SVG file.
*
* @module @stdlib/plot/vega/base/spec2svg-file
*
* @example
* var join = require( 'path' ).join;
* var tmpdir = require( '@stdlib/os/tmpdir' );
* var spec2svgFile = require( '@stdlib/plot/vega/base/spec2svg-file' );
*
* var fpath = join( tmpdir(), 'output.svg' );
*
* var spec = {
* '$schema': 'https://vega.github.io/schema/vega/v6.json',
* 'width': 400,
* 'height': 30,
* 'padding': 5,
* 'title': {
* 'text': 'Hello World'
* },
* 'marks': []
* };
*
* function done( error ) {
* if ( error ) {
* throw error;
* }
* }
*
* spec2svgFile( fpath, spec, done );

Check warning on line 50 in lib/node_modules/@stdlib/plot/vega/base/spec2svg-file/lib/index.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unknown word: "fpath"
*/

// MODULES //

var main = require( './main.js' );


// EXPORTS //

module.exports = main;
88 changes: 88 additions & 0 deletions lib/node_modules/@stdlib/plot/vega/base/spec2svg-file/lib/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2026 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var resolve = require( 'path' ).resolve;
var writeFile = require( '@stdlib/fs/write-file' );
var spec2svg = require( '@stdlib/plot/vega/base/spec2svg' );


// MAIN //

/**
* Renders a Vega specification to an SVG file.
*
* @param {string} outputPath - file path for the SVG output
* @param {Object} spec - Vega specification
* @param {Callback} clbk - callback to invoke upon completion
*
* @example
* var join = require( 'path' ).join;
* var tmpdir = require( '@stdlib/os/tmpdir' );
* var spec2svgFile = require( '@stdlib/plot/vega/base/spec2svg-file' );
*
* var fpath = join( tmpdir(), 'output.svg' );
*
* var spec = {
* '$schema': 'https://vega.github.io/schema/vega/v6.json',
* 'width': 400,
* 'height': 30,
* 'padding': 5,
* 'title': {
* 'text': 'Hello World'
* },
* 'marks': []
* };
*
* function done( error ) {
* if ( error ) {
* throw error;
* }
* }
*
* spec2svgFile( fpath, spec, done );

Check warning on line 61 in lib/node_modules/@stdlib/plot/vega/base/spec2svg-file/lib/main.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unknown word: "fpath"
*/
function spec2svgFile( outputPath, spec, clbk ) {
var fpath;

fpath = resolve( outputPath );
spec2svg( spec, onSVG );

/**
* Callback invoked upon rendering an SVG.
*
* @private
* @param {(Error|null)} error - error object
* @param {string} svg - rendered SVG string
* @returns {void}
*/
function onSVG( error, svg ) {
if ( error ) {
return clbk( error );
}
writeFile( fpath, svg, clbk );
}
}


// EXPORTS //

module.exports = spec2svgFile;
56 changes: 56 additions & 0 deletions lib/node_modules/@stdlib/plot/vega/base/spec2svg-file/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "@stdlib/plot/vega/base/spec2svg-file",
"version": "0.0.0",
"description": "Render a Vega specification to an SVG file.",
"license": "Apache-2.0",
"author": {
"name": "The Stdlib Authors",
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
},
"contributors": [
{
"name": "The Stdlib Authors",
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
}
],
"main": "./lib",
"directories": {
"lib": "./lib"
},
"scripts": {},
"homepage": "https://github.com/stdlib-js/stdlib",
"repository": {
"type": "git",
"url": "git://github.com/stdlib-js/stdlib.git"
},
"bugs": {
"url": "https://github.com/stdlib-js/stdlib/issues"
},
"dependencies": {},
"devDependencies": {},
"engines": {
"node": ">=0.10.0",
"npm": ">2.7.0"
},
"os": [
"aix",
"darwin",
"freebsd",
"linux",
"macos",
"openbsd",
"sunos",
"win32",
"windows"
],
"keywords": [
"stdlib",
"plot",
"vega",
"render",
"svg",
"figure",
"visualization",
"dataviz"
]
}
Loading