Skip to content

Commit

Permalink
deploy: 4a8914e
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephBond committed Nov 8, 2023
1 parent 441f4a8 commit 8c02869
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 32 deletions.
56 changes: 38 additions & 18 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -30679,9 +30679,9 @@
svg.call(tip);
const x2 = band().range([0, width]).domain(data.map((d) => d.x._1)).padding(0.2);
svg.append("g").attr("transform", "translate(0," + height + ")").call(axisBottom(x2)).selectAll("text").style("text-anchor", "middle");
const nearest = 100, y_max = Math.ceil(Math.max(...data.map((d) => d.y._1)) / nearest) * nearest;
const nearest = 1, y_max = Math.ceil(Math.max(...data.map((d) => d.y._1)) / nearest) * nearest;
const y2 = linear2().domain([0, y_max]).range([height, 0]);
const tickEvery = nearest / 2, ticks = Array.from(Array(y_max / tickEvery + 1).keys()).map((n) => n * tickEvery);
const tickEvery = y_max / 4, ticks = Array.from(Array(y_max / tickEvery + 1).keys()).map((n) => n * tickEvery);
const yAxis = axisLeft(y2).tickValues(ticks);
svg.append("g").call(yAxis);
const barFill = "#dcdcdc";
Expand Down Expand Up @@ -30934,29 +30934,49 @@
var drawTable = curry44(drawTable_);

