Move stacking to metadata and don't modify data.

Close #868.
Before code below depended on `datasets` variable. This line needs to know how many datasets are in plot, so we can iterate through `datasets` or `_datasetKeysInOrder `. Right now we don't need `datasets`, so this variable was deleted and one call was saved - `datasets()`.