-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: split chart and table in charts
- Loading branch information
Showing
7 changed files
with
135 additions
and
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React from "react"; | ||
|
||
import { useSeriesGroupStyles } from "./SeriesGroupStyles"; | ||
import { useSortedColumns } from "./useSortColumn"; | ||
import SeriesRow, { type SeriesRowProps } from "./SeriesRow"; | ||
import SeriesRowHeaders from "./SeriesRowHeaders"; | ||
import { type SeriesHeaderProps } from "./SeriesHeader"; | ||
import Loader from "./Loader"; | ||
export type CardinalityTableProps = { | ||
rows: SeriesRowProps[]; | ||
sectionHeader: string; | ||
sectionHeaderName: string; | ||
theme: any; | ||
} & SeriesHeaderProps; | ||
|
||
const CardinalityTable: React.FC<CardinalityTableProps> = ({ | ||
rows, | ||
theme, | ||
sectionHeader, | ||
sectionHeaderName, | ||
}) => { | ||
const { seriesGroupStyles } = useSeriesGroupStyles(theme); | ||
|
||
const { sortedRows, handleSort } = useSortedColumns(rows); | ||
|
||
return ( | ||
<div className="c-table"> | ||
{rows && ( | ||
<SeriesRowHeaders | ||
handleSort={handleSort} | ||
headerName={sectionHeaderName} | ||
name={sectionHeader} | ||
theme={seriesGroupStyles} | ||
/> | ||
)} | ||
|
||
{sortedRows && sortedRows?.length > 0 ? ( | ||
sortedRows.map((row: SeriesRowProps, key: number) => ( | ||
<SeriesRow | ||
{...row} | ||
key={key} | ||
theme={seriesGroupStyles} | ||
hasShare={ | ||
sectionHeaderName !== "labelValueCountByLabelName" | ||
} | ||
/> | ||
)) | ||
) : ( | ||
<Loader /> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default CardinalityTable; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,44 @@ | ||
import React from 'react' | ||
|
||
import React from "react"; | ||
import { | ||
StyledTabs, | ||
StyledTab, | ||
} from "@ui/main/components/QueryItem/StyledTabs"; | ||
import { css, cx } from "@emotion/css"; | ||
export type SeriesHeaderProps = { | ||
title: string; | ||
theme: any; | ||
tabsValue?: number; | ||
onTabChange?: any; | ||
}; | ||
// here should be the tabs for table / chart view | ||
export const StyledTabsCont = (theme: any) => css` | ||
background: ${theme.WidgetBg}; | ||
.MuiTabs-root { | ||
height: 20px !important; | ||
min-height: 20px; | ||
} | ||
.MuiButtonBase-root { | ||
min-height: 0; | ||
} | ||
`; | ||
|
||
const SeriesHeader:React.FC<SeriesHeaderProps> = ({ title }: SeriesHeaderProps) => { | ||
return <div className="c-header">{title}</div>; | ||
const SeriesHeader: React.FC<SeriesHeaderProps> = ({ | ||
title, | ||
tabsValue, | ||
onTabChange, | ||
theme, | ||
}: SeriesHeaderProps) => { | ||
return ( | ||
<div className="c-header"> | ||
<div>{title}</div> | ||
<div className={cx(StyledTabsCont(theme))}> | ||
<StyledTabs value={tabsValue} onChange={onTabChange}> | ||
<StyledTab label="Table" /> | ||
<StyledTab label="Chart" /> | ||
</StyledTabs> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default SeriesHeader; |
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