Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private addDatasets(data: DataPoint[]) {
const groupedData = groupBy(data, datum => datum.series);
const seriesNames = Object.keys(groupedData);
const plot = seriesNames.length > 1
? new Plots.ClusteredBar()
: new Plots.Bar();
seriesNames.forEach(series => plot.addDataset(new Dataset(groupedData[series])));
return plot;
}