Skip to content

Commit 005bb21

Browse files
authored
Merge pull request #920 from devtron-labs/feat/efficient-projects
feat: uat changes finops
2 parents f79a5bc + 597373a commit 005bb21

7 files changed

Lines changed: 36 additions & 4 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "1.20.5-pre-7",
3+
"version": "1.20.5-alpha-8",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Common/SegmentedBarChart/SegmentedBarChart.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const SegmentedBarChart: React.FC<SegmentedBarChartProps> = ({
3535
swapLegendAndBar = false,
3636
showAnimationOnBar = false,
3737
isLoading,
38-
size = ComponentSizeType.medium,
38+
size = ComponentSizeType.small,
3939
}) => {
4040
const entities = isLoading ? [FALLBACK_ENTITY] : userEntities
4141
const total = entities.reduce((sum, entity) => entity.value + sum, 0)

src/Common/SegmentedBarChart/utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ export const getBarHeightForSize = (size: ComponentSizeType) => {
44
switch (size) {
55
case ComponentSizeType.large:
66
return 'h-20'
7+
case ComponentSizeType.medium:
8+
return 'h-12'
79
case ComponentSizeType.xs:
810
return 'h-6'
911
default:

src/Shared/Components/Charts/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,3 +314,5 @@ export const CHART_CANVAS_BACKGROUND_COLORS: Record<AppThemeType, string> = {
314314
}
315315

316316
export const LINE_DASH = [6, 6]
317+
318+
export const MAX_BAR_THICKNESS = 96

src/Shared/Components/Charts/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,26 @@ export type TypeAndDatasetsType =
6969
*/
7070
datasets: SimpleDatasetForPie
7171
onChartClick?: OnChartClickHandler
72+
yScaleTickFormat?: never
7273
} & Never<XYAxisMax>)
7374
| ({
7475
type: 'line'
7576
datasets: SimpleDatasetForLineAndArea[]
7677
onChartClick?: never
78+
yScaleTickFormat?: (value: number) => string
7779
} & XYAxisMax)
7880
| ({
7981
type: 'area'
8082
datasets: SimpleDatasetForLineAndArea
8183
/* onChartClick is not applicable for area charts */
8284
onChartClick?: never
85+
yScaleTickFormat?: (value: number) => string
8386
} & XYAxisMax)
8487
| ({
8588
type: Exclude<ChartType, 'pie' | 'line' | 'area'>
8689
datasets: SimpleDataset[]
8790
onChartClick?: OnChartClickHandler
91+
yScaleTickFormat?: (value: number) => string
8892
} & XYAxisMax)
8993

9094
export type ChartProps = {

src/Shared/Components/Charts/utils.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
CHART_COLORS,
2121
CHART_GRID_LINES_COLORS,
2222
LINE_DASH,
23+
MAX_BAR_THICKNESS,
2324
} from './constants'
2425
import {
2526
ChartColorKey,
@@ -180,6 +181,7 @@ export const getDefaultOptions = ({
180181
yAxisMax,
181182
xScaleTitle,
182183
yScaleTitle,
184+
yScaleTickFormat,
183185
} = chartProps
184186
const baseOptions: ChartOptions = {
185187
responsive: true,
@@ -243,16 +245,28 @@ export const getDefaultOptions = ({
243245
},
244246
} satisfies ScaleOptions<'linear'>
245247

248+
const ticksWithCallback = {
249+
...commonScaleConfig.ticks,
250+
callback: (value) => yScaleTickFormat(Number(value)),
251+
} satisfies ScaleOptions<'linear'>['ticks']
252+
246253
const commonXScaleConfig = {
247254
...commonScaleConfig,
248255
max: xAxisMax,
249256
title: getScaleTickTitleConfig(xScaleTitle, appTheme),
257+
...(typeof yScaleTickFormat === 'function' && type === 'stackedBarHorizontal'
258+
? { ticks: ticksWithCallback }
259+
: {}),
250260
} satisfies ScaleOptions<'linear'>
251261

252262
const commonYScaleConfig = {
253263
...commonScaleConfig,
254264
max: yAxisMax,
255265
title: getScaleTickTitleConfig(yScaleTitle, appTheme),
266+
// for stackedBarHorizon
267+
...(typeof yScaleTickFormat === 'function' && type !== 'stackedBarHorizontal'
268+
? { ticks: ticksWithCallback }
269+
: {}),
256270
} satisfies ScaleOptions<'linear'>
257271

258272
switch (type) {
@@ -301,6 +315,11 @@ export const getDefaultOptions = ({
301315
beginAtZero: true,
302316
},
303317
},
318+
datasets: {
319+
bar: {
320+
maxBarThickness: MAX_BAR_THICKNESS,
321+
},
322+
},
304323
} satisfies ChartOptions<'bar'>
305324
case 'stackedBarHorizontal':
306325
return {
@@ -316,6 +335,11 @@ export const getDefaultOptions = ({
316335
stacked: true,
317336
},
318337
},
338+
datasets: {
339+
bar: {
340+
maxBarThickness: MAX_BAR_THICKNESS,
341+
},
342+
},
319343
} satisfies ChartOptions<'bar'>
320344
case 'pie':
321345
return {

0 commit comments

Comments
 (0)