Skip to content

Commit

Permalink
Derive available journals from data
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiamersmann committed Feb 7, 2021
1 parent 20361a1 commit b13e323
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
{#if width < 600}
<Catch content={"width < 600"} />
{:else}
<SidePanel />
{#await loadData() then data}
<SidePanel {data} />
<Visualization {data} />
{/await}
<Tooltip />
Expand Down
4 changes: 3 additions & 1 deletion src/SidePanel.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<script>
import Legend from './components/Legend.svelte';
import SelectJournal from './components/SelectJournal.svelte';
export let data = [];
</script>

<div class="side-panel">
Expand All @@ -15,7 +17,7 @@
</p>

<Legend />
<SelectJournal />
<SelectJournal {data} />
</div>

<style>
Expand Down
25 changes: 22 additions & 3 deletions src/components/SelectJournal.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
<script>
import { descending, mean, groups } from 'd3-array';
import Select from 'svelte-select';
import SelectItem from './components/SelectItem.svelte';
import SelectItem from './SelectItem.svelte';
import { selectedJournal } from '../stores/selections';
export let data = [];
const capitalize = (s) => s.charAt(0).toUpperCase() + s.slice(1);
const journals = groups(data, (d) => d.journal)
.map(([, values]) => {
const journal = values[0].journal;
const impactFactor = mean(values, (d) => d.citedBy);
return {
value: journal,
label: `${capitalize(journal)} (${Math.round(impactFactor)})`,
impactFactor
};
})
.sort((a, b) => descending(a.impactFactor, b.impactFactor));
import { journals } from './inputs/constants';
import { selectedJournal } from './stores/selections';
selectedJournal.set(journals[0].value);
function handleSelect(event) {
selectedJournal.set(event.detail.value);
Expand Down
5 changes: 0 additions & 5 deletions src/inputs/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,3 @@ export const dataPath = 'data/sources.csv';

export const quantiles = [0, 0.9, 0.95, 0.99, 0.999];
export const tickStep = 500;

export const journals = [
{value: 'nature', label: 'Nature'},
{value: 'science', label: 'Science'},
];
4 changes: 1 addition & 3 deletions src/stores/selections.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { writable } from 'svelte/store';

import { journals } from '../inputs/constants';

export const selectedJournal = writable(journals[0].value);
export const selectedJournal = writable();
export const selectedStar = writable();

export const activeQuantile = writable(1);
Expand Down

0 comments on commit b13e323

Please sign in to comment.