Skip to content

Commit d92a00c

Browse files
committed
feat: add plot/vega/padding initial implementation
--- 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: passed - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - 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 ca6a6c6 commit d92a00c

File tree

15 files changed

+890
-0
lines changed

15 files changed

+890
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
'use strict';
20+
21+
var Padding = require( './../lib' );
22+
23+
var padding = new Padding();
24+
console.log( padding.toJSON() );
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 the bottom padding (in pixels).
27+
*
28+
* @private
29+
* @returns {number} padding
30+
*/
31+
function get() {
32+
return this._bottom;
33+
}
34+
35+
36+
// EXPORTS //
37+
38+
module.exports = get;
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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 logger = require( 'debug' );
26+
var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive;
27+
var format = require( '@stdlib/string/format' );
28+
29+
30+
// VARIABLES //
31+
32+
var debug = logger( 'vega:padding:set:bottom' );
33+
34+
35+
// MAIN //
36+
37+
/**
38+
* Sets the bottom padding (in pixels).
39+
*
40+
* @private
41+
* @param {number} value - input value
42+
* @throws {TypeError} must be a number
43+
* @returns {void}
44+
*/
45+
function set( value ) {
46+
if ( !isNumber( value ) ) {
47+
throw new TypeError( format( 'invalid assignment. `%s` must be a number. Value: `%s`.', 'bottom', value ) );
48+
}
49+
if ( value !== this._bottom ) {
50+
debug( 'Current value: %s. New value: %s.', this._bottom, value );
51+
this._bottom = value;
52+
this.emit( 'change' );
53+
}
54+
}
55+
56+
57+
// EXPORTS //
58+
59+
module.exports = set;
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
'use strict';
20+
21+
// MAIN //
22+
23+
/**
24+
* Returns defaults.
25+
*
26+
* @private
27+
* @returns {Object} default options
28+
*
29+
* @example
30+
* var o = defaults();
31+
* // returns {...}
32+
*/
33+
function defaults() {
34+
return {
35+
// Bottom padding (in pixels):
36+
'bottom': 0,
37+
38+
// Left padding (in pixels):
39+
'left': 0,
40+
41+
// Right padding (in pixels):
42+
'right': 0,
43+
44+
// Top padding (in pixels):
45+
'top': 0
46+
};
47+
}
48+
49+
50+
// EXPORTS //
51+
52+
module.exports = defaults;
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
'use strict';
20+
21+
/**
22+
* Padding constructor.
23+
*
24+
* @module @stdlib/plot/vega/padding
25+
*
26+
* @example
27+
* var Padding = require( '@stdlib/plot/vega/padding' );
28+
*
29+
* var padding = new Padding();
30+
* // returns <Padding>
31+
*/
32+
33+
// MODULES //
34+
35+
var main = require( './main.js' );
36+
37+
38+
// EXPORTS //
39+
40+
module.exports = main;
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 the left padding (in pixels).
27+
*
28+
* @private
29+
* @returns {number} padding
30+
*/
31+
function get() {
32+
return this._left;
33+
}
34+
35+
36+
// EXPORTS //
37+
38+
module.exports = get;
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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 logger = require( 'debug' );
26+
var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive;
27+
var format = require( '@stdlib/string/format' );
28+
29+
30+
// VARIABLES //
31+
32+
var debug = logger( 'vega:padding:set:left' );
33+
34+
35+
// MAIN //
36+
37+
/**
38+
* Sets the left padding (in pixels).
39+
*
40+
* @private
41+
* @param {number} value - input value
42+
* @throws {TypeError} must be a number
43+
* @returns {void}
44+
*/
45+
function set( value ) {
46+
if ( !isNumber( value ) ) {
47+
throw new TypeError( format( 'invalid assignment. `%s` must be a number. Value: `%s`.', 'left', value ) );
48+
}
49+
if ( value !== this._left ) {
50+
debug( 'Current value: %s. New value: %s.', this._left, value );
51+
this._left = value;
52+
this.emit( 'change' );
53+
}
54+
}
55+
56+
57+
// EXPORTS //
58+
59+
module.exports = set;

0 commit comments

Comments
 (0)