|
@@ -5,7 +5,6 @@ import type {XAXisOption} from 'echarts/types/dist/shared';
|
|
|
import moment from 'moment';
|
|
|
|
|
|
import type {ReactEchartsRef, Series} from 'sentry/types/echarts';
|
|
|
-import {getDuration} from 'sentry/utils/formatters';
|
|
|
import {isCumulativeOp} from 'sentry/utils/metrics';
|
|
|
import type {MetricCorrelation, MetricSummary} from 'sentry/utils/metrics/types';
|
|
|
import {fitToValueRect, getValueRect} from 'sentry/views/ddm/chartUtils';
|
|
@@ -20,6 +19,7 @@ type UseChartSamplesProps = {
|
|
|
onMouseOut?: (sample: Sample) => void;
|
|
|
onMouseOver?: (sample: Sample) => void;
|
|
|
operation?: string;
|
|
|
+ valueFormatter?: (value: number) => string;
|
|
|
};
|
|
|
|
|
|
// TODO: remove this once we have a stabilized type for this
|
|
@@ -42,6 +42,7 @@ export function useChartSamples({
|
|
|
chartRef,
|
|
|
operation,
|
|
|
timeseries,
|
|
|
+ valueFormatter,
|
|
|
}: UseChartSamplesProps) {
|
|
|
const theme = useTheme();
|
|
|
|
|
@@ -188,10 +189,14 @@ export function useChartSamples({
|
|
|
},
|
|
|
valueFormatter: (_, label?: string) => {
|
|
|
const sample = samples[label ?? ''];
|
|
|
- return getDuration(sample.duration / 1000, 2, true);
|
|
|
+ const yValue = ((sample.min ?? 0) + (sample.max ?? 0)) / 2;
|
|
|
+ if (!valueFormatter) {
|
|
|
+ return yValue.toPrecision(5);
|
|
|
+ }
|
|
|
+ return valueFormatter(yValue);
|
|
|
},
|
|
|
};
|
|
|
- }, [samples]);
|
|
|
+ }, [samples, valueFormatter]);
|
|
|
|
|
|
return {
|
|
|
handleClick,
|