Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add base interface of Unicode plot and add implementation of bar plot #5444

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft
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
47 changes: 47 additions & 0 deletions lib/node_modules/@stdlib/plot/unicode/static_plots/bar/default.js
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the directory "static_plots"? Is there a reason to distinguish between "static" and presumably "dynamic"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actully when i see the sparkline code base i thought it take the dynamic inputs means continues from buffer , so the interface i have designe is for static plots only in which we provide full date before rendering , so thats the reason why i have put the name static_plot .

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2025 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 //


// MAIN //

/**
* Returns default options.
*
* @private
* @returns {Object} default options
*/
function defaults() {
var out = {};
out.rows = void 0;
out.cols = void 0;
out.xaxis = [];
out.yaxis = [];
out.barColor = 'Fbl';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the color naming scheme here? "Fbl" is not immediately obvious.

Copy link
Contributor Author

@Vinit-Pandit Vinit-Pandit Mar 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fbl stands for forward ( it is name i have seen used in ANSI encoding ) color black , we also have the Bbl for background black . we can change the color schema naming afterwards.

out.labelColor = 'Fbl';
out.marker = 'block';
return out;
}


// EXPORTS //

module.exports = defaults;
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2025 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 barchart = require( '@stdlib/plot/unicode/static_plots/bar' );

/*
1) some blocks are not generating Ex : 8th bar
2) labelColor is not working
*/
var options = {
'xaxis': [ 1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14
],
'yaxis': [ 10,
1,
5,
6,
7,
22,
10,
35,
40,
10,
11,
12,
13,
15
],
'rows': 20,
'cols': 100,
'barColor': 'Frd',
'labelColor': 'Frd'
};
var inst = new barchart(options);

inst.draw();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the distinction between "draw" and "render"?

inst.render();
37 changes: 37 additions & 0 deletions lib/node_modules/@stdlib/plot/unicode/static_plots/bar/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2025 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';

/**
* Base class for unicode bar chart.
*
* @module @stdlib/plot/unicode/static_plot/bar
*
* @example
* var base = require( '@stdlib/plot/unicode/static_plot/bar' );
*/

// MODULES //

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


// EXPORTS //

module.exports = main;
Loading
Loading