time series JS code + figure