Skip to content

Commit 30a554f

Browse files
committed
Add plot README.md file
1 parent 352e5ea commit 30a554f

File tree

1 file changed

+119
-0
lines changed

1 file changed

+119
-0
lines changed
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2021 The Stdlib Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
21+
# Plot
22+
23+
> Standard library plotting.
24+
25+
<section class="usage">
26+
27+
## Usage
28+
29+
```javascript
30+
var plot = require( '@stdlib/plot' );
31+
```
32+
33+
#### plot
34+
35+
Standard library plotting.
36+
37+
```javascript
38+
var x = [ 1, 2, 3 ];
39+
var y = [ 1, 0, 1 ];
40+
41+
var plt = plot( [ x ], [ y ] );
42+
```
43+
44+
</section>
45+
46+
<!-- /.usage -->
47+
48+
<section class="examples">
49+
50+
## Examples
51+
52+
<!-- TODO: better examples -->
53+
54+
<!-- eslint no-undef: "error" -->
55+
56+
```javascript
57+
var randn = require( '@stdlib/random/base/box-muller' );
58+
var Float64Array = require( '@stdlib/array/float64' );
59+
var now = require( '@stdlib/time/now' );
60+
var plot = require( '@stdlib/plot' );
61+
62+
var t;
63+
var x;
64+
var y;
65+
var i;
66+
67+
// Create some data...
68+
t = now() * 1000;
69+
x = new Float64Array( 100 );
70+
y = new Float64Array( x.length );
71+
for ( i = 0; i < x.length; i++ ) {
72+
x[ i ] = t + (i*360000);
73+
y[ i ] = 50.0 + (10.0*randn());
74+
}
75+
76+
// Create a new plot:
77+
var plt = plot( [x], [y], {
78+
'width': 600,
79+
'height': 480,
80+
'xScale': 'time',
81+
'xTickFormat': '%H:%M',
82+
'renderFormat': 'html'
83+
});
84+
85+
// Render as a virtual DOM tree:
86+
var vtree = plt.render( 'vdom' );
87+
console.log( JSON.stringify( vtree ) );
88+
89+
// Render as HTML:
90+
var html = plt.render();
91+
console.log( html );
92+
93+
// Listen for 'render' events (e.g., when triggered due to changes in state):
94+
plt.on( 'render', onRender );
95+
96+
setTimeout( update, 1000 );
97+
98+
function update() {
99+
plt.width = 720;
100+
}
101+
102+
function onRender( html ) {
103+
console.log( html );
104+
}
105+
```
106+
107+
</section>
108+
109+
<!-- /.examples -->
110+
111+
<section class="links">
112+
113+
<!-- <toc-links> -->
114+
115+
<!-- </toc-links> -->
116+
117+
</section>
118+
119+
<!-- /.links -->

0 commit comments

Comments
 (0)