Fix some spacing inconsistencies in the code
Store plot type in a variable
Convert period to milliseconds in case of timeseries

The timeseries plot_type uses the extended timestamp.
This has precision up to milliseconds in Javascript.
But the user probably does not know this,
so pretend that seconds are used.
(Note: the formula will show the value in milliseconds!)