Skip to content
Snippets Groups Projects
Commit 4c091545 authored by ericj's avatar ericj
Browse files

cleanup

parent 55565c09
Branches master
No related tags found
No related merge requests found
...@@ -7,8 +7,8 @@ loadData().then(([schengenData1, countryData]) => { ...@@ -7,8 +7,8 @@ loadData().then(([schengenData1, countryData]) => {
const countryMap = {}; const countryMap = {};
countryData.forEach(d => { countryData.forEach(d => {
countryMap[d.Country] = { countryMap[d.Country] = {
gdp: +d.GDP.replace(/[$,]/g, ''), // Parse GDP gdp: +d.GDP.replace(/[$,]/g, ''),
population: +d.Population.replace(/[$,]/g, '') // Parse population population: +d.Population.replace(/[$,]/g, '')
}; };
}); });
...@@ -22,7 +22,6 @@ loadData().then(([schengenData1, countryData]) => { ...@@ -22,7 +22,6 @@ loadData().then(([schengenData1, countryData]) => {
let sizeDim; let sizeDim;
let opacityDim; let opacityDim;
// Append SVG container
const svg = addSvg("#bubble-container", 0, 115) const svg = addSvg("#bubble-container", 0, 115)
function updateBubble() { function updateBubble() {
...@@ -62,7 +61,6 @@ loadData().then(([schengenData1, countryData]) => { ...@@ -62,7 +61,6 @@ loadData().then(([schengenData1, countryData]) => {
.domain([0, d3.max(schengenData, d => d["opacity"] || 1)]) .domain([0, d3.max(schengenData, d => d["opacity"] || 1)])
.range([0.1, 1]); .range([0.1, 1]);
//const colorScale = d3.scaleOrdinal(d3.schemeCategory10);
const colorScale = d3 const colorScale = d3
.scaleOrdinal() .scaleOrdinal()
.domain(schengenData) .domain(schengenData)
...@@ -70,7 +68,6 @@ loadData().then(([schengenData1, countryData]) => { ...@@ -70,7 +68,6 @@ loadData().then(([schengenData1, countryData]) => {
svg.selectAll("*").remove(); svg.selectAll("*").remove();
// Add X axis
svg.append("g") svg.append("g")
.attr("transform", `translate(0,${height-margin.top-margin.bottom})`) .attr("transform", `translate(0,${height-margin.top-margin.bottom})`)
.call(d3.axisBottom(xScale).ticks(10, ".1s")) .call(d3.axisBottom(xScale).ticks(10, ".1s"))
...@@ -80,7 +77,6 @@ loadData().then(([schengenData1, countryData]) => { ...@@ -80,7 +77,6 @@ loadData().then(([schengenData1, countryData]) => {
.text("GDP") .text("GDP")
.style("fill", "black"); .style("fill", "black");
// Add Y axis
svg.append("g") svg.append("g")
.call(d3.axisLeft(yScale)) .call(d3.axisLeft(yScale))
.append("text") .append("text")
...@@ -91,7 +87,6 @@ loadData().then(([schengenData1, countryData]) => { ...@@ -91,7 +87,6 @@ loadData().then(([schengenData1, countryData]) => {
.text("Population") .text("Population")
.style("fill", "black"); .style("fill", "black");
// Draw bubbles
const tooltip = d3.select("body") const tooltip = d3.select("body")
.append("div") .append("div")
.attr("class", "tooltip") .attr("class", "tooltip")
......
import {getDimensions, initNavigation, loadData} from "./lib.js"; import {getDimensions, initNavigation, loadData} from "./lib.js";
window.addEventListener('load', () => { window.addEventListener('load', () => {
// navigation
initNavigation() initNavigation()
//fill dropdowns with dimensions
//data filter buttons
const selectors = Array.from(document.querySelectorAll('.visa-type-autofill')); const selectors = Array.from(document.querySelectorAll('.visa-type-autofill'));
console.log(selectors); console.log(selectors);
loadData().then(([schengenCsv, countryCsv])=>{ loadData().then(([schengenCsv, countryCsv])=>{
......
import {addSvg, width, height as _height, margin, colors, getDimensions, loadData} from "./lib.js"; import {addSvg, width, height as _height, margin, getDimensions, loadData} from "./lib.js";
const height = _height-120 const height = _height-120
...@@ -6,20 +6,16 @@ const svg = addSvg("#parallel-coordinates-container", 0, 60) ...@@ -6,20 +6,16 @@ const svg = addSvg("#parallel-coordinates-container", 0, 60)
const loadingIndicator = d3.select("#loading"); const loadingIndicator = d3.select("#loading");
// Show loading indicator
function showLoading() { function showLoading() {
loadingIndicator.style("display", "block"); loadingIndicator.style("display", "block");
} }
// Hide loading indicator
function hideLoading() { function hideLoading() {
loadingIndicator.style("display", "none"); loadingIndicator.style("display", "none");
} }
// Load data
showLoading(); showLoading();
loadData().then(([data,_]) => { loadData().then(([data,_]) => {
// Parse data
data.forEach(d => { data.forEach(d => {
for (const key in d) { for (const key in d) {
if (!isNaN(+d[key])) { if (!isNaN(+d[key])) {
...@@ -48,13 +44,11 @@ loadData().then(([data,_]) => { ...@@ -48,13 +44,11 @@ loadData().then(([data,_]) => {
const lineGenerator = d3.line() const lineGenerator = d3.line()
.defined(d => !isNaN(d[1])) .defined(d => !isNaN(d[1]))
.x(d => xScale(d[0])) .x(d => xScale(d[0]))
.y(d => yScales[d[0]](d[1] + epsilon)); // epsilon to avoid log(0) .y(d => yScales[d[0]](d[1] + epsilon));
// Group data by state
const groupedData = d3.group(data, d => d["Schengen State"]); const groupedData = d3.group(data, d => d["Schengen State"]);
const states = Array.from(groupedData.keys()); const states = Array.from(groupedData.keys());
// Populate dropdown
const dropdown = d3.select("#state-dropdown"); const dropdown = d3.select("#state-dropdown");
dropdown.selectAll("option") dropdown.selectAll("option")
.data(states) .data(states)
...@@ -63,14 +57,12 @@ loadData().then(([data,_]) => { ...@@ -63,14 +57,12 @@ loadData().then(([data,_]) => {
.attr("value", d => d) .attr("value", d => d)
.text(d => d); .text(d => d);
// Update plot function
function updatePlot(state) { function updatePlot(state) {
const filteredData = state ? groupedData.get(state) : data; const filteredData = state ? groupedData.get(state) : data;
const paths = svg.selectAll(".data-line") const paths = svg.selectAll(".data-line")
.data(filteredData); .data(filteredData);
// Enter and update paths
paths.enter() paths.enter()
.append("path") .append("path")
.attr("class", "data-line") .attr("class", "data-line")
...@@ -81,27 +73,23 @@ loadData().then(([data,_]) => { ...@@ -81,27 +73,23 @@ loadData().then(([data,_]) => {
.style("opacity", 0.05) .style("opacity", 0.05)
.attr("fill", "none"); .attr("fill", "none");
// Remove old paths
paths.exit().remove(); paths.exit().remove();
} }
// Initialize with full dataset // Initialize with full dataset
updatePlot(null); updatePlot(null);
// Draw axes with labels
dimensions.forEach(dim => { dimensions.forEach(dim => {
svg.append("g") svg.append("g")
.attr("transform", `translate(${xScale(dim)},0)`) .attr("transform", `translate(${xScale(dim)},0)`)
.call(d3.axisLeft(yScales[dim])); .call(d3.axisLeft(yScales[dim]));
// Use foreignObject for axis labels
svg.append("foreignObject") svg.append("foreignObject")
.attr("x", xScale(dim) - 30) // Adjust x position .attr("x", xScale(dim) - 30)
.attr("y", height - margin.top - margin.bottom-20) // Adjust y position .attr("y", height - margin.top - margin.bottom-20)
.attr("width", 60) // Set width for wrapping .attr("width", 60)
.attr("height", 140) // Set height for the container .attr("height", 140)
.append("xhtml:div") // Add a div for HTML content .append("xhtml:div")
.style("font-size", "12px") .style("font-size", "12px")
.style("text-align", "center") .style("text-align", "center")
.style("word-wrap", "break-word") .style("word-wrap", "break-word")
......
...@@ -78,6 +78,5 @@ loadData().then(([data,_]) => { ...@@ -78,6 +78,5 @@ loadData().then(([data,_]) => {
updateGraph(type); updateGraph(type);
}); });
// Initialize with "Total uniform visas issued (including MEV)"
updateGraph("Total uniform visas issued (including MEV)"); updateGraph("Total uniform visas issued (including MEV)");
}); });
\ No newline at end of file
import {addSvg, width, height, margin, loadData, navigate} from "./lib.js"; import {addSvg, width, height, loadData, navigate} from "./lib.js";
let currentData; let currentData;
...@@ -58,11 +58,10 @@ function updateTree(filterKey) { ...@@ -58,11 +58,10 @@ function updateTree(filterKey) {
return match ? +match[1] : 0; return match ? +match[1] : 0;
}); });
return d3.scaleSqrt() return d3.scaleSqrt()
.domain([0, d3.max(values)]) // Min/Max der Werte .domain([0, d3.max(values)])
.range([5, 40]); // Knotenradius .range([5, 40]);
} }
// Erstelle die Skalierung basierend auf der aktuellen Ebene
const sizeScale = createSizeScale(root.descendants()); const sizeScale = createSizeScale(root.descendants());
function removeChildren(child) { function removeChildren(child) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment