11import React , { useState } from 'react'
2- import {
3- EuiFieldText ,
4- EuiButtonGroup ,
5- EuiAccordion ,
6- EuiButtonGroupProps ,
7- } from '@elastic/eui'
2+ import { EuiFieldText , EuiButtonGroup , EuiButtonGroupProps } from '@elastic/eui'
83import { SwitchInput } from 'uiSrc/components/base/inputs'
94import { FormFieldset } from 'uiSrc/components/base/forms/fieldset'
105import { AxisScale , GraphMode , ChartConfigFormProps } from './interfaces'
@@ -14,6 +9,7 @@ import {
149 TITLE_MAX_LENGTH ,
1510} from './constants'
1611import { RiAccordion } from 'uiSrc/components/base/display/accordion/RiAccordion'
12+ import { ButtonGroup } from 'uiSrc/components/base/forms/button-group/ButtonGroup'
1713
1814const NewEnumSelect = ( {
1915 selected,
@@ -42,6 +38,17 @@ export default function ChartConfigForm(props: ChartConfigFormProps) {
4238
4339 const { onChange, value } = props
4440
41+ const yAxisButtonGroupItems = [
42+ {
43+ label : 'Left' ,
44+ value : false ,
45+ } ,
46+ {
47+ label : 'Right' ,
48+ value : true ,
49+ } ,
50+ ]
51+
4552 return (
4653 < form className = "chart-config-form" >
4754 < div className = "chart-form-top" >
@@ -103,23 +110,21 @@ export default function ChartConfigForm(props: ChartConfigFormProps) {
103110 { Object . keys ( value . keyToY2Axis ) . map ( ( key ) => (
104111 < div className = "y-axis-2-item" >
105112 < div > { key } </ div >
106- < EuiButtonGroup
107- buttonSize = "compressed"
108- options = { [ 'left' , 'right' ] . map ( ( v : string ) => ( {
109- id : v ,
110- label : v ,
111- } ) ) }
112- onChange = { ( id ) =>
113- onChange ( 'keyToY2Axis' , {
114- ...value . keyToY2Axis ,
115- [ key ] : id === 'right' ,
116- } )
117- }
118- idSelected = {
119- value . keyToY2Axis [ key ] === true ? 'right' : 'left'
120- }
121- isFullWidth
122- />
113+ < ButtonGroup >
114+ { yAxisButtonGroupItems . map ( ( item ) => (
115+ < ButtonGroup . Button
116+ isSelected = { value . keyToY2Axis [ key ] === item . value }
117+ onClick = { ( ) =>
118+ onChange ( 'keyToY2Axis' , {
119+ ...value . keyToY2Axis ,
120+ [ key ] : item . value ,
121+ } )
122+ }
123+ >
124+ { item . label }
125+ </ ButtonGroup . Button >
126+ ) ) }
127+ </ ButtonGroup >
123128 </ div >
124129 ) ) }
125130 </ div >
0 commit comments