Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/dev 4215h #1707

Merged
merged 8 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/chart/src/components/BrushChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,15 @@ const BrushChart = ({ xMax, yMax }: BrushChartProps) => {

const tooltipText = 'Drag edges to focus on a specific segment '
const textWidth = getTextWidth(tooltipText, `normal ${16 / 1.1}px sans-serif`)
const DASHBOARD_MARGIN = 50
const BRUSH_HEIGHT_MULTIPLIER = 1.5

const calculateGroupTop = (): number => {
return Number(yMax) + config.xAxis.axisBBox + brushheight * 1.5
if (dashboardConfig?.type === 'dashboard') {
return Number(yMax) + config.xAxis.axisBBox + brushheight * BRUSH_HEIGHT_MULTIPLIER + DASHBOARD_MARGIN
} else {
return Number(yMax) + config.xAxis.axisBBox + brushheight * BRUSH_HEIGHT_MULTIPLIER
}
}

const handleMouseOver = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ export const useEditorPermissions = () => {
}
}
const visHasBrushChart = () => {
return false
if (config.xAxis.type === 'categorical') return false
return ['Line', 'Bar', 'Area Chart', 'Combo'].includes(visualizationType) && orientation === 'vertical'
}
Expand Down
3 changes: 2 additions & 1 deletion packages/chart/src/components/Legend/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export const getMarginTop = (isBottomOrSmallViewport, config) => {
return '0px'
}
if (isBottomOrSmallViewport && config.brush?.active) {
return '35px'
const BRUSH_HEIGHT_MULTIPLIER = 1.5
return `${config.brush.height * BRUSH_HEIGHT_MULTIPLIER}px`
}
return '20px'
}
Expand Down
11 changes: 1 addition & 10 deletions packages/chart/src/components/LinearChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -823,16 +823,7 @@ const LinearChart = forwardRef<SVGAElement, LinearChartProps>(({ parentHeight, p
/>
)}
{/*Brush chart */}
{config.brush.active && config.xAxis.type !== 'categorical' && (
<BrushChart
xScaleBrush={xScaleBrush}
yScale={yScale}
xMax={xMax}
yMax={yMax}
xScale={xScale}
seriesScale={seriesScale}
/>
)}
{config.brush.active && config.xAxis.type !== 'categorical' && <BrushChart xMax={xMax} yMax={yMax} />}
{/* Line chart */}
{/* TODO: Make this just line or combo? */}
{!['Paired Bar', 'Box Plot', 'Area Chart', 'Scatter Plot', 'Deviation Bar', 'Forecasting', 'Bar'].includes(
Expand Down
2 changes: 1 addition & 1 deletion packages/chart/src/data/initial-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export default {
position: 'right'
},
brush: {
height: 25,
height: 45,
active: false
},
exclusions: {
Expand Down
5 changes: 5 additions & 0 deletions packages/chart/src/scss/DataTable.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
.data-table-container {
margin: 20px 0 0;

&.brush-active {
adamdoe marked this conversation as resolved.
Show resolved Hide resolved
margin: 80px 0 0;
}

width: 100%;
&.download-link-above {
margin: 0;
Expand Down
14 changes: 7 additions & 7 deletions packages/core/components/DataTable/DataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,17 +244,17 @@ const DataTable = (props: DataTableProps) => {
</MediaControls.Section>
)
}
const getClassNames = (): string => {
const isBrushActive = config?.brush?.active && config.legend.position !== 'bottom'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:
Consider organizing the class names in an array and returning the result. This can improve readability and maintainability:

const classes = []
if (logic) classes.push('class-name')
if (!logic) classes.filter(c => c !== 'class-name')
return classes.join(' ')

This approach makes the class logic easier to follow, especially when dealing with conditional class assignments.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

const downloadLinkClass = !config.table.showDownloadLinkBelow ? 'download-link-above' : ''

return `data-table-container ${isBrushActive ? 'brush-active' : ''} ${viewport} ${downloadLinkClass}`
}

return (
<ErrorBoundary component='DataTable'>
{!config.table.showDownloadLinkBelow && <TableMediaControls />}
<section
id={tabbingId.replace('#', '')}
className={`data-table-container ${viewport} ${
!config.table.showDownloadLinkBelow ? 'download-link-above' : ''
}`}
aria-label={accessibilityLabel}
>
<section id={tabbingId.replace('#', '')} className={getClassNames()} aria-label={accessibilityLabel}>
<SkipTo skipId={skipId} skipMessage='Skip Data Table' />
{config.table.collapsible !== false && (
<ExpandCollapse
Expand Down
Loading