Skip to content

Commit

Permalink
ui: fix in order for category
Browse files Browse the repository at this point in the history
  • Loading branch information
DimaAmega committed Aug 9, 2024
1 parent a614c37 commit b1e74a4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ interface BigGraphWidgetProps extends AdditionalGraphInfo {
const BigGraphWidgetContent: React.FunctionComponent<BigGraphWidgetProps> = (props) => {
const viewParams = useDashboardViewParams()
const isHistogram = props.data.some(({ type }) => type === 'histogram')
const isCastXaxisToCategory = viewParams?.isXaxisAsCategorical && !isHistogram

const xaxisOptionsOverride = isCastXaxisToCategory
? ({ type: 'category', categoryorder: 'category ascending' } as const)
: ({} as const)

return (
<div>
Expand All @@ -19,10 +24,7 @@ const BigGraphWidgetContent: React.FunctionComponent<BigGraphWidgetProps> = (pro
layout={{
...props.layout,
title: undefined,
xaxis: {
...props.layout?.xaxis,
type: viewParams?.isXaxisAsCategorical && !isHistogram ? 'category' : undefined
}
xaxis: { ...props.layout?.xaxis, ...xaxisOptionsOverride }
}}
config={{ responsive: true }}
style={{
Expand Down
10 changes: 6 additions & 4 deletions ui/packages/evidently-ui-lib/src/widgets/RichDataWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ const RichDataWidget: React.FunctionComponent<RichDataParams & { widgetSize: num
const [details, setDetails] = useState<boolean>(false)
const viewParams = useDashboardViewParams()
const isHistogram = props.graph?.data.some(({ type }) => type === 'histogram')
const isCastXaxisToCategory = viewParams?.isXaxisAsCategorical && !isHistogram

const xaxisOptionsOverride = isCastXaxisToCategory
? ({ type: 'category', categoryorder: 'category ascending' } as const)
: ({} as const)

return (
<React.Fragment>
Expand Down Expand Up @@ -66,10 +71,7 @@ const RichDataWidget: React.FunctionComponent<RichDataParams & { widgetSize: num
layout={{
...props.graph.layout,
title: undefined,
xaxis: {
...props.graph.layout?.xaxis,
type: viewParams?.isXaxisAsCategorical && !isHistogram ? 'category' : undefined
}
xaxis: { ...props.graph.layout?.xaxis, ...xaxisOptionsOverride }
}}
config={{ responsive: true }}
style={{
Expand Down

0 comments on commit b1e74a4

Please sign in to comment.