Skip to content

Commit 1877a42

Browse files
committed
feat: add server property
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 15566b5 commit 1877a42

File tree

3 files changed

+116
-27
lines changed

3 files changed

+116
-27
lines changed

lib/node_modules/@stdlib/plot/charts/base/ctor/lib/main.js

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var Visualization = require( '@stdlib/plot/vega/builder' );
3434
var Padding = require( '@stdlib/plot/vega/padding/ctor' );
3535
var Title = require( '@stdlib/plot/vega/title/ctor' );
3636
var spec2svg = require( '@stdlib/plot/vega/base/spec2svg' );
37-
var createView = require( '@stdlib/plot/base/view' );
37+
var View = require( '@stdlib/plot/base/view' );
3838
var format = require( '@stdlib/string/format' );
3939
var defaults = require( './defaults.js' );
4040

@@ -54,6 +54,9 @@ var setHeight = require( './height/set.js' );
5454
var getPadding = require( './padding/get.js' );
5555
var setPadding = require( './padding/set.js' );
5656

57+
var getServer = require( './server/get.js' );
58+
var setServer = require( './server/set.js' );
59+
5760
var getTheme = require( './theme/get.js' );
5861
var setTheme = require( './theme/set.js' );
5962

@@ -291,6 +294,23 @@ setReadWriteAccessor( Chart.prototype, 'height', getHeight, setHeight );
291294
*/
292295
setReadWriteAccessor( Chart.prototype, 'padding', getPadding, setPadding );
293296

297+
/**
298+
* Chart server.
299+
*
300+
* @name server
301+
* @memberof Chart.prototype
302+
* @type {(Server|null)}
303+
* @default null
304+
*
305+
* @example
306+
* var chart = new Chart();
307+
* // returns <Chart>
308+
*
309+
* var v = chart.server;
310+
* // returns null
311+
*/
312+
setReadWriteAccessor( Chart.prototype, 'server', getServer, setServer );
313+
294314
/**
295315
* Chart theme.
296316
*
@@ -423,7 +443,7 @@ setReadOnly( Chart.prototype, 'toJSON', function toJSON() {
423443
* chart.view( 'stdout' );
424444
*/
425445
setReadOnly( Chart.prototype, 'view', function view( viewer ) {
426-
var ctx;
446+
var view;
427447
var v;
428448

429449
// FIXME: validate viewer argument
@@ -435,31 +455,8 @@ setReadOnly( Chart.prototype, 'view', function view( viewer ) {
435455
}
436456
debug( 'Viewer: %s', v );
437457

438-
// Cache various properties in order to avoid mutation during asynchronous rendering...
439-
ctx = {
440-
'width': this.width,
441-
'height': this.height,
442-
'title': this.title.text.join( '\n' )
443-
};
444-
445-
// Render the chart to a string:
446-
this.render( onRender );
447-
448-
/**
449-
* Callback invoked upon render completion.
450-
*
451-
* @private
452-
* @param {(Error|null)} error - error object or null
453-
* @param {string} result - result
454-
* @throws {Error} unexpected error
455-
*/
456-
function onRender( error, result ) {
457-
if ( error ) {
458-
throw error;
459-
}
460-
debug( 'Generating view...' );
461-
createView( ctx, v, result );
462-
}
458+
view = new View( this );
459+
view.render( v );
463460
});
464461

465462

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
/* eslint-disable no-invalid-this */
20+
21+
'use strict';
22+
23+
// MAIN //
24+
25+
/**
26+
* Returns a chart server.
27+
*
28+
* @private
29+
* @returns {(Server|null)} server
30+
*/
31+
function get() {
32+
return this._server || null;
33+
}
34+
35+
36+
// EXPORTS //
37+
38+
module.exports = get;
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
/* eslint-disable no-invalid-this */
20+
21+
'use strict';
22+
23+
// MODULES //
24+
25+
var isMethodIn = require( '@stdlib/assert/is-method-in' );
26+
var isObject = require( '@stdlib/assert/is-object' );
27+
var format = require( '@stdlib/string/format' );
28+
29+
30+
// MAIN //
31+
32+
/**
33+
* Sets a chart server.
34+
*
35+
* @private
36+
* @param {Server} value - input value
37+
* @throws {TypeError} must be a valid server
38+
* @returns {void}
39+
*/
40+
function set( value ) {
41+
if (
42+
!isObject( value ) &&
43+
!isMethodIn( value, 'address' ) &&
44+
!isMethodIn( value, 'close' )
45+
) {
46+
throw new TypeError( format( 'invalid assignment. `%s` must be a valid server instance. Value: `%s`.', 'server', value ) );
47+
}
48+
this._server = value;
49+
}
50+
51+
52+
// EXPORTS //
53+
54+
module.exports = set;

0 commit comments

Comments
 (0)