Refactor historyTimeAxis(...) function.