Reusing the same config object for multiple charts

Sometimes, when you have a lot of similar charts on the same page, you'll want to reuse the same base config across all of them.

The first natural instinct would be to create a "template" config object, then pass it as config for each individual chart object.

That, won't work, though. The chart take the object and uses it to store additional settings, references, etc. Naturally, if the same object is reused across multiple chart instances, it might (and will) create various unpredictable anomalies.

The solution is to "clone" the config object, so that each chart receives it's own config, without creating any conflicts.

This demo defines and showcases a function which can be used to clone those objects safely.