/* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 */ import { EuiColorPicker, EuiFieldText, EuiFormRow, EuiPanel, EuiSelect, EuiSpacer, EuiSwitch, EuiTitle, } from '@elastic/eui'; import React from 'react'; import { GanttParams, PlotlyAxisPosition, PlotlyAxisType, PlotlyLegendOrientation, VisOptionsProps, } from '../gantt_vis_type'; export function OptionsEditor({ aggs, stateParams, setValue }: VisOptionsProps) { const legendOrientationOptions: Array<{ value: PlotlyLegendOrientation; text: string }> = [ { value: 'v', text: 'Vertical' }, { value: 'h', text: 'Horizontal' }, ]; const renderLegendOptions = () => { return (

Legend

setValue('showLegend', e.target.checked)} /> {stateParams.showLegend && ( setValue('legendOrientation', e.target.value as PlotlyLegendOrientation) } disabled={!stateParams.showLegend} /> )}
); }; const renderGridOptions = () => { return (

Grid

setValue('yAxisShowGrid', e.target.checked)} /> setValue('xAxisShowGrid', e.target.checked)} />
); }; const renderColorOptions = () => { return (

Colors

setValue('colors', e)} />
); }; const yAxisPositionOptions: Array<{ value: PlotlyAxisPosition; text: string }> = [ { value: 'left', text: 'Left' }, { value: 'right', text: 'Right' }, ]; const xAxisPositionOptions: Array<{ value: PlotlyAxisPosition; text: string }> = [ { value: 'top', text: 'Top' }, { value: 'bottom', text: 'Bottom' }, ]; const axisTypeOptions: Array<{ value: PlotlyAxisType; text: string }> = [ { value: '-', text: 'Auto' }, { value: 'linear', text: 'Linear' }, { value: 'log', text: 'Log' }, ]; const timeFormatOptions: Array<{ value: string; text: string }> = [ { value: 'hh:mm:ss.SSS A', text: 'hh:mm:ss.SSS (12 hours)' }, { value: 'MM/DD hh:mm:ss A', text: 'MM/DD hh:mm:ss (12 hours)' }, { value: 'MM/DD/YY hh:mm A', text: 'MM/DD/YY hh:mm (12 hours)' }, { value: 'HH:mm:ss.SSS', text: 'hh:mm:ss.SSS (24 hours)' }, { value: 'MM/DD HH:mm:ss', text: 'MM/DD hh:mm:ss (24 hours)' }, { value: 'MM/DD/YY HH:mm', text: 'MM/DD/YY hh:mm (24 hours)' }, ]; const renderYAxisOptions = () => { return (

Y-axis

setValue('yAxisPosition', e.target.value as PlotlyAxisPosition)} /> setValue('yAxisShowLine', e.target.checked)} /> setValue('yAxisShowTitle', e.target.checked)} /> {stateParams.yAxisShowTitle ? ( setValue('yAxisTitle', e.target.value)} /> ) : null}
); }; const renderXAxisOptions = () => { return (

X-axis

setValue('xAxisPosition', e.target.value as PlotlyAxisPosition)} /> setValue('xAxisType', e.target.value as PlotlyAxisType)} /> setValue('timeFormat', e.target.value)} /> setValue('xAxisShowLine', e.target.checked)} /> setValue('xAxisShowTitle', e.target.checked)} /> {stateParams.xAxisShowTitle ? ( setValue('xAxisTitle', e.target.value)} /> ) : null}
); }; return ( <> {renderYAxisOptions()} {renderXAxisOptions()} {renderLegendOptions()} {renderGridOptions()} {renderColorOptions()} ); }