// output-es/App.TableView/index.js
var energyRecord = (r) => ({
year: (() => {
const $1 = $$get("year")(r);
var waterRecord = (r) => ({
country: (() => {
const $1 = $$get("country")(r);
if ($1.tag === "Str") {
return $Tuple($1._2, $1._1);
}
return typeError($1)("Str");
})(),
cities: (() => {
const $1 = $$get("cities")(r);
if ($1.tag === "Int") {
return $Tuple($1._2, $1._1);
}
return typeError($1)("Int");
})(),
country: (() => {
const $1 = $$get("country")(r);
if ($1.tag === "Str") {
farms: (() => {
const $1 = $$get("farms")(r);
if ($1.tag === "Int") {
return $Tuple($1._2, $1._1);
}
return typeError($1)("Str");
return typeError($1)("Int");
})(),
energyType: (() => {
const $1 = $$get("energyType")(r);
if ($1.tag === "Str") {
industry: (() => {
const $1 = $$get("industry")(r);
if ($1.tag === "Int") {
return $Tuple($1._2, $1._1);
}
return typeError($1)("Str");
return typeError($1)("Int");
})(),
output: get_intOrNumber("output")(r)
energy: (() => {
const $1 = $$get("energy")(r);
if ($1.tag === "Int") {
return $Tuple($1._2, $1._1);
}
return typeError($1)("Int");
})(),
popMil: (() => {
const $1 = $$get("popMil")(r);
if ($1.tag === "Int") {
return $Tuple($1._2, $1._1);
}
return typeError($1)("Int");
})()
});

// output-es/Control.Monad.Error.Class/index.js
Expand Down Expand Up @@ -37507,17 +37527,17 @@
return $View("LineChartFig", reflectDictValBooleanLine1.from()(record1.unpack(v1._3._1)._1));
}
if (v1._2 === "Nil" || v1._2 === ":") {
return $View("EnergyTableView", { title: v, table: arrayMap(record2(energyRecord))(reflectValBooleanArrayVal.from()(v1)) });
return $View("WaterTableView", { title: v, table: arrayMap(record2(waterRecord))(reflectValBooleanArrayVal.from()(v1)) });
}
return unsafePerformEffect(throwException(error("absurd")));
}
if (v1._2 === "Nil" || v1._2 === ":") {
return $View("EnergyTableView", { title: v, table: arrayMap(record2(energyRecord))(reflectValBooleanArrayVal.from()(v1)) });
return $View("WaterTableView", { title: v, table: arrayMap(record2(waterRecord))(reflectValBooleanArrayVal.from()(v1)) });
}
return unsafePerformEffect(throwException(error("absurd")));
}
if (v1._2 === "Nil" || v1._2 === ":") {
return $View("EnergyTableView", { title: v, table: arrayMap(record2(energyRecord))(reflectValBooleanArrayVal.from()(v1)) });
return $View("WaterTableView", { title: v, table: arrayMap(record2(waterRecord))(reflectValBooleanArrayVal.from()(v1)) });
}
return unsafePerformEffect(throwException(error("absurd")));
}
Expand Down Expand Up @@ -37661,7 +37681,7 @@
if (v3.tag === "MatrixFig") {
return bindE(eventListener((x2) => v1(matrixViewHandler(x2))))(drawMatrix(v)(v2)(v3._1));
}
if (v3.tag === "EnergyTableView") {
if (v3.tag === "WaterTableView") {
return bindE(eventListener((x2) => v1((x$1) => x$1)))(drawTable(v)(v2)(v3._1));
}
if (v3.tag === "LineChartFig") {
Expand Down
8 changes: 8 additions & 0 deletions fluid/example/linked-outputs/water-bar-chart.fld
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
let totalFor country =
sum [row.cities + row.farms + row.industry + row.energy | row <- data, row.country == country];
let countryData = [ {x: country.country, y: totalFor country.country}
| country <- data]
in BarChart {
caption: "Total Water Consumption By Country",
data: countryData
}
4 changes: 4 additions & 0 deletions fluid/example/linked-outputs/water-consumption-data.fld
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[
{country: "Germany", cities: 1000, farms: 150, industry:500 , energy: 450, popMil: 81},
{country: "UK", cities: 800, farms: 200, industry: 400, energy: 700, popMil: 67}
]
7 changes: 7 additions & 0 deletions fluid/example/linked-outputs/water-ratio-chart.fld
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
let ratioFor country =
sum [row.popMil / row.farms | row <- data, row.country == country];
let countryData = [{x: country.country, y: ratioFor country.country} | country <- data]
in BarChart {
caption: "Ratio of farmland consumption to population in millions",
data: countryData
}
22 changes: 12 additions & 10 deletions fluid/example/slicing/motivating-example.expect.fld
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
let country_water c_name countries_list cities = let city_water = sum [city.water|country <- countries_list, c_name == country.name, city <- cities, elem city.name country.cities];
let country_water countries_list cities c_name = let city_water = sum [city.water|country <- countries_list, c_name == country.name, city <- cities, elem city.name country.cities];
farm_water = sum ⸨[country.farms * ⸨3⸩|country <- countries_list, country.name == c_name]⸩ in
city_water + farm_water in
let all_countries = [{name : "Germany", cities : ["Berlin", "Hamburg", "Munich"], farms : 100}
, {name : "UK", cities : ["London"], farms : 200}
let all_countries = [{name : "Germany", cities : ["Berlin", "Hamburg", "Munich"], farms : 100}
, {name : "UK", cities : ["London", "Birmingham", "Manchester"], farms : 200}
] in
let all_cities = [{name : "Berlin", water : 130}
, {name : "Munich", water : ⸨80⸩}
, {name : "Hamburg", water : ⸨60⸩}
, {name : "London", water : 200}
, {name : "Birmingham", water : 50}
, {name : "Manchester", water : 35}
let all_cities = [{name : "Berlin", water : 130}
, {name : "Munich", water : 80}
, {name : "Hamburg", water : 60}
, {name : "London", water : 200}
, {name : "Birmingham", water : ⸨50⸩}
, {name : "Manchester", water : ⸨35⸩}
] in
country_water ⸨"Germany"⸩ all_countries all_cities
let all_waters countries cities = let c_names = [country.name|country <- countries] in
map (country_water countries cities) c_names in
all_waters all_countries all_cities
11 changes: 7 additions & 4 deletions fluid/example/slicing/motivating-example.fld
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
let country_water c_name countries_list cities =
let country_water countries_list cities c_name =
let city_water = sum [city.water | country <- countries_list
, c_name == country.name
, city <- cities
, elem city.name country.cities];
farm_water = sum [ country.farms * 3 | country <- countries_list, country.name == c_name ]
in city_water + farm_water;
let all_countries = [{name: "Germany", cities: ["Berlin", "Hamburg", "Munich"], farms: 100},
{name: "UK", cities: ["London"], farms: 200}];
{name: "UK", cities: ["London", "Birmingham", "Manchester"], farms: 200}];
let all_cities = [
{name: "Berlin", water: 130},
{name: "Munich", water: 80},
{name: "Hamburg", water: 60},
{name: "London", water: 200},
{name: "Birmingham", water: 50},
{name: "Manchester", water: 35}
]
in country_water "Germany" all_countries all_cities
];
let all_waters countries cities =
let c_names = [country.name | country <- countries]
in map (country_water countries cities) c_names
in all_waters all_countries all_cities

0 comments on commit 8c02869

Please sign in to comment.