Skip to content

Commit c9fe334

Browse files
author
Niilo Keinänen
committed
Update examples
1 parent 0a75bc8 commit c9fe334

1 file changed

Lines changed: 28 additions & 15 deletions

File tree

src/index.js

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
window.lcjsSmallView = window.devicePixelRatio >= 2
2+
if (!window.__lcjsDebugOverlay) {
3+
window.__lcjsDebugOverlay = document.createElement('div')
4+
window.__lcjsDebugOverlay.style.cssText = 'position:fixed;top:10px;left:10px;background:rgba(0,0,0,0.7);color:#fff;padding:4px 8px;z-index:99999;font:12px monospace;pointer-events:none'
5+
const attach = () => { if (document.body && !window.__lcjsDebugOverlay.parentNode) document.body.appendChild(window.__lcjsDebugOverlay) }
6+
attach()
7+
setInterval(() => {
8+
attach()
9+
window.__lcjsDebugOverlay.textContent = window.innerWidth + 'x' + window.innerHeight + ' dpr=' + window.devicePixelRatio + ' small=' + window.lcjsSmallView
10+
}, 500)
11+
}
112
const lcjs = require('@lightningchart/lcjs')
213
const {
314
lightningChart,
@@ -46,19 +57,9 @@ const chart3D = lc
4657
},
4758
theme: (() => {
4859
const t = Themes[new URLSearchParams(window.location.search).get('theme') || 'darkGold'] || undefined
49-
const smallView = window.devicePixelRatio >= 2
50-
if (!window.__lcjsDebugOverlay) {
51-
window.__lcjsDebugOverlay = document.createElement('div')
52-
window.__lcjsDebugOverlay.style.cssText = 'position:fixed;top:0;left:0;background:rgba(0,0,0,0.7);color:#fff;padding:4px 8px;z-index:99999;font:12px monospace;pointer-events:none'
53-
if (document.body) document.body.appendChild(window.__lcjsDebugOverlay)
54-
setInterval(() => {
55-
if (!window.__lcjsDebugOverlay.parentNode && document.body) document.body.appendChild(window.__lcjsDebugOverlay)
56-
window.__lcjsDebugOverlay.textContent = window.innerWidth + 'x' + window.innerHeight + ' dpr=' + window.devicePixelRatio + ' small=' + (window.devicePixelRatio >= 2)
57-
}, 500)
58-
}
59-
return t && smallView ? lcjs.scaleTheme(t, 0.5) : t
60+
return t && window.lcjsSmallView ? lcjs.scaleTheme(t, 0.5) : t
6061
})(),
61-
textRenderer: window.devicePixelRatio >= 2 ? lcjs.htmlTextRenderer : undefined,
62+
textRenderer: window.lcjsSmallView ? lcjs.htmlTextRenderer : undefined,
6263
})
6364
.setTitle('3D view — select a point to update 2D slices')
6465
.setTitleMargin(0)
@@ -101,7 +102,11 @@ const chartWD = lc
101102
legend: {
102103
visible: false,
103104
},
104-
// theme: Themes.darkGold
105+
theme: (() => {
106+
const t = Themes[new URLSearchParams(window.location.search).get('theme') || 'darkGold'] || undefined
107+
return t && window.lcjsSmallView ? lcjs.scaleTheme(t, 0.5) : t
108+
})(),
109+
textRenderer: window.lcjsSmallView ? lcjs.htmlTextRenderer : undefined,
105110
})
106111
.setTitle('Width vs Depth')
107112
.setUserInteractions(undefined)
@@ -137,7 +142,11 @@ const chartWH = lc
137142
legend: {
138143
visible: false,
139144
},
140-
// theme: Themes.darkGold
145+
theme: (() => {
146+
const t = Themes[new URLSearchParams(window.location.search).get('theme') || 'darkGold'] || undefined
147+
return t && window.lcjsSmallView ? lcjs.scaleTheme(t, 0.5) : t
148+
})(),
149+
textRenderer: window.lcjsSmallView ? lcjs.htmlTextRenderer : undefined,
141150
})
142151
.setTitle('Width vs Height')
143152
.setUserInteractions(undefined)
@@ -173,7 +182,11 @@ const chartDH = lc
173182
legend: {
174183
visible: false,
175184
},
176-
// theme: Themes.darkGold
185+
theme: (() => {
186+
const t = Themes[new URLSearchParams(window.location.search).get('theme') || 'darkGold'] || undefined
187+
return t && window.lcjsSmallView ? lcjs.scaleTheme(t, 0.5) : t
188+
})(),
189+
textRenderer: window.lcjsSmallView ? lcjs.htmlTextRenderer : undefined,
177190
})
178191
.setTitle('Depth vs Height')
179192
.setUserInteractions(undefined)

0 commit comments

Comments
 (0)