optimize JS for timspan graph