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

Add legend to followup chart #167

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 13 additions & 1 deletion components/defaultFunnelChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function findKeysFromData(data) {
}, [])
}

export const DefaultFunnelChart = ({ data, dataTestid }) => {
export const DefaultFunnelChart = ({ data, dataTestid, showLegend }) => {
const keys = findKeysFromData(data)

return (
Expand All @@ -23,6 +23,18 @@ export const DefaultFunnelChart = ({ data, dataTestid }) => {
data={data}
indexBy={xAxisKey}
keys={keys}
legends={
showLegend
? [
{
dataFrom: "keys",
anchor: "top-left",
direction: "column",
itemHeight: 20,
},
]
: []
}
groupMode="grouped"
margin={{ top: 15, right: 10, bottom: 150, left: 60 }}
padding={0.1}
Expand Down
6 changes: 5 additions & 1 deletion pages/funnel.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ function Funnel() {
<div className="funnel-chart">
<h2>Nombre d'emails et/ou sms récapitulatifs</h2>
{followupData && (
<DefaultFunnelChart data={followupData} dataTestid="funnel-email" />
<DefaultFunnelChart
data={followupData}
dataTestid="funnel-email"
showLegend
/>
)}
</div>

Expand Down
8 changes: 4 additions & 4 deletions services/funnelService.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ function formatFunnelData(data) {
followupData: [
{
label: "avec recontact",
Sms: data.followupWithOptinCountSms,
Email: data.followupWithOptinCountEmail,
"Sms uniq.": data.followupWithOptinCountSms,
"Email uniq.": data.followupWithOptinCountEmail,
"Email et Sms": data.followupWithOptinCountEmailAndSms,
},
{
label: "sans recontact",
Sms: data.followupWithoutOptinCountSms,
Email: data.followupWithoutOptinCountEmail,
"Sms uniq.": data.followupWithoutOptinCountSms,
"Email uniq.": data.followupWithoutOptinCountEmail,
"Email et Sms": data.followupWithoutOptinCountEmailAndSms,
},
],
Expand Down