Construct time series in javascript code