/* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 */ import React from 'react'; import plotComponentFactory from 'react-plotly.js/factory'; import Plotly from 'plotly.js-dist'; import { uiSettingsService } from '../../../../common/utils'; interface PltProps { data: Plotly.Data[]; layout?: Partial; config?: Partial; onHoverHandler?: (event: Readonly) => void; onUnhoverHandler?: (event: Readonly) => void; onClickHandler?: (event: Readonly) => void; height?: string; dispatch?: (props: any) => void; } export function Plt(props: PltProps) { const PlotComponent = plotComponentFactory(Plotly); const darkLayout = uiSettingsService.get('theme:darkMode') ? { paper_bgcolor: '#1D1E24', plot_bgcolor: '#1D1E24', font: { color: '#DFE5EF', }, } : {}; const finalLayout = { autosize: true, barmode: 'stack', legend: { orientation: 'h', traceorder: 'normal', }, showlegend: false, hovermode: 'closest', xaxis: { showgrid: true, zeroline: false, rangemode: 'normal', automargin: true, }, yaxis: { showgrid: true, zeroline: false, rangemode: 'normal', }, ...darkLayout, ...props.layout, }; const finalConfig = { displayModeBar: false, ...props.config, }; return ( ); }