Skip to content
Merged
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
117 changes: 117 additions & 0 deletions lib/node_modules/@stdlib/plot/charts/line/ctor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<!--

@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.

-->

# LineChart

> Line chart constructor.

<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->

<section class="intro">

</section>

<!-- /.intro -->

<!-- Package usage documentation. -->

<section class="usage">

## Usage

```javascript
var LineChart = require( '@stdlib/plot/charts/line/ctor' );
```

#### LineChart( \[x\[, y],] \[options] )

Returns a line chart instance.

```javascript
var chart = new LineChart( [ 1, 2, 3 ], [ 4, 5, 6 ] );
// returns <LineChart>
```

</section>

<!-- /.usage -->

<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="notes">

</section>

<!-- /.notes -->

<!-- Package usage examples. -->

<section class="examples">

## Examples

<!-- eslint no-undef: "error" -->

```javascript
var uniform = require( '@stdlib/random/uniform' );
var Float64Vector = require( '@stdlib/ndarray/vector/float64' );
var LineChart = require( '@stdlib/plot/charts/line/ctor' );

var a = new Float64Vector( [ 10.0, 20.0, 30.0, 40.0, 50.0 ] );
var b = new Float64Vector( [ 20.0, 30.0, 40.0, 50.0, 60.0 ] );

var y = uniform( [ 100, 5 ], a, b );

var chart = new LineChart( y, {
'lineStyle': [ '-', '-.' ],
'lineOpacity': [ 1.0, 0.4 ],
'lineWidth': [ 3, 1 ],
'legend': true
});
console.log( chart.toJSON() );
```

</section>

<!-- /.examples -->

<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="references">

</section>

<!-- /.references -->

<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->

<section class="related">

</section>

<!-- /.related -->

<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="links">

</section>

<!-- /.links -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* @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 bench = require( '@stdlib/bench' );
var format = require( '@stdlib/string/format' );
var pkg = require( './../package.json' ).name;
var LineChart = require( './../lib' );


// MAIN //

bench( format( '%s::instantiation', pkg ), function benchmark( b ) {
var v;
var i;
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
v = new LineChart();
if ( !( v instanceof LineChart ) ) {
b.fail( 'should return an instance' );
}
}
b.toc();
if ( !( v instanceof LineChart ) ) {
b.fail( 'should return an instance' );
}
b.pass( 'benchmark finished' );
b.end();
});

// TODO: add benchmarks

Check warning on line 49 in lib/node_modules/@stdlib/plot/charts/line/ctor/benchmark/benchmark.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unexpected 'todo' comment: 'TODO: add benchmarks'
31 changes: 31 additions & 0 deletions lib/node_modules/@stdlib/plot/charts/line/ctor/docs/repl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

{{alias}}( [x[, y],] [options] )
Returns a line chart instance.

Parameters
----------
x: ArrayLike|ndarray|Array (optional)
An array-like object, an ndarray, or an array of such values. If not
provided a `y` argument, this specifies y-coordinate values. If provided
a `y` argument, this specifies x-coordinate values.

y: ArrayLike|ndarray|Array (optional)
An array-like object, an ndarray, or an array of such values
containing y-coordinate values.

options: Object (optional)
Options.

Returns
-------
chart: LineChart
Line chart instance.

Examples
--------
> var chart = new {{alias}}( [ 1, 2, 3 ], [ 4, 5, 6 ] )
<LineChart>

See Also
--------

126 changes: 126 additions & 0 deletions lib/node_modules/@stdlib/plot/charts/line/ctor/docs/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/*
* @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.
*/

// TypeScript Version: 4.1

/// <reference types="@stdlib/types"/>

import { Collection } from '@stdlib/types/array';
import { ndarray } from '@stdlib/types/ndarray';

/**
* Chart data.
*/
type Data = Collection | ndarray;

/**
* Interface describing constructor options.
*/
interface Options {
/**
* Line colors.
*/
colors?: string | Array<string>;

/**
* Boolean indicating whether to display a chart legend.
*/
legend?: boolean;

/**
* Line opacity.
*/
lineOpacity?: number | Array<number>;

/**
* Line style(s).
*/
lineStyle?: string | Array<string>;

/**
* Line symbol(s).
*/
lineSymbol?: string | Array<string>;

/**
* Line width(s) in pixels.
*/
lineWidth?: number | Array<number>;
}

/**
* Line chart.
*/
declare class LineChart {
/**
* Line chart constructor.
*
* @param options - constructor options
* @returns line chart instance
*
* @example
* var chart = new LineChart();
* // returns <LineChart>
*/
constructor( options?: Options );

/**
* Line chart constructor.
*
* @param y - y-values
* @param options - constructor options
* @returns line chart instance
*
* @example
* var chart = new LineChart( [ 4, 5, 6 ] );
* // returns <LineChart>
*/
constructor( y: Data | Array<Data>, options?: Options );

/**
* Line chart constructor.
*
* @param x - x-values
* @param y - y-values
* @param options - constructor options
* @returns line chart instance
*
* @example
* var chart = new LineChart( [ 1, 2, 3 ], [ 4, 5, 6 ] );
* // returns <LineChart>
*/
constructor( x: Data | Array<Data>, y: Data | Array<Data>, options?: Options );

/**
* Serializes a chart to a JSON object.
*
* @returns JSON object
*
* @example
* var chart = new LineChart( [ 1, 2, 3 ], [ 4, 5, 6 ] );
*
* var v = chart.toJSON();
* // returns {...}
*/
toJSON(): Record<string, unknown>;
}


// EXPORTS //

export = LineChart;
66 changes: 66 additions & 0 deletions lib/node_modules/@stdlib/plot/charts/line/ctor/docs/types/test.ts
Original file line number Diff line number Diff line change
@@ -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 @typescript-eslint/no-unused-expressions */

import LineChart = require( './index' );


// TESTS //

// The constructor returns a line chart instance...
{
new LineChart(); // $ExpectType LineChart
new LineChart( [ 4, 5, 6 ] ); // $ExpectType LineChart
new LineChart( [ 1, 2, 3 ], [ 4, 5, 6 ] ); // $ExpectType LineChart
new LineChart( {} ); // $ExpectType LineChart
new LineChart( [ 1, 2, 3 ], [ 4, 5, 6 ], {} ); // $ExpectType LineChart
}

// The compiler throws an error if the constructor is provided an invalid first argument...
{
new LineChart( 5 ); // $ExpectError
new LineChart( true ); // $ExpectError
new LineChart( null ); // $ExpectError
}

// The compiler throws an error if the constructor is provided an invalid options argument...
{
new LineChart( [ 1, 2, 3 ], [ 4, 5, 6 ], 5 ); // $ExpectError
new LineChart( [ 1, 2, 3 ], [ 4, 5, 6 ], 'abc' ); // $ExpectError
new LineChart( [ 1, 2, 3 ], [ 4, 5, 6 ], null ); // $ExpectError
}

// The compiler throws an error if the constructor is provided an unsupported number of arguments...
{
new LineChart( [ 1, 2, 3 ], [ 4, 5, 6 ], {}, {} ); // $ExpectError
}

// The `toJSON` method returns a JSON object...
{
const chart = new LineChart( [ 1, 2, 3 ], [ 4, 5, 6 ] );

chart.toJSON(); // $ExpectType Record<string, unknown>
}

// The compiler throws an error if the `toJSON` method is provided any arguments...
{
const chart = new LineChart();

chart.toJSON( {} ); // $ExpectError
}
Loading
Loading