Skip to content

Commit b190e24

Browse files
feat(MetricChart): add legend to some charts (#1893)
1 parent 4dd053d commit b190e24

File tree

6 files changed

+22
-24
lines changed

6 files changed

+22
-24
lines changed

package-lock.json

+8-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@bem-react/classname": "^1.6.0",
1414
"@ebay/nice-modal-react": "^1.2.13",
1515
"@gravity-ui/axios-wrapper": "^1.5.1",
16-
"@gravity-ui/chartkit": "^5.19.2",
16+
"@gravity-ui/chartkit": "^5.20.0",
1717
"@gravity-ui/components": "^3.13.2",
1818
"@gravity-ui/date-components": "^2.11.0",
1919
"@gravity-ui/date-utils": "^2.5.6",

src/components/MetricChart/MetricChart.tsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22

33
import ChartKit, {settings} from '@gravity-ui/chartkit';
4-
import type {YagrSeriesData, YagrWidgetData} from '@gravity-ui/chartkit/yagr';
4+
import type {YagrWidgetData} from '@gravity-ui/chartkit/yagr';
55
import {YagrPlugin} from '@gravity-ui/chartkit/yagr';
66

77
import {cn} from '../../utils/cn';
@@ -29,12 +29,12 @@ const prepareWidgetData = (
2929
data: PreparedMetricsData,
3030
options: ChartOptions = {},
3131
): YagrWidgetData => {
32-
const {dataType, scaleRange} = options;
32+
const {dataType, scaleRange, showLegend} = options;
3333
const defaultDataFormatter = getDefaultDataFormatter(dataType);
3434

3535
const isDataEmpty = !data.metrics.length;
3636

37-
const graphs: YagrSeriesData[] = data.metrics.map((metric, index) => {
37+
const graphs: YagrWidgetData['data']['graphs'] = data.metrics.map((metric, index) => {
3838
const lineColor = metric.color || colors[index];
3939
const color = colorToRGBA(lineColor, 0.1);
4040

@@ -91,6 +91,9 @@ const prepareWidgetData = (
9191
show: true,
9292
tracking: 'sticky',
9393
},
94+
legend: {
95+
show: showLegend,
96+
},
9497
},
9598
};
9699
};

src/components/MetricChart/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export interface ChartOptions {
3838
min?: number;
3939
max?: number;
4040
};
41+
showLegend?: boolean;
4142
}
4243

4344
export type ChartDataStatus = 'loading' | 'success' | 'error';

src/containers/Tenant/Diagnostics/TenantOverview/DefaultOverviewContent/defaultDashboardConfig.ts

+5-12
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,24 @@ export const defaultDashboardConfig: ChartConfig[] = [
1616
metrics: [
1717
{
1818
target: 'queries.latencies.p50',
19-
title: i18n('charts.transaction-latency', {
20-
percentile: 'p50',
21-
}),
19+
title: 'p50',
2220
},
2321
{
2422
target: 'queries.latencies.p75',
25-
title: i18n('charts.transaction-latency', {
26-
percentile: 'p75',
27-
}),
23+
title: 'p75',
2824
},
2925
{
3026
target: 'queries.latencies.p90',
31-
title: i18n('charts.transaction-latency', {
32-
percentile: 'p90',
33-
}),
27+
title: 'p90',
3428
},
3529
{
3630
target: 'queries.latencies.p99',
37-
title: i18n('charts.transaction-latency', {
38-
percentile: 'p99',
39-
}),
31+
title: 'p99',
4032
},
4133
],
4234
options: {
4335
dataType: 'ms',
36+
showLegend: true,
4437
},
4538
},
4639
];

src/containers/Tenant/Diagnostics/TenantOverview/TenantCpu/cpuDashboardConfig.ts

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const cpuDashboardConfig: ChartConfig[] = [
2222
min: 0,
2323
max: 1,
2424
},
25+
showLegend: true,
2526
},
2627
},
2728
];

0 commit comments

Comments
 (0)