Improve readability of the code
This commit is contained in:
13
app.qmd
13
app.qmd
@@ -16,10 +16,6 @@ d3 = require("d3@7")
|
||||
|
||||
```{ojs}
|
||||
bsplineData = FileAttachment("basis_functions.csv").csv({ typed: true })
|
||||
|
||||
muValues = Array.from(new Set(bsplineData.map(d => d.mu))).sort((a, b) => a - b)
|
||||
minMu = Math.min(...muValues)
|
||||
maxMu = Math.max(...muValues)
|
||||
```
|
||||
|
||||
```{ojs}
|
||||
@@ -61,13 +57,15 @@ chart = {
|
||||
d.nonc === selectedNonc &&
|
||||
d.tailw === selectedTailw
|
||||
);
|
||||
const container = d3.create("div").style("margin-bottom", "20px");
|
||||
const container = d3.create("div")
|
||||
.style("max-width", "none")
|
||||
.style("width", "100%");;
|
||||
const controlsContainer = container.append("div")
|
||||
.style("display", "flex")
|
||||
.style("gap", "20px");
|
||||
// slider controls
|
||||
const sliders = [
|
||||
{ label: 'Mu', get: () => selectedMu, set: v => selectedMu = v, min: minMu, max: maxMu, step: 0.2 },
|
||||
{ label: 'Mu', get: () => selectedMu, set: v => selectedMu = v, min: 0.1, max: 0.9, step: 0.2 },
|
||||
{ label: 'Sigma', get: () => Math.log2(selectedSig), set: v => selectedSig = 2 ** v, min: -2, max: 2, step: 1 },
|
||||
{ label: 'Noncentrality', get: () => selectedNonc, set: v => selectedNonc = v, min: -4, max: 4, step: 2 },
|
||||
{ label: 'Tailweight', get: () => Math.log2(selectedTailw), set: v => selectedTailw = 2 ** v, min: -2, max: 2, step: 1 }
|
||||
@@ -94,8 +92,7 @@ chart = {
|
||||
const margin = {top: 40, right: 20, bottom: 40, left: 40};
|
||||
const innerWidth = width - margin.left - margin.right;
|
||||
const innerHeight = height - margin.top - margin.bottom;
|
||||
// Set container width to match SVG plot width
|
||||
container.style("max-width", "none").style("width", "100%");
|
||||
|
||||
// Set controls container width to match SVG plot width
|
||||
controlsContainer.style("max-width", "none").style("width", "100%");
|
||||
// Distribute each control evenly and make sliders full-width
|
||||
|
||||
Reference in New Issue
Block a user