Series that abstracts away some of the more annoying aspects of working with date-value pairs.
A series is an array-like data structure that contains date-value pairs. In fact, the
Array object. Within the series object, data is stored as a list of ordered pairs.
Date ValueDate ValueDate Value...
As the Series is just an extension of an Array, it contains all of the Array methods. However, many methods have been overridden to allow for easier manipulation of the data within the series. It is much more common to manipulate data (y-values) than it is to manipulate the underlying dates themselves.
Series can be manipulated functionally using the built in functions of Via Script. Most of these functions will only accept a series as their primary argument. For example, to add a constant to every value in the series:
const series_plus_seven = ;
In this case, the function
add will return a new series with the constant added to each of the original items.
const sum_of_two_series = ;
This will add two series together, one value at a time. Obviously, series must be of the same length to be manipulated in this way.
Create a Series
const series = ;
Insert a Value
Get a Value
Returns A Value
You can certainly use bracket notation (as with any JS array), but this provides a simpler alias for retrieving values at a certain index.
//Simple aliasseries;//Other method for retrieving values//Note that series[index] is the Date that corresponds to this valueseriesindex1;
Availability of a Date Range
This function is not implemented yet.
Check to see if a Series contains values for all dates within a certain range, with a certain granularity. For example, does the Series contain values for all days between 1 Jan 2018 and 31 Jan 2018?
const available = series;
This function is an override of the JS
Array.map function. It will map all values to a new value, without transforming the keys (dates). It will return a new series and not modify the original series.
const new_series = series;
This function is similar to the
Object.entries function. It will map all values to a array containing both the key and value. It will return a new series and not modify the original series. Please note, this does not return an
Object.entries does. It returns a new
Series, like other functions do.
//Entries is a Series of arrays, each containing [original_key, original_value]const entries = series;
Via Script Functions
...To Be Continued.