funnel
This commit is contained in:
@@ -363,6 +363,7 @@ export function Chart({ data }: { data: RouterOutputs['chart']['funnel'] }) {
|
|||||||
const rechartData = useRechartData(data);
|
const rechartData = useRechartData(data);
|
||||||
const xAxisProps = useXAxisProps();
|
const xAxisProps = useXAxisProps();
|
||||||
const yAxisProps = useYAxisProps();
|
const yAxisProps = useYAxisProps();
|
||||||
|
const hasBreakdowns = data.current.length > 1;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TooltipProvider data={data.current}>
|
<TooltipProvider data={data.current}>
|
||||||
@@ -391,19 +392,37 @@ export function Chart({ data }: { data: RouterOutputs['chart']['funnel'] }) {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<YAxis {...yAxisProps} />
|
<YAxis {...yAxisProps} />
|
||||||
<Bar
|
{hasBreakdowns ? (
|
||||||
data={rechartData}
|
data.current.map((item, breakdownIndex) => (
|
||||||
dataKey="step:percent:0"
|
<Bar
|
||||||
shape={<BarShapeProps />}
|
key={`step:percent:${item.id}`}
|
||||||
>
|
dataKey={`step:percent:${breakdownIndex}`}
|
||||||
{rechartData.map((item, index) => (
|
shape={<BarShapeProps />}
|
||||||
<Cell
|
>
|
||||||
key={item.name}
|
{rechartData.map((item, stepIndex) => (
|
||||||
fill={getChartTranslucentColor(index)}
|
<Cell
|
||||||
stroke={getChartColor(index)}
|
key={`${item.name}-${breakdownIndex}`}
|
||||||
/>
|
fill={getChartTranslucentColor(breakdownIndex)}
|
||||||
))}
|
stroke={getChartColor(breakdownIndex)}
|
||||||
</Bar>
|
/>
|
||||||
|
))}
|
||||||
|
</Bar>
|
||||||
|
))
|
||||||
|
) : (
|
||||||
|
<Bar
|
||||||
|
data={rechartData}
|
||||||
|
dataKey="step:percent:0"
|
||||||
|
shape={<BarShapeProps />}
|
||||||
|
>
|
||||||
|
{rechartData.map((item, index) => (
|
||||||
|
<Cell
|
||||||
|
key={item.name}
|
||||||
|
fill={getChartTranslucentColor(index)}
|
||||||
|
stroke={getChartColor(index)}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</Bar>
|
||||||
|
)}
|
||||||
<Tooltip />
|
<Tooltip />
|
||||||
</BarChart>
|
</BarChart>
|
||||||
</ResponsiveContainer>
|
</ResponsiveContainer>
|
||||||
@@ -412,8 +431,6 @@ export function Chart({ data }: { data: RouterOutputs['chart']['funnel'] }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
type Hej = RouterOutputs['chart']['funnel']['current'];
|
|
||||||
|
|
||||||
const { Tooltip, TooltipProvider } = createChartTooltip<
|
const { Tooltip, TooltipProvider } = createChartTooltip<
|
||||||
RechartData,
|
RechartData,
|
||||||
{
|
{
|
||||||
@@ -435,7 +452,7 @@ const { Tooltip, TooltipProvider } = createChartTooltip<
|
|||||||
<div className="flex justify-between gap-8 text-muted-foreground">
|
<div className="flex justify-between gap-8 text-muted-foreground">
|
||||||
<div>{data.name}</div>
|
<div>{data.name}</div>
|
||||||
</div>
|
</div>
|
||||||
{variants.map((key) => {
|
{variants.map((key, breakdownIndex) => {
|
||||||
const variant = data[key];
|
const variant = data[key];
|
||||||
const prevVariant = data[`prev_${key}`];
|
const prevVariant = data[`prev_${key}`];
|
||||||
if (!variant?.step) {
|
if (!variant?.step) {
|
||||||
@@ -445,7 +462,11 @@ const { Tooltip, TooltipProvider } = createChartTooltip<
|
|||||||
<div className="row gap-2" key={key}>
|
<div className="row gap-2" key={key}>
|
||||||
<div
|
<div
|
||||||
className="w-[3px] rounded-full"
|
className="w-[3px] rounded-full"
|
||||||
style={{ background: getChartColor(index) }}
|
style={{
|
||||||
|
background: getChartColor(
|
||||||
|
variants.length > 1 ? breakdownIndex : index,
|
||||||
|
),
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<div className="col flex-1 gap-1">
|
<div className="col flex-1 gap-1">
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import { ModalHeader } from './Modal/Container';
|
|||||||
import { ScrollableModal, useScrollableModal } from './Modal/scrollable-modal';
|
import { ScrollableModal, useScrollableModal } from './Modal/scrollable-modal';
|
||||||
|
|
||||||
const ProfileItem = ({ profile }: { profile: any }) => {
|
const ProfileItem = ({ profile }: { profile: any }) => {
|
||||||
console.log('ProfileItem', profile.id);
|
|
||||||
return (
|
return (
|
||||||
<ProjectLink
|
<ProjectLink
|
||||||
preload={false}
|
preload={false}
|
||||||
|
|||||||
Reference in New Issue
Block a user