import React from 'react' ; import { Axis , BarSeries , Chart , Position , ScaleType , Settings , SeriesNameFn } from '@elastic/charts' ; import * as TestDatasets from '@elastic/charts/src/utils/data_samples/test_dataset' ; import { useBaseTheme } from '../../use_base_theme' ; export const Example = ( ) => { const customSeriesNamingFn = ( { yAccessor , splitAccessors } ) => { if ( yAccessor === 'y1' && splitAccessors . get ( 'g' ) === 'a' ) { return 'Custom full series name' ; } return null ; } ; return ( < Chart > < Settings showLegend showLegendExtra legendPosition = { Position . Right } baseTheme = { useBaseTheme ( ) } / > < Axis id = "bottom" position = { Position . Bottom } title = "Bottom axis" showOverlappingTicks / > < Axis id = "left2" title = "Left axis" position = { Position . Left } tickFormat = { ( d ) => Number ( d ) . toFixed ( 2 ) } /> < BarSeries id = "bars1" xScaleType = { ScaleType . Ordinal } yScaleType = { ScaleType . Linear } xAccessor = "x" yAccessors = { [ 'y1' , 'y2' ] } splitSeriesAccessors = { [ 'g' ] } data = { TestDatasets . BARCHART_2Y1G } name = { customSeriesNamingFn } / > < /Chart>); } ;