Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

Move dashed effect from JS to CSS

Blue Mouse9efc98e03d1d
diff --git a/web/app/pages/Project/View/ViewProject.helpers.tsx b/web/app/pages/Project/View/ViewProject.helpers.tsx
index 6d237e5c7..82846bdc3 100644
--- a/web/app/pages/Project/View/ViewProject.helpers.tsx
+++ b/web/app/pages/Project/View/ViewProject.helpers.tsx
@@ -1835,57 +1835,6 @@ const getSettingsFunnels = (
inner: true,
},
},
- onrendered: function () {
- const chart = this as any
- if (!chart?.$?.bar?.bars) return
-
- try {
- const svg = chart.$.svg.node()
- if (!svg) return
-
- const ns = 'http://www.w3.org/2000/svg'
-
- let defs = svg.querySelector('defs')
- if (!defs) {
- defs = document.createElementNS(ns, 'defs')
- svg.insertBefore(defs, svg.firstChild)
- }
-
- if (!defs.querySelector('#funnel-dropoff-stripe')) {
- const pattern = document.createElementNS(ns, 'pattern')
- pattern.setAttribute('id', 'funnel-dropoff-stripe')
- pattern.setAttribute('patternUnits', 'userSpaceOnUse')
- pattern.setAttribute('width', '20')
- pattern.setAttribute('height', '20')
- pattern.setAttribute('patternTransform', 'rotate(-45)')
-
- const band1 = document.createElementNS(ns, 'rect')
- band1.setAttribute('width', '20')
- band1.setAttribute('height', '20')
- band1.style.fill = 'var(--funnel-stripe-1)'
- pattern.appendChild(band1)
-
- const band2 = document.createElementNS(ns, 'rect')
- band2.setAttribute('x', '0')
- band2.setAttribute('y', '0')
- band2.setAttribute('width', '10')
- band2.setAttribute('height', '20')
- band2.style.fill = 'var(--funnel-stripe-2)'
- pattern.appendChild(band2)
-
- defs.appendChild(pattern)
- }
-
- chart.$.bar.bars.each(function (this: SVGPathElement, d: any) {
- if (d?.id === 'dropoff') {
- this.style.fill = 'url(#funnel-dropoff-stripe)'
- this.style.stroke = 'none'
- }
- })
- } catch {
- // ignore
- }
- },
tooltip: {
contents: (items: any) => {
const { index = 0 } = items[0] || {}
diff --git a/web/app/pages/Project/tabs/Funnels/FunnelChart.tsx b/web/app/pages/Project/tabs/Funnels/FunnelChart.tsx
index f8a321f98..4e63d583f 100644
--- a/web/app/pages/Project/tabs/Funnels/FunnelChart.tsx
+++ b/web/app/pages/Project/tabs/Funnels/FunnelChart.tsx
@@ -49,12 +49,38 @@ export const FunnelChart = ({
)
return (
- <MainChart
- chartId='funnel-chart'
- options={options}
- dataNames={dataNames}
- className={cn('funnel-chart', className)}
- deps={deps}
- />
+ <>
+ <svg width={0} height={0} className='absolute'>
+ <defs>
+ <pattern
+ id='funnel-dropoff-stripe'
+ patternUnits='userSpaceOnUse'
+ width={20}
+ height={20}
+ patternTransform='rotate(-45)'
+ >
+ <rect
+ width={20}
+ height={20}
+ style={{ fill: 'var(--funnel-stripe-1)' }}
+ />
+ <rect
+ x={0}
+ y={0}
+ width={10}
+ height={20}
+ style={{ fill: 'var(--funnel-stripe-2)' }}
+ />
+ </pattern>
+ </defs>
+ </svg>
+ <MainChart
+ chartId='funnel-chart'
+ options={options}
+ dataNames={dataNames}
+ className={cn('funnel-chart', className)}
+ deps={deps}
+ />
+ </>
)
}
diff --git a/web/app/styles/ProjectViewStyle.css b/web/app/styles/ProjectViewStyle.css
index 2650c4c33..fef02a7b3 100644
--- a/web/app/styles/ProjectViewStyle.css
+++ b/web/app/styles/ProjectViewStyle.css
@@ -191,6 +191,11 @@ body.dark .bb-ygrid {
stroke-width: 0 !important;
}
+.funnel-chart .bb-target-dropoff .bb-bar {
+ fill: url(#funnel-dropoff-stripe) !important;
+ opacity: 0.8;
+}
+
.funnel-chart .bb-bar {
fill-opacity: 1 !important;
stroke: none !important;