-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref(insights): Refactor Resources page charts (#81976)
Makes two important changes: - Extract `DurationChart`, `ThroughputChart`, and `AssetSizeChart` components. These are re-used on the landing page and the asset details page. This also brings this module more in-line with how other insights are structured - use `useSpanMetricsSeries` instead of `useSpansQuery`. This is a better way to load data, since it returns `meta` and other good information. Again, better consistency with other Insights modules
- Loading branch information
Showing
5 changed files
with
152 additions
and
244 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
static/app/views/insights/browser/resources/components/charts/assetSizeChart.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import {tct} from 'sentry/locale'; | ||
import type {Series} from 'sentry/types/echarts'; | ||
import {formatBytesBase2} from 'sentry/utils/bytes/formatBytesBase2'; | ||
import getDynamicText from 'sentry/utils/getDynamicText'; | ||
import {DATA_TYPE} from 'sentry/views/insights/browser/resources/settings'; | ||
import {AVG_COLOR} from 'sentry/views/insights/colors'; | ||
import Chart, {ChartType} from 'sentry/views/insights/common/components/chart'; | ||
import ChartPanel from 'sentry/views/insights/common/components/chartPanel'; | ||
import {DataTitles} from 'sentry/views/insights/common/views/spans/types'; | ||
|
||
interface Props { | ||
isLoading: boolean; | ||
series: Series[]; | ||
error?: Error | null; | ||
} | ||
|
||
export function AssetSizeChart({series, isLoading}: Props) { | ||
return ( | ||
<ChartPanel title={tct('Average [dataType] Size', {dataType: DATA_TYPE})}> | ||
<Chart | ||
height={160} | ||
aggregateOutputFormat="size" | ||
data={series} | ||
loading={isLoading} | ||
chartColors={[AVG_COLOR]} | ||
type={ChartType.LINE} | ||
definedAxisTicks={4} | ||
tooltipFormatterOptions={{ | ||
valueFormatter: bytes => | ||
getDynamicText({ | ||
value: formatBytesBase2(bytes), | ||
fixed: 'xx KiB', | ||
}), | ||
nameFormatter: name => DataTitles[name], | ||
}} | ||
/> | ||
</ChartPanel> | ||
); | ||
} |
33 changes: 33 additions & 0 deletions
33
static/app/views/insights/browser/resources/components/charts/durationChart.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import type {Series} from 'sentry/types/echarts'; | ||
import {AVG_COLOR} from 'sentry/views/insights/colors'; | ||
import Chart, {ChartType} from 'sentry/views/insights/common/components/chart'; | ||
import ChartPanel from 'sentry/views/insights/common/components/chartPanel'; | ||
import {getDurationChartTitle} from 'sentry/views/insights/common/views/spans/types'; | ||
import {CHART_HEIGHT} from 'sentry/views/insights/database/settings'; | ||
|
||
interface Props { | ||
isLoading: boolean; | ||
series: Series[]; | ||
error?: Error | null; | ||
} | ||
|
||
export function DurationChart({series, isLoading, error}: Props) { | ||
return ( | ||
<ChartPanel title={getDurationChartTitle('resource')}> | ||
<Chart | ||
height={CHART_HEIGHT} | ||
grid={{ | ||
left: '0', | ||
right: '0', | ||
top: '8px', | ||
bottom: '0', | ||
}} | ||
data={series} | ||
loading={isLoading} | ||
error={error} | ||
chartColors={[AVG_COLOR]} | ||
type={ChartType.LINE} | ||
/> | ||
</ChartPanel> | ||
); | ||
} |
197 changes: 19 additions & 178 deletions
197
static/app/views/insights/browser/resources/components/charts/resourceLandingPageCharts.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.