Skip to content

Commit

Permalink
Merge branch 'feat/pod-label' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
paulseamer committed May 17, 2024
2 parents 272af27 + 4a68dc5 commit 06e4e34
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
3 changes: 2 additions & 1 deletion app/src/main.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { select } from 'd3-selection';
import { initLookup } from './shared/lookup.mjs';
import { initVariants } from './shared/variants.mjs';
import { initPods } from './shared/pods.mjs';
import { initPyramid } from './pyramid/index.mjs';
import { initLineCharts } from './line-charts/index.mjs';
import { initHistograms } from './histograms/index.mjs';


async function main() {
// Asynchronously load the json files from root of data/ into memory
await Promise.all([initLookup(), initVariants()]);
await Promise.all([initLookup(), initVariants(), initPods()]);
// Initialise our charts in order
initPyramid(select('#pyramid'));
initLineCharts(select('#line-charts'));
Expand Down
12 changes: 6 additions & 6 deletions app/src/shared/controls.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ticks as d3Ticks } from 'd3-array';
import { scaleLinear } from 'd3-scale';
import { lookup } from './lookup.mjs';
import { variants } from '../shared/variants.mjs';
import { pods } from '../shared/pods.mjs';
import { constants } from './constants.mjs';


Expand Down Expand Up @@ -192,16 +193,15 @@ function initAreaSelect(container, setState) {


function initPodSelect(dropdown, setState) {
const pods = ['aae', 'apc', 'opc'];
const callback = evt => setState({ 'pod': evt.target.value });
dropdown.on('change', callback);
const podSelect = dropdown.on('change', callback);

dropdown.selectAll('option')
.data(pods)
podSelect.selectAll('option')
.data(Array.from(Object.entries(pods)))
.enter()
.append('option')
.attr('value', d => d)
.text(d => d);
.attr('value', d => d[0])
.text(d => d[1].name);

return dropdown.node().value;
}
Expand Down
12 changes: 12 additions & 0 deletions app/src/shared/pods.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Module for loading pod data
import { load } from './load.mjs';

let pods;


async function initPods() {
[pods] = await Promise.all([load('pods')]);
}


export { pods, initPods };

0 comments on commit 06e4e34

Please sign in to comment.