diff --git a/packages/propel/src/charts/bar-chart/root.tsx b/packages/propel/src/charts/bar-chart/root.tsx index 57bde9b8c9f..abe936d5c71 100644 --- a/packages/propel/src/charts/bar-chart/root.tsx +++ b/packages/propel/src/charts/bar-chart/root.tsx @@ -56,7 +56,6 @@ export const BarChart = React.memo((props: T dataKey={bar.key} stackId={bar.stackId} opacity={!!activeLegend && activeLegend !== bar.key ? 0.1 : 1} - fill={bar.fill} shape={(shapeProps: any) => { const showTopBorderRadius = bar.showTopBorderRadius?.(shapeProps.dataKey, shapeProps.payload); const showBottomBorderRadius = bar.showBottomBorderRadius?.(shapeProps.dataKey, shapeProps.payload); @@ -64,6 +63,7 @@ export const BarChart = React.memo((props: T return ( = { export type TBarItem = { key: T; label: string; - fill: string; + fill: string | ((payload: any) => string); textClassName: string; showPercentage?: boolean; stackId: string; @@ -116,6 +116,7 @@ export type TPieChartProps = Pick< text?: string | number; }; tooltipLabel?: string | ((payload: any) => string); + customLegend?: (props: any) => React.ReactNode; }; export type TreeMapItem = { diff --git a/web/core/components/profile/overview/priority-distribution.tsx b/web/core/components/profile/overview/priority-distribution.tsx index 856f7259157..575e1561b7a 100644 --- a/web/core/components/profile/overview/priority-distribution.tsx +++ b/web/core/components/profile/overview/priority-distribution.tsx @@ -2,9 +2,10 @@ // ui import { useTranslation } from "@plane/i18n"; +import { BarChart } from "@plane/propel/charts/bar-chart"; import { IUserProfileData } from "@plane/types"; import { Loader, Card } from "@plane/ui"; -import { BarGraph, ProfileEmptyState } from "@/components/ui"; +import { ProfileEmptyState } from "@/components/ui"; // image import { capitalizeFirstLetter } from "@/helpers/string.helper"; import emptyBarGraph from "@/public/empty-state/empty_bar_graph.svg"; @@ -15,6 +16,14 @@ type Props = { userProfile: IUserProfileData | undefined; }; +const priorityColors = { + urgent: "#991b1b", + high: "#ef4444", + medium: "#f59e0b", + low: "#16a34a", + none: "#e5e5e5", +}; + export const ProfilePriorityDistribution: React.FC = ({ userProfile }) => { const { t } = useTranslation(); return ( @@ -23,50 +32,35 @@ export const ProfilePriorityDistribution: React.FC = ({ userProfile }) => {userProfile ? ( {userProfile.priority_distribution.length > 0 ? ( - ({ - priority: capitalizeFirstLetter(priority.priority ?? "None"), - value: priority.priority_count, + key: priority.priority ?? "None", + name: capitalizeFirstLetter(priority.priority ?? "None"), + count: priority.priority_count, }))} - height="300px" - indexBy="priority" - keys={["value"]} - borderRadius={4} - padding={0.7} - customYAxisTickValues={userProfile.priority_distribution.map((p) => p.priority_count)} - tooltip={(datum) => ( -
- - {datum.data.priority}: - {datum.value} -
- )} - colors={(datum) => { - if (datum.data.priority === "Urgent") return "#991b1b"; - else if (datum.data.priority === "High") return "#ef4444"; - else if (datum.data.priority === "Medium") return "#f59e0b"; - else if (datum.data.priority === "Low") return "#16a34a"; - else return "#e5e5e5"; - }} - theme={{ - axis: { - domain: { - line: { - stroke: "transparent", - }, - }, - }, - grid: { - line: { - stroke: "transparent", - }, + bars={[ + { + key: "count", + label: "Count", + stackId: "bar-one", + fill: (payload) => priorityColors[payload.key as keyof typeof priorityColors], + textClassName: "", + showPercentage: false, + showTopBorderRadius: () => true, + showBottomBorderRadius: () => true, }, + ]} + xAxis={{ + key: "name", + label: t("profile.stats.priority_distribution.priority"), + }} + yAxis={{ + key: "count", + label: "", }} + barSize={20} /> ) : (
diff --git a/web/core/components/profile/overview/state-distribution.tsx b/web/core/components/profile/overview/state-distribution.tsx index 5e9d0d2c777..2d95f146340 100644 --- a/web/core/components/profile/overview/state-distribution.tsx +++ b/web/core/components/profile/overview/state-distribution.tsx @@ -1,10 +1,13 @@ // plane imports import { STATE_GROUPS } from "@plane/constants"; import { useTranslation } from "@plane/i18n"; +import { PieChart } from "@plane/propel/charts/pie-chart"; import { IUserProfileData, IUserStateDistribution } from "@plane/types"; // ui import { Card } from "@plane/ui"; -import { ProfileEmptyState, PieGraph } from "@/components/ui"; +import { ProfileEmptyState } from "@/components/ui"; +// helpers +import { capitalizeFirstLetter } from "@/helpers/string.helper"; // image import stateGraph from "@/public/empty-state/state_graph.svg"; @@ -22,40 +25,36 @@ export const ProfileStateDistribution: React.FC = ({ stateDistribution, u

{t("profile.stats.state_distribution.title")}

{userProfile.state_distribution.length > 0 ? ( -
-
- ({ - id: group.state_group, - label: group.state_group, - value: group.state_count, - color: STATE_GROUPS[group.state_group]?.color ?? "rgb(var(--color-primary-100))", - })) ?? [] - } - height="250px" - innerRadius={0.6} - cornerRadius={5} - padAngle={2} - enableArcLabels - arcLabelsTextColor="#000000" - enableArcLinkLabels={false} - activeInnerRadiusOffset={5} - colors={(datum) => datum?.data?.color} - tooltip={(datum) => ( -
- {datum.datum.label} work items:{" "} - {datum.datum.value} -
- )} - margin={{ - top: 32, - right: 0, - bottom: 32, - left: 0, - }} - /> -
+
+ ({ + id: group.state_group, + key: group.state_group, + value: group.state_count, + name: capitalizeFirstLetter(group.state_group), + color: STATE_GROUPS[group.state_group]?.color, + })) ?? [] + } + cells={userProfile.state_distribution.map((group) => ({ + key: group.state_group, + fill: STATE_GROUPS[group.state_group]?.color, + }))} + showTooltip + tooltipLabel="Count" + paddingAngle={5} + cornerRadius={4} + innerRadius="50%" + showLabel={false} + />
{stateDistribution.map((group) => (