Skip to content

Commit

Permalink
fix(MetricChart): zero min value (#787)
Browse files Browse the repository at this point in the history
  • Loading branch information
artemmufazalov authored Apr 2, 2024
1 parent 9bcffd6 commit f767d00
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/components/MetricChart/MetricChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const prepareWidgetData = (
data: PreparedMetricsData,
options: ChartOptions = {},
): YagrWidgetData => {
const {dataType} = options;
const {dataType, scaleRange} = options;
const defaultDataFormatter = getDefaultDataFormatter(dataType);

const isDataEmpty = !data.metrics.length;
Expand Down Expand Up @@ -88,6 +88,8 @@ const prepareWidgetData = (
y: {
type: 'linear',
range: 'nice',
min: scaleRange?.min || 0,
max: scaleRange?.max,
},
},
axes: {
Expand Down
4 changes: 4 additions & 0 deletions src/components/MetricChart/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ export type ChartDataType = 'ms' | 'size' | 'percent';

export interface ChartOptions {
dataType?: ChartDataType;
scaleRange?: {
min?: number;
max?: number;
};
}

export type ChartDataStatus = 'loading' | 'success' | 'error';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export const cpuDashboardConfig: ChartConfig[] = [
metrics: pools.map(getPoolMetricConfig),
options: {
dataType: 'percent',
scaleRange: {
min: 0,
max: 1,
},
},
},
];

0 comments on commit f767d00

Please sign in to comment.