import { boolean , select } from '@storybook/addon-knobs' ; import moment from 'moment' ; import React from 'react' ; import { LineSeries , Chart , ScaleType , Settings , Position , Axis } from '@elastic/charts' ; import { useBaseTheme } from '../../use_base_theme' ; export const Example = ( ) => { const negative = boolean ( 'use negative values' , true ) ; const yScaleType = select ( 'Y scale type' , { [ ScaleType . Linear ] : ScaleType . Linear , [ ScaleType . Log ] : ScaleType . Log , } , ScaleType . Linear ) ; const start = moment ( 1628547917775 ) ; const data = new Array ( 12 ) . fill ( 0 ) . map ( ( _ , i ) => { const months = 1 ; return { y : i === 10 ? ( negative ? - 1 : 1 ) : 0 , x : start . add ( months , 'm' ) . valueOf ( ) , } ; } ) ; return ( < Chart > < Settings baseTheme = { useBaseTheme ( ) } / > < Axis id = "y" position = { Position . Left } / > < Axis id = "x" position = { Position . Bottom } / > < LineSeries fit = "linear" id = "line" xAccessor = "x" yAccessors = { [ 'y' ] } xScaleType = { ScaleType . Time } yScaleType = { yScaleType } data = { data } / > < /Chart>); } ;