UNPKG

1.12 kBJavaScriptView Raw
1import times from 'lodash/times';
2import { SERIES_NAME, SERIES_NAME_SHORT } from '../stories_utils';
3
4import {
5 marqueeSelectionSvgPath,
6 redoSvgPath,
7 clearAllSvgPath,
8 downloadSvgPath,
9} from '../svgs/svg_paths';
10import { colorFromDefaultPalette } from './theme';
11
12export const toolbox = {
13 feature: {
14 dataZoom: {
15 icon: {
16 zoom: marqueeSelectionSvgPath,
17 back: redoSvgPath,
18 },
19 },
20 restore: {
21 icon: clearAllSvgPath,
22 },
23 saveAsImage: {
24 icon: downloadSvgPath,
25 },
26 },
27};
28
29/**
30 * Generates series data for usage in chart examples
31 *
32 * @param {Number} amount number of generated series
33 * @param {String} nameType type of names - how long they should be
34 * @returns {Array} generated series data
35 */
36export const generateSeriesData = (amount = 10, nameType = SERIES_NAME_SHORT) => {
37 const defaultData = [820, 932, 960, 1150, 1290, 1330, 1390];
38 const name = SERIES_NAME[nameType];
39
40 return times(amount, (index) => ({
41 color: colorFromDefaultPalette(index),
42 data: defaultData.map((value) => value * index),
43 name: `${name}${index + 1}`,
44 }));
45};