-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(Core UI): ♻️ Organize charts and custom cell fodlers
- Loading branch information
Showing
44 changed files
with
125 additions
and
144 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
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
This file was deleted.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...ents/SKSanckeyChart/SkSankey.constants.ts → ...arts/SKSanckeyChart/SkSankey.constants.ts
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
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
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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...mponents/SkChartArea/SkChartArea.utils.ts → ...SkCharts/SkChartArea/SkChartArea.utils.ts
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
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
8 changes: 8 additions & 0 deletions
8
src/core/components/SkCharts/SkChartPie/SkChartPie.constants.ts
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,8 @@ | ||
const CHART_CONFIG = { | ||
LAYOUT: { | ||
DEFAULT_PADDING: { bottom: 40, left: 40, right: 40, top: 40 }, | ||
DEFAULT_HEIGHT: 300 | ||
} | ||
}; | ||
|
||
export { CHART_CONFIG }; |
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,59 @@ | ||
import { FC } from 'react'; | ||
|
||
import { ChartDonut, ChartDonutProps, ChartTooltip } from '@patternfly/react-charts/victory'; | ||
|
||
import { CHART_CONFIG } from './SkChartPie.constants'; | ||
import { useChartDimensions } from '../../../../hooks/useChartDimensions'; | ||
import { formatToDecimalPlacesIfCents } from '../../../utils/formatToDecimalPlacesIfCents'; | ||
|
||
export interface SkChartPieProps extends ChartDonutProps { | ||
data: { x: string; y: number }[]; | ||
format?: Function; | ||
padding?: Record<string, string>; | ||
} | ||
|
||
const SkChartPie: FC<SkChartPieProps> = function ({ | ||
data, | ||
legendOrientation = 'horizontal', | ||
legendPosition = 'bottom', | ||
format = (y: number) => y, | ||
height = CHART_CONFIG.LAYOUT.DEFAULT_HEIGHT, | ||
padding = CHART_CONFIG.LAYOUT.DEFAULT_PADDING, | ||
...props | ||
}) { | ||
const { chartWidth, chartContainerRef } = useChartDimensions(); | ||
|
||
const total = data.reduce((acc, { y }) => acc + y, 0); | ||
const labels = data.map(({ x, y }) => `${x}: ${format(y)}`); | ||
const legendData = data.map(({ x, y }) => ({ | ||
name: `${x}: ${total ? formatToDecimalPlacesIfCents((y * 100) / total, 1) : 0}%` | ||
})); | ||
|
||
return ( | ||
<div ref={chartContainerRef} style={{ width: `100%`, height: `${height}px` }}> | ||
<ChartDonut | ||
width={chartWidth} | ||
height={height} | ||
legendAllowWrap | ||
title={format(total)} | ||
data={data} | ||
labels={labels} | ||
labelComponent={ | ||
<ChartTooltip | ||
cornerRadius={5} | ||
flyoutStyle={{ | ||
fillOpacity: 0.75 | ||
}} | ||
/> | ||
} | ||
legendOrientation={legendOrientation} | ||
legendPosition={legendPosition} | ||
legendData={legendData} | ||
padding={padding} | ||
{...props} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default SkChartPie; |
2 changes: 1 addition & 1 deletion
2
src/core/components/SKDurationCell/index.tsx → ...le/SkCustomCells/SKDurationCell/index.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
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
4 changes: 2 additions & 2 deletions
4
src/core/components/SkLinkCell/index.tsx → ...kTable/SkCustomCells/SkLinkCell/index.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
File renamed without changes.
File renamed without changes.
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
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
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.