Created
October 5, 2022 07:39
-
-
Save jakhog/7ac26de81f8edcbb06fe7f1896a55e33 to your computer and use it in GitHub Desktop.
Vega-Lite "container" size scrollbar bug - minimal example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="https://cdn.jsdelivr.net/npm/vega@5"></script> | |
<script src="https://cdn.jsdelivr.net/npm/vega-lite@5"></script> | |
<script src="https://cdn.jsdelivr.net/npm/vega-embed@6"></script> | |
<style> | |
#container { | |
width: 60%; | |
height: 400px; | |
border: 5px solid red; | |
} | |
#vis { | |
height: 100%; | |
width: 100%; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="container"> | |
<div id="vis"></div> | |
</div> | |
<button id="toggleScrollbar">Toggle Scrollbar</button> | |
<script type="text/javascript"> | |
const spec = { | |
$schema: "https://vega.github.io/schema/vega-lite/v5.json", | |
width: "container", | |
height: "container", | |
description: "Google's stock price over time.", | |
data: { url: "https://raw.githubusercontent.com/vega/vega/main/docs/data/stocks.csv" }, | |
transform: [{ filter: "datum.symbol==='GOOG'" }], | |
mark: "line", | |
encoding: { | |
x: { field: "date", type: "temporal" }, | |
y: { field: "price", type: "quantitative" } | |
} | |
}; | |
vegaEmbed("#vis", spec, { actions: false }); | |
document.getElementById("toggleScrollbar").addEventListener('click', () => { | |
const value = document.body.style.overflowY === 'scroll' ? 'initial' : 'scroll'; | |
document.body.style.overflowY = value; | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment