|
|
|
@ -1,4 +1,3 @@ |
|
|
|
|
import { css } from '@emotion/css'; |
|
|
|
|
import { identity } from 'lodash'; |
|
|
|
|
import React, { useEffect, useMemo, useState } from 'react'; |
|
|
|
|
|
|
|
|
@ -11,7 +10,6 @@ import { |
|
|
|
|
FieldColorModeId, |
|
|
|
|
FieldConfigSource, |
|
|
|
|
getFrameDisplayName, |
|
|
|
|
GrafanaTheme2, |
|
|
|
|
LoadingState, |
|
|
|
|
SplitOpen, |
|
|
|
|
TimeZone, |
|
|
|
@ -27,15 +25,7 @@ import { |
|
|
|
|
SortOrder, |
|
|
|
|
GraphThresholdsStyleConfig, |
|
|
|
|
} from '@grafana/schema'; |
|
|
|
|
import { |
|
|
|
|
Button, |
|
|
|
|
Icon, |
|
|
|
|
PanelContext, |
|
|
|
|
PanelContextProvider, |
|
|
|
|
SeriesVisibilityChangeMode, |
|
|
|
|
useStyles2, |
|
|
|
|
useTheme2, |
|
|
|
|
} from '@grafana/ui'; |
|
|
|
|
import { PanelContext, PanelContextProvider, SeriesVisibilityChangeMode, useTheme2 } from '@grafana/ui'; |
|
|
|
|
import { GraphFieldConfig } from 'app/plugins/panel/graph/types'; |
|
|
|
|
import { defaultGraphConfig, getGraphFieldConfig } from 'app/plugins/panel/timeseries/config'; |
|
|
|
|
import { Options as TimeSeriesOptions } from 'app/plugins/panel/timeseries/panelcfg.gen'; |
|
|
|
@ -47,7 +37,7 @@ import { useExploreDataLinkPostProcessor } from '../hooks/useExploreDataLinkPost |
|
|
|
|
import { applyGraphStyle, applyThresholdsConfig } from './exploreGraphStyleUtils'; |
|
|
|
|
import { useStructureRev } from './useStructureRev'; |
|
|
|
|
|
|
|
|
|
const MAX_NUMBER_OF_TIME_SERIES = 20; |
|
|
|
|
export const MAX_NUMBER_OF_TIME_SERIES = 20; |
|
|
|
|
|
|
|
|
|
interface Props { |
|
|
|
|
data: DataFrame[]; |
|
|
|
@ -67,6 +57,7 @@ interface Props { |
|
|
|
|
thresholdsConfig?: ThresholdsConfig; |
|
|
|
|
thresholdsStyle?: GraphThresholdsStyleConfig; |
|
|
|
|
eventBus: EventBus; |
|
|
|
|
showAllTimeSeries: boolean; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export function ExploreGraph({ |
|
|
|
@ -87,10 +78,9 @@ export function ExploreGraph({ |
|
|
|
|
thresholdsConfig, |
|
|
|
|
thresholdsStyle, |
|
|
|
|
eventBus, |
|
|
|
|
showAllTimeSeries, |
|
|
|
|
}: Props) { |
|
|
|
|
const theme = useTheme2(); |
|
|
|
|
const style = useStyles2(getStyles); |
|
|
|
|
const [showAllTimeSeries, setShowAllTimeSeries] = useState(false); |
|
|
|
|
|
|
|
|
|
const timeRange = useMemo( |
|
|
|
|
() => ({ |
|
|
|
@ -198,20 +188,6 @@ export function ExploreGraph({ |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<PanelContextProvider value={panelContext}> |
|
|
|
|
{data.length > MAX_NUMBER_OF_TIME_SERIES && !showAllTimeSeries && ( |
|
|
|
|
<div className={style.timeSeriesDisclaimer}> |
|
|
|
|
<Icon className={style.disclaimerIcon} name="exclamation-triangle" /> |
|
|
|
|
Showing only {MAX_NUMBER_OF_TIME_SERIES} time series. |
|
|
|
|
<Button |
|
|
|
|
variant="primary" |
|
|
|
|
fill="text" |
|
|
|
|
onClick={() => setShowAllTimeSeries(true)} |
|
|
|
|
className={style.showAllButton} |
|
|
|
|
> |
|
|
|
|
Show all {data.length} |
|
|
|
|
</Button> |
|
|
|
|
</div> |
|
|
|
|
)} |
|
|
|
|
<PanelRenderer |
|
|
|
|
data={{ |
|
|
|
|
series: dataWithConfig, |
|
|
|
@ -231,20 +207,3 @@ export function ExploreGraph({ |
|
|
|
|
</PanelContextProvider> |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const getStyles = (theme: GrafanaTheme2) => ({ |
|
|
|
|
timeSeriesDisclaimer: css` |
|
|
|
|
label: time-series-disclaimer; |
|
|
|
|
margin: ${theme.spacing(1)} auto; |
|
|
|
|
padding: 10px 0; |
|
|
|
|
text-align: center; |
|
|
|
|
`,
|
|
|
|
|
disclaimerIcon: css` |
|
|
|
|
label: disclaimer-icon; |
|
|
|
|
color: ${theme.colors.warning.main}; |
|
|
|
|
margin-right: ${theme.spacing(0.5)}; |
|
|
|
|
`,
|
|
|
|
|
showAllButton: css` |
|
|
|
|
margin-left: ${theme.spacing(0.5)}; |
|
|
|
|
`,
|
|
|
|
|
}); |
|
|
|
|