Skip to content

Commit 4a6c145

Browse files
author
Niilo Keinänen
committed
Update examples
1 parent 134a5cf commit 4a6c145

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

src/index.js

Lines changed: 13 additions & 12 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
/*
213
* LightningChartJS example that showcases a simulation of daily temperature variations.
314
*/
@@ -15,19 +26,9 @@ const chart = lightningChart({
1526
.ChartXY({
1627
theme: (() => {
1728
const t = Themes[new URLSearchParams(window.location.search).get('theme') || 'darkGold'] || undefined
18-
const smallView = window.devicePixelRatio >= 2
19-
if (!window.__lcjsDebugOverlay) {
20-
window.__lcjsDebugOverlay = document.createElement('div')
21-
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'
22-
if (document.body) document.body.appendChild(window.__lcjsDebugOverlay)
23-
setInterval(() => {
24-
if (!window.__lcjsDebugOverlay.parentNode && document.body) document.body.appendChild(window.__lcjsDebugOverlay)
25-
window.__lcjsDebugOverlay.textContent = window.innerWidth + 'x' + window.innerHeight + ' dpr=' + window.devicePixelRatio + ' small=' + (window.devicePixelRatio >= 2)
26-
}, 500)
27-
}
28-
return t && smallView ? lcjs.scaleTheme(t, 0.5) : t
29+
return t && window.lcjsSmallView ? lcjs.scaleTheme(t, 0.5) : t
2930
})(),
30-
textRenderer: window.devicePixelRatio >= 2 ? lcjs.htmlTextRenderer : undefined,
31+
textRenderer: window.lcjsSmallView ? lcjs.htmlTextRenderer : undefined,
3132
})
3233
.setTitle('Daily temperature range, April 2019')
3334

0 commit comments

Comments
 (0)