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!

Better chart styling

Blue Mouse85200255dbb1
diff --git a/web/app/pages/Project/View/ViewProject.helpers.tsx b/web/app/pages/Project/View/ViewProject.helpers.tsx
index 61216e6da..383d4fcd7 100644
--- a/web/app/pages/Project/View/ViewProject.helpers.tsx
+++ b/web/app/pages/Project/View/ViewProject.helpers.tsx
@@ -1738,7 +1738,6 @@ const getSettingsFunnels = (
const svg = chart.$.svg.node()
if (!svg) return
- const isDark = document.documentElement.classList.contains('dark')
const ns = 'http://www.w3.org/2000/svg'
let defs = svg.querySelector('defs')
@@ -1747,31 +1746,30 @@ const getSettingsFunnels = (
svg.insertBefore(defs, svg.firstChild)
}
- const old = defs.querySelector('#funnel-dropoff-stripe')
- if (old) old.remove()
-
- 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.setAttribute('fill', isDark ? '#1e2340' : '#e2e4ef')
- 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.setAttribute('fill', isDark ? '#2a3058' : '#d8dbed')
- pattern.appendChild(band2)
-
- defs.appendChild(pattern)
+ 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') {
diff --git a/web/app/styles/ProjectViewStyle.css b/web/app/styles/ProjectViewStyle.css
index a534d9ce2..7c8e37db3 100644
--- a/web/app/styles/ProjectViewStyle.css
+++ b/web/app/styles/ProjectViewStyle.css
@@ -176,6 +176,16 @@ body.dark .bb-ygrid {
stroke: var(--color-blue-700) !important;
}
+:root {
+ --funnel-stripe-1: #e2e4ef;
+ --funnel-stripe-2: #d8dbed;
+}
+
+.dark {
+ --funnel-stripe-1: #1e2340;
+ --funnel-stripe-2: #2a3058;
+}
+
.bb-target-dropoff .bb-bar {
stroke: none !important;
stroke-width: 0 !important;