Public
Edited
Aug 7, 2023
Insert cell
Insert cell
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof confirm = Inputs.button("OK", {label: "Weiter?"})
Insert cell
confirm ? document.getElementById("mySearch").value : md`Awaiting confirmation…`
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Inputs.table(ZielwertberechnungEW)
Insert cell
// Inputs.table(ZielwertberechnungEW)
Insert cell
Insert cell
zielwertberechnung_gols_bezirk = FileAttachment("Zielwertberechnung_Gols_Bezirk@1.xlsx").xlsx()
Insert cell
Zielwertberechnung_Gols_Bezirk = zielwertberechnung_gols_bezirk.sheet(0, { headers: true})
Insert cell
Insert cell
Zielwertberechnung = zielwertberechnung.sheet(0, { headers: true})
Insert cell
zielwertberechnung = FileAttachment("P23_TWh@3.xlsx").xlsx()
Insert cell
Insert cell
function getDatasettobarchart(name) { // get the column
{return Gols2}
}
Insert cell
ZielwertberechnungEW = zielwertberechnungew.sheet(0, { headers: true})
Insert cell
zielwertberechnungew = FileAttachment("ZielwertberechnungEW@3.xlsx").xlsx()
Insert cell
function getDatasetEW(name) { // get the column
{return ZielwertberechnungEW}
}
Insert cell
ebenen = FileAttachment("Ebenen@11.xlsx").xlsx()
Insert cell
Ebenen = ebenen.sheet(0, { headers: true})
Insert cell
function getDatasetEbenen(name) { // get the column
{return Ebenen}
}
Insert cell
Inputs.table(Ebenen)
Insert cell
Insert cell
ebene = ({
keys: ["Gem", "Deckung_ZW", "BL", "AT"],
labels: ["Gemeindeebene", "Bezirksebene", "Bundeslandebene", "Österreich"]
})
Insert cell
Insert cell
// Copyright 2021 Observable, Inc.
// Released under the ISC license.
// https://observablehq.com/@d3/choropleth
function Choropleth(data, {
id = d => d.ISO, // given d in data, returns the feature id
value, // given d in data, returns the quantitative value
title, // given a feature f and possibly a datum d, returns the hover text
format, // optional format specifier for the title
// scale = d3.scaleSequential, // type of color scale
// scale = d3.scaleQuantize,
scale = d3.scaleSequentialSqrt, // type of color scale
domain, // [min, max] values; input of color scale
range = d3.interpolateBlues, // output of color scale
width, // outer width, in pixels
height, // outer height, in pixels
projection, // a D3 projection; null for pre-projected geometry
features, // a GeoJSON feature collection
featureId, // given a feature, returns its id
borders, // a GeoJSON object for stroking borders
outline = projection && projection.rotate ? {type: "Sphere"} : null, // a GeoJSON object for the background
unknown = "grey", // fill color for missing data
fill = "white", // fill color for outline
stroke = "#grey",//"#E26F99", // stroke color for borders
strokeLinecap = "round", // stroke line cap for borders
strokeLinejoin = "round", // stroke line join for borders
strokeWidth = 0.15, // stroke width for borders
strokeOpacity = 1, // stroke opacity for borders
backgroundColor = "#454545",
landColor = "#444444",
landStroke = "#000000",
markerColor = "#E26F99",
} = {}) {
// Compute values.
const N = d3.map(data, id); // one-dimensional array with all IDs
const V = d3.map(data, value).map(d => d == null ? NaN : +d); // one-dimensional array with all values
const Im = new d3.InternMap(N.map((id, i) => [id, i])); // 1dim map ISO string as key, and index i as result: Im("10101") = 0
const If = d3.map(features.features, featureId);
console.log(N)

// Compute default domains.
if (domain === undefined) domain = [d3.quantile(V,quantil[0]), d3.quantile(V, quantil[1])];//d3.extent(V);

// Construct scales.
const color = scale(domain, range);
if (color.unknown && unknown !== undefined) color.unknown(unknown);

// Compute titles.
if (title === undefined) {
format = color.tickFormat(100, format);
title = (d, i) => `${auswahl}\n${d.properties.name}\n${format(V[i])}`;
} else if (title !== null) {
const T = title;
const O = d3.map(data, d => d);
title = (f, i) => T(f, O[i]);
}

// Compute the default height. If an outline object is specified, scale the projection to fit
// the width, and then compute the corresponding height.
if (height === undefined) {
if (outline === undefined) {
height = width/2;
} else {
const [[x0, y0], [x1, y1]] = d3.geoPath(projection.fitWidth(width, outline)).bounds(outline);
const dy = Math.ceil(y1 - y0), l = Math.min(Math.ceil(x1 - x0), dy);
projection.scale(projection.scale() * (l - 1) / l).precision(0.2);
height = dy;
}
}

// Construct a path generator.
const path = d3.geoPath(projection);

const svg = d3.create("svg")
.attr("width", width)
.attr("height", height)
.attr("viewBox", [0, 0, width, height])
.attr("style", "width: 100%; height: 10%; height: intrinsic;");
if (outline != null) svg.append("path")
.attr("fill", fill)
.attr("stroke", "currentColor")
.attr("d", path(outline));
svg.append("rect")
.attr("width", width)
.attr("height", height)
.attr('fill', backgroundColor);
svg.append("g")
.selectAll("path")
.data(features.features)
.join("path")
.attr("fill", (d, i) => color(V[Im.get(If[i])]))
.attr("d", path)
.append("title")
.text((d, i) => title(d, Im.get(If[i])));
if (borders != null) svg.append("path")
.attr("pointer-events", "none")
.attr("fill", "none")
.attr("stroke", stroke)
.attr("stroke-linecap", strokeLinecap)
.attr("stroke-linejoin", strokeLinejoin)
.attr("stroke-width", strokeWidth)
.attr("stroke-opacity", strokeOpacity)
.attr("d", path(borders));

const key = Legend(color, { // https://observablehq.com/@d3/choropleth
title: auswahl+" ",
// tickSize: 6,
width: width*0.95,
hight: 100,
})
svg.append("g")
.attr("transform", "translate("+width/50+","+width/50+")")
.append(() => key);
return Object.assign(svg.node(), {scales: {color}});
}
Insert cell
// Copyright 2021 Observable, Inc.
// Released under the ISC license.
// https://observablehq.com/@d3/choropleth
function Choropleth2(data, {
id = d => d.ISO, // given d in data, returns the feature id
value, // given d in data, returns the quantitative value
title, // given a feature f and possibly a datum d, returns the hover text
format, // optional format specifier for the title
// scale = d3.scaleSequential, // type of color scale
scale = d3.scaleQuantize,
// scale = d3.scaleSequentialSqrt, // type of color scale
domain, // [min, max] values; input of color scale
range = d3.interpolateBlues, // output of color scale
width, // outer width, in pixels
height, // outer height, in pixels
projection, // a D3 projection; null for pre-projected geometry
features, // a GeoJSON feature collection
featureId, // given a feature, returns its id
borders, // a GeoJSON object for stroking borders
outline = projection && projection.rotate ? {type: "Sphere"} : null, // a GeoJSON object for the background
unknown = "grey", // fill color for missing data
fill = "white", // fill color for outline
stroke = "#grey",//"#E26F99", // stroke color for borders
strokeLinecap = "round", // stroke line cap for borders
strokeLinejoin = "round", // stroke line join for borders
strokeWidth = 0.15, // stroke width for borders
strokeOpacity = 1, // stroke opacity for borders
backgroundColor = "#454545",
landColor = "#444444",
landStroke = "#000000",
markerColor = "#E26F99",
} = {}) {
// Compute values.
const N = d3.map(data, id); // one-dimensional array with all IDs
const V = d3.map(data, value).map(d => d == null ? NaN : +d); // one-dimensional array with all values
const Im = new d3.InternMap(N.map((id, i) => [id, i])); // 1dim map ISO string as key, and index i as result: Im("10101") = 0
const If = d3.map(features.features, featureId);
console.log(N)

// Compute default domains.
if (domain === undefined) domain = [d3.quantile(V,quantil[0]), d3.quantile(V, quantil[1])];//d3.extent(V);

// Construct scales.
const color = scale(domain, range);
if (color.unknown && unknown !== undefined) color.unknown(unknown);

// Compute titles.
if (title === undefined) {
format = color.tickFormat(100, format);
title = (d, i) => `${auswahl2}\n${d.properties.name}\n${format(V[i])}`;
} else if (title !== null) {
const T = title;
const O = d3.map(data, d => d);
title = (f, i) => T(f, O[i]);
}

// Compute the default height. If an outline object is specified, scale the projection to fit
// the width, and then compute the corresponding height.
if (height === undefined) {
if (outline === undefined) {
height = width/2;
} else {
const [[x0, y0], [x1, y1]] = d3.geoPath(projection.fitWidth(width, outline)).bounds(outline);
const dy = Math.ceil(y1 - y0), l = Math.min(Math.ceil(x1 - x0), dy);
projection.scale(projection.scale() * (l - 1) / l).precision(0.2);
height = dy;
}
}

// Construct a path generator.
const path = d3.geoPath(projection);

const svg = d3.create("svg")
.attr("width", width)
.attr("height", height)
.attr("viewBox", [0, 0, width, height])
.attr("style", "width: 100%; height: 10%; height: intrinsic;");
if (outline != null) svg.append("path")
.attr("fill", fill)
.attr("stroke", "currentColor")
.attr("d", path(outline));
svg.append("rect")
.attr("width", width)
.attr("height", height)
.attr('fill', backgroundColor);
svg.append("g")
.selectAll("path")
.data(features.features)
.join("path")
.attr("fill", (d, i) => color(V[Im.get(If[i])]))
.attr("d", path)
.append("title")
.text((d, i) => title(d, Im.get(If[i])));
if (borders != null) svg.append("path")
.attr("pointer-events", "none")
.attr("fill", "none")
.attr("stroke", stroke)
.attr("stroke-linecap", strokeLinecap)
.attr("stroke-linejoin", strokeLinejoin)
.attr("stroke-width", strokeWidth)
.attr("stroke-opacity", strokeOpacity)
.attr("d", path(borders));

const key = Legend(color, { // https://observablehq.com/@d3/choropleth
title: auswahl2+" ",
// tickSize: 6,
width: width*0.95,
hight: 100,
})
svg.append("g")
.attr("transform", "translate("+width/50+","+width/50+")")
.append(() => key);
return Object.assign(svg.node(), {scales: {color}});
}
Insert cell
jszip = require("jszip@3/dist/jszip.min.js")
Insert cell
projection = d3.geoMercator()
.scale(2)
.translate([1-width / 0.8, height / 2])
Insert cell
height=600

Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
Insert cell
Insert cell
topo2 = FileAttachment("gemeinden_topo_ep.txt").json()
Insert cell
Insert cell
gemeinden = topojson.feature(topo2, topo2.objects.gemeinden)
Insert cell
gols2 = FileAttachment("Gols2@6.xlsx").xlsx()
Insert cell
Gols2 = gols2.sheet(0, { headers: true})
Insert cell
// Inputs.table(Gols2)
Insert cell
Insert cell
Insert cell
Insert cell
import { StackedBarChart } from "@d3/diverging-stacked-bar-chart"
Insert cell
Insert cell
G2 = require("@antv/g2@3")
Insert cell
https://observablehq.com/@d3/diverging-stacked-bar-chart
https://observablehq.com/@douglyuckling/diverging-stacked-bar-chart
https://observablehq.com/@pearmini/g2-bar-chart-groupedg2-stacked-bar-chart-diverging
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import {Legend} from "@d3/color-legend"
Insert cell
import {rangeSlider, themes} from '@mootari/range-slider'
Insert cell
gols25 = FileAttachment("Gols2@5.xlsx").xlsx()
Insert cell
Gols25 = gols25.sheet(1, { headers: true})
Insert cell
html`<style>p { max-width: 100%; }</style>`
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more