diff --git a/lib/node_modules/@stdlib/plot/vega/transform/loess/examples/index.js b/lib/node_modules/@stdlib/plot/vega/transform/loess/examples/index.js new file mode 100644 index 000000000000..65c5dfd7a4f0 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/loess/examples/index.js @@ -0,0 +1,30 @@ +/** +* @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'; + +var Field = require( '@stdlib/plot/vega/field/ctor' ); +var LoessTransform = require( './../lib' ); + +var transform = new LoessTransform({ + 'x': new Field({ 'field': 'dv' }), + 'y': new Field({ 'field': 'iv' }), + 'bandwidth': 0.2 +}); + +console.log( transform.toJSON() ); diff --git a/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/as/get.js b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/as/get.js new file mode 100644 index 000000000000..7932e5a40214 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/as/get.js @@ -0,0 +1,43 @@ +/** +* @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. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var prop = require( './properties.js' ); + + +// MAIN // + +/** +* Returns the output field names for the predictor and predicted values. +* +* @private +* @returns {(string|void)} output field names +*/ +function get() { + return this[ prop.private ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/as/properties.js b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/as/properties.js new file mode 100644 index 000000000000..3f2304dc2f08 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/as/properties.js @@ -0,0 +1,33 @@ +/** +* @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 property2object = require( '@stdlib/plot/vega/base/property2object' ); + + +// MAIN // + +var obj = property2object( 'as' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/as/set.js b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/as/set.js new file mode 100644 index 000000000000..3866f5fd788c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/as/set.js @@ -0,0 +1,66 @@ +/** +* @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. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var logger = require( 'debug' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var format = require( '@stdlib/string/format' ); +var changeEvent = require( './../change_event.js' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:loess-transform:set:'+prop.name ); + + +// MAIN // + +/** +* Sets the output field names for the predictor and predicted values. +* +* ## Notes +* +* - Providing `undefined` "unsets" the configured value. +* +* @private +* @param {(string|void)} value - input value +* @throws {TypeError} must be a string +* @returns {void} +*/ +function set( value ) { + if ( !isString( value ) && !isUndefined( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a string. Value: `%s`.', prop.name, value ) ); + } + if ( value !== this[ prop.private ] ) { + debug( 'Current value: %s. New value: %s.', this[ prop.private ], value ); + this[ prop.private ] = value; + this.emit( 'change', changeEvent( prop.name ) ); + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/bandwidth/get.js b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/bandwidth/get.js new file mode 100644 index 000000000000..247bb9d5e1b7 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/bandwidth/get.js @@ -0,0 +1,43 @@ +/** +* @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. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var prop = require( './properties.js' ); + + +// MAIN // + +/** +* Returns the smoothing parameter. +* +* @private +* @returns {number} bandwidth +*/ +function get() { + return this[ prop.private ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/bandwidth/properties.js b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/bandwidth/properties.js new file mode 100644 index 000000000000..df1f857e3f75 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/bandwidth/properties.js @@ -0,0 +1,33 @@ +/** +* @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 property2object = require( '@stdlib/plot/vega/base/property2object' ); + + +// MAIN // + +var obj = property2object( 'bandwidth' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/bandwidth/set.js b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/bandwidth/set.js new file mode 100644 index 000000000000..3cb114c52c48 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/bandwidth/set.js @@ -0,0 +1,61 @@ +/** +* @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. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var logger = require( 'debug' ); +var isNonNegativeNumber = require( '@stdlib/assert/is-nonnegative-number' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var changeEvent = require( './../change_event.js' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:loess-transform:set:'+prop.name ); + + +// MAIN // + +/** +* Sets the smoothing parameter. +* +* @private +* @param {NonNegativeNumber} value - input value +* @throws {TypeError} must be a nonnegative number +* @returns {void} +*/ +function set( value ) { + if ( !isNonNegativeNumber( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a nonnegative number. Value: `%s`.', prop.name, value ) ); + } + if ( value !== this[ prop.private ] ) { + debug( 'Current value: %s. New value: %s.', this[ prop.private ], value ); + this[ prop.private ] = value; + this.emit( 'change', changeEvent( prop.name ) ); + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/change_event.js b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/change_event.js new file mode 100644 index 000000000000..e444f9c667b0 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/change_event.js @@ -0,0 +1,41 @@ +/** +* @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'; + +// MAIN // + +/** +* Returns a new change event object. +* +* @private +* @param {string} property - property name +* @returns {Object} event object +*/ +function event( property ) { // eslint-disable-line stdlib/no-redeclare + return { + 'type': 'update', + 'source': 'transform', + 'property': property + }; +} + + +// EXPORTS // + +module.exports = event; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/defaults.js b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/defaults.js new file mode 100644 index 000000000000..a519573f54e8 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/defaults.js @@ -0,0 +1,43 @@ +/** +* @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'; + +// MAIN // + +/** +* Returns defaults. +* +* @private +* @returns {Object} default options +* +* @example +* var o = defaults(); +* // returns {...} +*/ +function defaults() { + return { + // The smoothing parameter: + 'bandwidth': 0.3 + }; +} + + +// EXPORTS // + +module.exports = defaults; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/groupby/get.js b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/groupby/get.js new file mode 100644 index 000000000000..b5bacad05361 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/groupby/get.js @@ -0,0 +1,43 @@ +/** +* @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. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var prop = require( './properties.js' ); + + +// MAIN // + +/** +* Returns the data fields to group by. +* +* @private +* @returns {(Array|void)} fields +*/ +function get() { + return this[ prop.private ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/groupby/properties.js b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/groupby/properties.js new file mode 100644 index 000000000000..9132e7e77a3a --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/groupby/properties.js @@ -0,0 +1,33 @@ +/** +* @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 property2object = require( '@stdlib/plot/vega/base/property2object' ); + + +// MAIN // + +var obj = property2object( 'groupby' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/groupby/set.js b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/groupby/set.js new file mode 100644 index 000000000000..0ce83474460a --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/groupby/set.js @@ -0,0 +1,84 @@ +/** +* @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. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var logger = require( 'debug' ); +var isFieldArray = require( '@stdlib/plot/vega/base/assert/is-field-array' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasEqualValues = require( '@stdlib/array/base/assert/has-equal-values' ); +var copy = require( '@stdlib/array/base/copy' ); +var format = require( '@stdlib/string/format' ); +var changeEvent = require( './../change_event.js' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:loess-transform:set:'+prop.name ); + + +// MAIN // + +/** +* Sets the data fields to group by. +* +* ## Notes +* +* - Providing `undefined` "unsets" the configured value. +* +* @private +* @param {(FieldArray|void)} value - input value +* @throws {TypeError} must be an array of valid fields +* @returns {void} +*/ +function set( value ) { + if ( !isFieldArray( value ) ) { + if ( isUndefined( value ) ) { + if ( value === this[ prop.private ] ) { + return; + } + debug( 'Current value: %s. New value: %s.', JSON.stringify( this[ prop.private ] ), value ); + this[ prop.private ] = value; + this.emit( 'change', changeEvent( prop.name ) ); + return; + } + throw new TypeError( format( 'invalid assignment. `%s` must be an array of valid fields. Value: `%s`.', prop.name, value ) ); + } + value = copy( value ); + if ( isUndefined( this[ prop.private ] ) ) { + debug( 'Current value: %s. New value: %s.', this[ prop.private ], JSON.stringify( value ) ); + this[ prop.private ] = value; + this.emit( 'change', changeEvent( prop.name ) ); + return; + } + if ( !hasEqualValues( value, this[ prop.private ] ) ) { + debug( 'Current value: %s. New value: %s.', JSON.stringify( this[ prop.private ] ), JSON.stringify( value ) ); + this[ prop.private ] = copy( value ); + this.emit( 'change', changeEvent( prop.name ) ); + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/index.js b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/index.js new file mode 100644 index 000000000000..72535ffbeba2 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/index.js @@ -0,0 +1,45 @@ +/** +* @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'; + +/** +* Loess transform constructor. +* +* @module @stdlib/plot/vega/transform/loess +* +* @example +* var Field = require( '@stdlib/plot/vega/field/ctor' ); +* var LoessTransform = require( '@stdlib/plot/vega/transform/loess' ); +* +* var transform = new LoessTransform({ +* 'x': new Field({ 'field': 'dv' }), +* 'y': new Field({ 'field': 'iv' }), +* 'bandwidth': 0.2 +* }); +* // returns +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/main.js b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/main.js new file mode 100644 index 000000000000..b88e0b0993ac --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/main.js @@ -0,0 +1,313 @@ +/** +* @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. +*/ + +/* eslint-disable no-restricted-syntax, no-invalid-this, stdlib/no-empty-lines-between-requires */ + +'use strict'; + +// MODULES // + +var EventEmitter = require( 'events' ).EventEmitter; +var logger = require( 'debug' ); +var isObject = require( '@stdlib/assert/is-object' ); +var setNonEnumerableReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils/define-nonenumerable-read-only-accessor' ); // eslint-disable-line id-length +var setReadWriteAccessor = require( '@stdlib/utils/define-read-write-accessor' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var inherit = require( '@stdlib/utils/inherit' ); +var objectKeys = require( '@stdlib/utils/keys' ); +var instance2json = require( '@stdlib/plot/vega/base/to-json' ); +var transformErrorMessage = require( '@stdlib/plot/vega/base/transform-validation-message' ); +var format = require( '@stdlib/string/format' ); +var properties = require( './properties.json' ); +var defaults = require( './defaults.js' ); + +// Note: keep the following in alphabetical order according to the `require` path... +var getAs = require( './as/get.js' ); +var setAs = require( './as/set.js' ); + +var getBandwidth = require( './bandwidth/get.js' ); +var setBandwidth = require( './bandwidth/set.js' ); + +var getGroupby = require( './groupby/get.js' ); +var setGroupby = require( './groupby/set.js' ); + +var getX = require( './x/get.js' ); +var setX = require( './x/set.js' ); + +var getY = require( './y/get.js' ); +var setY = require( './y/set.js' ); + +var getProperties = require( './properties/get.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:loess-transform:main' ); + + +// MAIN // + +/** +* Loess transform constructor. +* +* @constructor +* @param {Options} options - constructor options +* @param {Field} options.x - data field for the independent variable (predictor) +* @param {Field} options.y - data field for the dependent variable (predicted) +* @param {NonNegativeNumber} [options.bandwidth=0.3] - smoothing parameter +* @param {(FieldArray|void)} [options.groupby] - data fields to group by +* @param {string} [options.as] - output field names for the predictor and predicted values for the line of best fit +* @throws {TypeError} options argument must be an object +* @throws {Error} must provide valid options +* @returns {LoessTransform} loess transform instance +* +* @example +* var Field = require( '@stdlib/plot/vega/field/ctor' ); +* +* var transform = new LoessTransform({ +* 'x': new Field({ 'field': 'dv' }), +* 'y': new Field({ 'field': 'iv' }), +* 'bandwidth': 0.2 +* }); +* // returns +*/ +function LoessTransform( options ) { + var opts; + var keys; + var v; + var k; + var i; + if ( !( this instanceof LoessTransform ) ) { + return new LoessTransform( options ); + } + EventEmitter.call( this ); + + if ( !isObject( options ) ) { + throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + } + + // Check for required properties... + if ( !hasProp( options, 'x' ) ) { + throw new TypeError( 'invalid argument. Options argument must specify a data field for the independent variable.' ); + } + if ( !hasProp( options, 'y' ) ) { + throw new TypeError( 'invalid argument. Options argument must specify a data field for the dependent variable.' ); + } + + // Resolve the default configuration: + opts = defaults(); + + // Set internal properties according to the default configuration... + keys = objectKeys( opts ); + for ( i = 0; i < keys.length; i++ ) { + k = keys[ i ]; + this[ '_'+k ] = opts[ k ]; + } + + // Validate provided options by attempting to assign option values to corresponding fields... + for ( i = 0; i < properties.length; i++ ) { + k = properties[ i ]; + if ( !hasProp( options, k ) ) { + continue; + } + v = options[ k ]; + try { + this[ k ] = v; + } catch ( err ) { + debug( 'Encountered an error. Error: %s', err.message ); + + // FIXME: retain thrown error type + throw new Error( transformErrorMessage( err.message ) ); + } + } + return this; +} + +/* +* Inherit from the `EventEmitter` prototype. +*/ +inherit( LoessTransform, EventEmitter ); + +/** +* Constructor name. +* +* @private +* @name name +* @memberof LoessTransform +* @readonly +* @type {string} +*/ +setNonEnumerableReadOnly( LoessTransform, 'name', 'LoessTransform' ); + +/** +* Output field names for the predictor and predicted values for the line of best fit. +* +* @name as +* @memberof LoessTransform.prototype +* @type {string} +* +* @example +* var Field = require( '@stdlib/plot/vega/field/ctor' ); +* +* var transform = new LoessTransform({ +* 'x': new Field({ 'field': 'dv' }), +* 'y': new Field({ 'field': 'iv' }), +* 'as': 'predicted' +* }); +* +* var v = transform.as; +* // returns 'predicted' +*/ +setReadWriteAccessor( LoessTransform.prototype, 'as', getAs, setAs ); + +/** +* Smoothing parameter. +* +* @name bandwidth +* @memberof LoessTransform.prototype +* @type {NonNegativeNumber} +* @default 0.3 +* +* @example +* var Field = require( '@stdlib/plot/vega/field/ctor' ); +* +* var transform = new LoessTransform({ +* 'x': new Field({ 'field': 'dv' }), +* 'y': new Field({ 'field': 'iv' }), +* 'bandwidth': 0.2 +* }); +* +* var v = transform.bandwidth; +* // returns 0.2 +*/ +setReadWriteAccessor( LoessTransform.prototype, 'bandwidth', getBandwidth, setBandwidth ); + +/** +* Data fields to group by. +* +* @name groupby +* @memberof LoessTransform.prototype +* @type {(Array|void)} +* +* @example +* var Field = require( '@stdlib/plot/vega/field/ctor' ); +* +* var transform = new LoessTransform({ +* 'x': new Field({ 'field': 'dv' }), +* 'y': new Field({ 'field': 'iv' }), +* 'groupby': [ new Field({ 'field': 'category' }) ] +* }); +* +* var v = transform.groupby; +* // returns [...] +*/ +setReadWriteAccessor( LoessTransform.prototype, 'groupby', getGroupby, setGroupby ); + +/** +* Data field for the independent variable (predictor). +* +* @name x +* @memberof LoessTransform.prototype +* @type {Field} +* +* @example +* var Field = require( '@stdlib/plot/vega/field/ctor' ); +* +* var transform = new LoessTransform({ +* 'x': new Field({ 'field': 'dv' }), +* 'y': new Field({ 'field': 'iv' }) +* }); +* +* var v = transform.x; +* // returns +*/ +setReadWriteAccessor( LoessTransform.prototype, 'x', getX, setX ); + +/** +* Data field for the dependent variable (predicted). +* +* @name y +* @memberof LoessTransform.prototype +* @type {Field} +* +* @example +* var Field = require( '@stdlib/plot/vega/field/ctor' ); +* +* var transform = new LoessTransform({ +* 'x': new Field({ 'field': 'dv' }), +* 'y': new Field({ 'field': 'iv' }) +* }); +* +* var v = transform.y; +* // returns +*/ +setReadWriteAccessor( LoessTransform.prototype, 'y', getY, setY ); + +/** +* Loess transform properties. +* +* @name properties +* @memberof LoessTransform.prototype +* @type {Array} +* +* @example +* var Field = require( '@stdlib/plot/vega/field/ctor' ); +* +* var transform = new LoessTransform({ +* 'x': new Field({ 'field': 'dv' }), +* 'y': new Field({ 'field': 'iv' }) +* }); +* +* var v = transform.properties; +* // returns [...] +*/ +setNonEnumerableReadOnlyAccessor( LoessTransform.prototype, 'properties', getProperties ); + +/** +* Serializes an instance to a JSON object. +* +* ## Notes +* +* - This method is implicitly invoked by `JSON.stringify`. +* +* @name toJSON +* @memberof LoessTransform.prototype +* @type {Function} +* @returns {Object} JSON object +* +* @example +* var Field = require( '@stdlib/plot/vega/field/ctor' ); +* +* var transform = new LoessTransform({ +* 'x': new Field({ 'field': 'dv' }), +* 'y': new Field({ 'field': 'iv' }), +* 'bandwidth': 0.2 +* }); +* +* var v = transform.toJSON(); +* // returns {...} +*/ +setNonEnumerableReadOnly( LoessTransform.prototype, 'toJSON', function toJSON() { + return instance2json( this, properties ); +}); + + +// EXPORTS // + +module.exports = LoessTransform; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/properties.json b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/properties.json new file mode 100644 index 000000000000..812660a77bd4 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/properties.json @@ -0,0 +1,7 @@ +[ + "as", + "bandwidth", + "groupby", + "x", + "y" +] diff --git a/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/properties/get.js b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/properties/get.js new file mode 100644 index 000000000000..f3cbb28454ea --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/properties/get.js @@ -0,0 +1,41 @@ +/** +* @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 properties = require( './../properties.json' ); + + +// MAIN // + +/** +* Returns the list of enumerable properties. +* +* @private +* @returns {Array} properties +*/ +function get() { + return properties.slice(); +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/x/get.js b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/x/get.js new file mode 100644 index 000000000000..04b95582992b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/x/get.js @@ -0,0 +1,44 @@ +/** +* @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. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +const Field = require('@stdlib/plot/vega/field/ctor/lib/main.js'); +// MODULES // + +var prop = require( './properties.js' ); + + +// MAIN // + +/** +* Returns the data field for the independent variable. +* +* @private +* @returns {Field} field +*/ +function get() { + return this[ prop.private ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/x/properties.js b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/x/properties.js new file mode 100644 index 000000000000..8562bbadefc2 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/x/properties.js @@ -0,0 +1,33 @@ +/** +* @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 property2object = require( '@stdlib/plot/vega/base/property2object' ); + + +// MAIN // + +var obj = property2object( 'x' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/x/set.js b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/x/set.js new file mode 100644 index 000000000000..dfcf85a0a184 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/x/set.js @@ -0,0 +1,61 @@ +/** +* @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. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var logger = require( 'debug' ); +var isField = require( '@stdlib/plot/vega/base/assert/is-field' ); +var format = require( '@stdlib/string/format' ); +var changeEvent = require( './../change_event.js' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:loess-transform:set:'+prop.name ); + + +// MAIN // + +/** +* Sets the data field for the independent variable. +* +* @private +* @param {Field} value - input value +* @throws {TypeError} must be a valid field +* @returns {void} +*/ +function set( value ) { + if ( !isField( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a valid field. Value: `%s`.', prop.name, value ) ); + } + if ( value !== this[ prop.private ] ) { + debug( 'Current value: %s. New value: %s.', JSON.stringify( this[ prop.private ] ), JSON.stringify( value ) ); + this[ prop.private ] = value; + this.emit( 'change', changeEvent( prop.name ) ); + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/y/get.js b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/y/get.js new file mode 100644 index 000000000000..a8e2e54360f0 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/y/get.js @@ -0,0 +1,43 @@ +/** +* @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. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var prop = require( './properties.js' ); + + +// MAIN // + +/** +* Returns the data field for the dependent variable. +* +* @private +* @returns {Field} field +*/ +function get() { + return this[ prop.private ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/y/properties.js b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/y/properties.js new file mode 100644 index 000000000000..3b4027c694ff --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/y/properties.js @@ -0,0 +1,33 @@ +/** +* @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 property2object = require( '@stdlib/plot/vega/base/property2object' ); + + +// MAIN // + +var obj = property2object( 'y' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/y/set.js b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/y/set.js new file mode 100644 index 000000000000..2eb9d669c04d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/loess/lib/y/set.js @@ -0,0 +1,61 @@ +/** +* @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. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var logger = require( 'debug' ); +var isField = require( '@stdlib/plot/vega/base/assert/is-field' ); +var format = require( '@stdlib/string/format' ); +var changeEvent = require( './../change_event.js' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:loess-transform:set:'+prop.name ); + + +// MAIN // + +/** +* Sets the data field for the dependent variable. +* +* @private +* @param {Field} value - input value +* @throws {TypeError} must be a valid field +* @returns {void} +*/ +function set( value ) { + if ( !isField( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a valid field. Value: `%s`.', prop.name, value ) ); + } + if ( value !== this[ prop.private ] ) { + debug( 'Current value: %s. New value: %s.', JSON.stringify( this[ prop.private ] ), JSON.stringify( value ) ); + this[ prop.private ] = value; + this.emit( 'change', changeEvent( prop.name ) ); + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/loess/package.json b/lib/node_modules/@stdlib/plot/vega/transform/loess/package.json new file mode 100644 index 000000000000..791ce82b457d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/loess/package.json @@ -0,0 +1,61 @@ +{ + "name": "@stdlib/plot/vega/transform/loess", + "version": "0.0.0", + "description": "Loess transform constructor.", + "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": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "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", + "transform", + "loess", + "constructor", + "ctor" + ], + "__stdlib__": {} +}