|
| 1 | +/* |
| 2 | + * Licensed to Elasticsearch B.V. under one or more contributor |
| 3 | + * license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright |
| 5 | + * ownership. Elasticsearch B.V. licenses this file to you under |
| 6 | + * the Apache License, Version 2.0 (the "License"); you may |
| 7 | + * not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +import { number, boolean } from '@storybook/addon-knobs'; |
| 21 | +import React from 'react'; |
| 22 | + |
| 23 | +import { Axis, Chart, Position, ScaleType, Settings, LineSeries } from '../../src'; |
| 24 | +import { getRandomNumberGenerator } from '../../src/mocks/utils'; |
| 25 | + |
| 26 | +const rng = getRandomNumberGenerator(); |
| 27 | +const bubbleData = new Array(30).fill(0).map((_, i) => ({ |
| 28 | + x: i, |
| 29 | + y: rng(2, 3, 2), |
| 30 | + z: rng(0, 20), |
| 31 | +})); |
| 32 | + |
| 33 | +export const Example = () => { |
| 34 | + const markSizeRatio = number('markSizeRatio', 10, { |
| 35 | + range: true, |
| 36 | + min: 1, |
| 37 | + max: 20, |
| 38 | + step: 1, |
| 39 | + }); |
| 40 | + |
| 41 | + const visible = boolean('show line points', true); |
| 42 | + |
| 43 | + return ( |
| 44 | + <Chart className="story-chart"> |
| 45 | + <Settings |
| 46 | + showLegend |
| 47 | + theme={{ |
| 48 | + markSizeRatio, |
| 49 | + lineSeriesStyle: { |
| 50 | + point: { |
| 51 | + visible, |
| 52 | + }, |
| 53 | + }, |
| 54 | + }} |
| 55 | + debug={boolean('debug', false)} |
| 56 | + /> |
| 57 | + <Axis id="bottom" position={Position.Bottom} title="Bottom axis" /> |
| 58 | + <Axis |
| 59 | + id="left2" |
| 60 | + title="Left axis" |
| 61 | + position={Position.Left} |
| 62 | + tickFormat={(d) => Number(d).toFixed(2)} |
| 63 | + domain={{ max: 5 }} |
| 64 | + /> |
| 65 | + |
| 66 | + <LineSeries |
| 67 | + id="lines" |
| 68 | + xScaleType={ScaleType.Linear} |
| 69 | + yScaleType={ScaleType.Linear} |
| 70 | + xAccessor="x" |
| 71 | + yAccessors={['y']} |
| 72 | + markSizeAccessor="z" |
| 73 | + data={bubbleData} |
| 74 | + /> |
| 75 | + </Chart> |
| 76 | + ); |
| 77 | +}; |
| 78 | + |
| 79 | +Example.text = 'testing'; |
0 commit comments