Skip to content

Commit

Permalink
Tooltip improvements. Fixes #53
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Kaczmarski committed Apr 19, 2024
1 parent 80a528e commit 5802707
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 51 deletions.
17 changes: 9 additions & 8 deletions capacity.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Plot.plot({
{
x: "year",
y: "capacity",
fill: "prime_mover",
fill: "Prime Mover",
order: ["Fossil Turbines", "Recip Engines", "Hydro", "Wind","Utility Solar","Rooftop Solar","Storage","Landfill Gas"],
tip: {format: {x: "d"}}
}
Expand Down Expand Up @@ -127,7 +127,7 @@ Plot.plot({
{
x: "year",
y: "capacity",
fill: "prime_mover",
fill: "Prime Mover",
order: ["Fossil Turbines", "Recip Engines", "Hydro", "Wind","Storage"],
tip: {format: {x: "d"}}
}
Expand Down Expand Up @@ -178,7 +178,7 @@ Plot.plot({
{
x: "year",
y: "capacity",
fill: "prime_mover",
fill: "Prime Mover",
order: ["Hydro", "Wind","Storage"],
tip: {format: {x: "d"}}
}
Expand Down Expand Up @@ -232,7 +232,7 @@ Plot.plot({
{
x: "year",
y: "capacity",
fill: "prime_mover",
fill: "Prime Mover",
order: ["Fossil Turbines", "Recip Engines", "Hydro", "Wind","Utility Solar","Rooftop Solar","Storage","Landfill Gas"],
tip: {format: {x: "d"}}
}
Expand Down Expand Up @@ -283,7 +283,7 @@ Plot.plot({
{
x: "year",
y: "capacity",
fill: "prime_mover",
fill: "Prime Mover",
order: ["Hydro", "Wind","Utility Solar","Rooftop Solar","Storage","Landfill Gas"],
tip: {format: {x: "d"}}
}
Expand Down Expand Up @@ -335,7 +335,7 @@ Plot.plot({
{
x: "year",
y: "capacity",
fill: "prime_mover",
fill: "Prime Mover",
order: ["Fossil Turbines", "Recip Engines", "Hydro", "Wind","Utility Solar","Storage"],
tip: {format: {x: "d"}}
}
Expand Down Expand Up @@ -386,7 +386,7 @@ Plot.plot({
{
x: "year",
y: "capacity",
fill: "prime_mover",
fill: "Prime Mover",
order: ["Hydro", "Wind","Utility Solar","Storage"],
tip: {format: {x: "d"}}
}
Expand All @@ -405,5 +405,6 @@ Plot.plot({


```{ojs}
cap_data = FileAttachment("data/working/capacity/capacity_long.csv").csv({ typed: true })
original_cap_data = FileAttachment("data/working/capacity/capacity_long.csv").csv({ typed: true })
cap_data = original_cap_data.map((d) => ({...d, "Prime Mover": d.prime_mover}))
```
28 changes: 14 additions & 14 deletions consumption.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ regional_consumption_data = tidy(
customers: sum('customers')
})
])
)
).map((d) => ({...d, "Customer Class": d.class})).map((d) => ({...d, "ACEP Region": d.acep_region}))
// Change in statewide totals
statewide_delta = tidy(
Expand All @@ -104,7 +104,7 @@ statewide_delta = tidy(
customers_delta: (d) => (d.customers - d.customers_2011) / d.customers_2011,
}),
filter((d) => d.year === 2019)
)
).map((d) => ({...d, "Customer Class": d.class}))
```

```{ojs}
Expand Down Expand Up @@ -136,8 +136,8 @@ Plot.plot({
Plot.barX(statewide_delta,
{
x: "sales_delta",
y: "class",
fill: "class",
y: "Customer Class",
fill: "Customer Class",
tip: {
format: {
x: (d) => `${(d).toLocaleString(undefined, {maximumFractionDigits: 2})}%`,
Expand Down Expand Up @@ -186,8 +186,8 @@ Plot.plot({
Plot.barX(statewide_delta,
{
x: "customers_delta",
y: "class",
fill: "class",
y: "Customer Class",
fill: "Customer Class",
tip: {
format: {
x: (d) => `${(d).toLocaleString(undefined, {maximumFractionDigits: 2})}%`,
Expand All @@ -211,7 +211,7 @@ Plot.plot({
```{ojs}
sales_per_capita_data = tidy(regional_consumption_data.filter((d) => d.class === "Residential"),
groupBy(
['acep_region','year'],
['ACEP Region','year'],
[
mutate({
sales_per_capita: (d) => (d.sales / d.customers) * 1000
Expand Down Expand Up @@ -253,7 +253,7 @@ Plot.plot({
Plot.line(sales_per_capita_data, {
x: "year",
y: "sales_per_capita",
stroke: "acep_region",
stroke: "ACEP Region",
strokeWidth: 5,
tip: {format: {x: "d"}}
}
Expand Down Expand Up @@ -303,7 +303,7 @@ Plot.plot({//|
{
x: "year",
y: "sales",
fill: "class",
fill: "Customer Class",
tip: {format: {x: "d"}}
}
),
Expand Down Expand Up @@ -350,7 +350,7 @@ Plot.plot({
{
x: "year",
y: "customers",
fill: "class",
fill: "Customer Class",
tip: {format: {x: "d"}}
}
),
Expand Down Expand Up @@ -399,7 +399,7 @@ Plot.plot({//|
{
x: "year",
y: "sales",
fill: "class",
fill: "Customer Class",
tip: {format: {x: "d"}}
}
),
Expand Down Expand Up @@ -446,7 +446,7 @@ Plot.plot({
{
x: "year",
y: "customers",
fill: "class",
fill: "Customer Class",
tip: {format: {
x: "d",
y: (y) => `${(y).toLocaleString(undefined, {maximumFractionDigits: 2})}`
Expand Down Expand Up @@ -499,7 +499,7 @@ Plot.plot({
{
x: "year",
y: "sales",
fill: "class",
fill: "Customer Class",
tip: {format: {x: "d"}}
}
),
Expand Down Expand Up @@ -546,7 +546,7 @@ Plot.plot({
{
x: "year",
y: "customers",
fill: "class",
fill: "Customer Class",
tip: {format: {
x: "d",
y: (y) => `${(y).toLocaleString(undefined, {maximumFractionDigits: 2})}`
Expand Down
30 changes: 17 additions & 13 deletions generation.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ gen_data = FileAttachment("data/working/generation/net_generation_long.csv").csv
// Convert MWh to GWh
gen_data_gwh = tidy(gen_data, mutate({
generation: (d) => d.generation / 1000
}));
})).map((d) => ({...d, "Fuel Type": d.fuel_type})).map((d) => ({...d, "ACEP Region": d.acep_region}));
//gen_data_gwh = gen_data_gwh_.map((d) => ({...d, "ACEP Region": d.acep_region},{...d, "Fuel Type": d.fuel_type}))
```

```{ojs}
Expand Down Expand Up @@ -108,7 +111,7 @@ Plot.plot({
{
x: "year",
y: "generation",
fill: "acep_region",
fill: "ACEP Region",
tip: {format: {x: "d"}}
}
)
Expand Down Expand Up @@ -158,13 +161,13 @@ join = tidy(share_data, fullJoin(total_gen, {by: ['year','acep_region']}))
// Creating a column with shares
join_shares = tidy(join.filter((d) => d.fuel_type !== "Storage"),
mutate({generation_share: (d) => (d.generation / d.total_generation)*100})
) // join_shares should be used for the 100% area charts
).map((d) => ({...d, "Fuel Type": d.fuel_type})).map((d) => ({...d, "ACEP Region": d.acep_region})) // join_shares should be used for the 100% area charts
// Table for just the 2011 and 2021 generation mix comparison
gen_mix_diff = tidy(
join_shares.filter((d) => d.year === 2011 || d.year === 2021),
groupBy(
['acep_region','fuel_type'],
['ACEP Region','Fuel Type'],
mutateWithSummary({
generation_share_2011: lag('generation_share', {default: 0})
})
Expand Down Expand Up @@ -212,13 +215,14 @@ Plot.plot({
Plot.frame(),
Plot.barX(gen_mix_diff, {
x: "delta",
y: "fuel_type",
fill: "fuel_type",
y: "Fuel Type",
fill: "Fuel Type",
order: ["Coal","Oil","Gas","Hydro","Wind","Solar"],
tip: {
format: {
x: (d) => `${(d).toLocaleString(undefined, {maximumFractionDigits: 2})}%`,
y: false
y: false,
fy: false
}
}
}
Expand Down Expand Up @@ -276,7 +280,7 @@ Plot.plot({
{
x:"year",
y:"generation_share",
fill: "fuel_type",
fill: "Fuel Type",
order: ["Oil","Hydro","Wind"],
tip: {format: {x: "d", y: (d) => `${(d).toLocaleString(undefined, {maximumFractionDigits: 2})}%`}}
}
Expand Down Expand Up @@ -331,7 +335,7 @@ Plot.plot({
{
x: "year",
y: "generation",
fill: "fuel_type",
fill: "Fuel Type",
order: ["Oil","Hydro","Wind"],
tip: {format: {x: "d"}}
}
Expand Down Expand Up @@ -384,7 +388,7 @@ Plot.plot({//|
{
x:"year",
y:"generation_share",
fill: "fuel_type",
fill: "Fuel Type",
order: ["Coal","Oil","Gas","Hydro","Wind","Solar"],
tip: {format: {x: "d", y: (d) => `${(d).toLocaleString(undefined, {maximumFractionDigits: 2})}%`}}
}
Expand Down Expand Up @@ -440,7 +444,7 @@ Plot.plot({
{
x: "year",
y: "generation",
fill: "fuel_type",
fill: "Fuel Type",
order: ["Coal","Oil","Gas","Hydro","Wind","Solar"],
tip: {format: {x: "d"}}
}
Expand Down Expand Up @@ -494,7 +498,7 @@ Plot.plot({
{
x:"year",
y:"generation_share",
fill: "fuel_type",
fill: "Fuel Type",
order: ["Oil","Gas","Hydro","Wind","Solar","Other"],
tip: {format: {x: "d", y: (d) => `${(d).toLocaleString(undefined, {maximumFractionDigits: 2})}%`}}
}
Expand Down Expand Up @@ -549,7 +553,7 @@ Plot.plot({
{
x: "year",
y: "generation",
fill: "fuel_type",
fill: "Fuel Type",
order: ["Oil","Gas","Hydro","Wind","Solar","Other"],
tip: {format: {x: "d"}}
}
Expand Down
Loading

0 comments on commit 5802707

Please sign in to comment.