Save and load chart data

Commits are separated since the first ones are housekeeping and factorization.