rumble-charts
Version:
Truly declarative React charts components
34 lines (31 loc) • 1.37 kB
JavaScript
import { __assign } from '../external/tslib/tslib.es6.js';
import { isFunction } from './isFunction.js';
import { random } from './random.js';
import { range } from './range.js';
function generateRandomSeries(seriesCount, pointsCount, options) {
if (options === void 0) { options = {}; }
options = __assign({ type: 'number', min: 1, max: 100, float: false }, options);
var type = options.type ? options.type.toLowerCase() : 'number';
return range(seriesCount).map(function (seriesIndex) {
var _pointsCount = isFunction(pointsCount) ? pointsCount(seriesIndex) : pointsCount;
return {
data: range(_pointsCount).map(function (pointIndex) {
var value = random(options.min, options.max, options.float);
if (type === 'array') {
return [pointIndex, value];
}
else if (type === 'object') {
var point = options.point;
if (isFunction(point)) {
point = point({ seriesIndex: seriesIndex, pointIndex: pointIndex, value: value });
}
return __assign({ x: pointIndex, y: value }, point);
}
else {
return value;
}
})
};
});
}
export { generateRandomSeries };