html`<figure style="max-width: 100%;">
<a href="/game_for_everyone.html"><img src="https://www.mikeread.com.au/images/newsmcc.png" style="max-width:80%;height:auto;">
</figure>There's A Game For Everyone</a>`Mike Read
<!-- html`<figure style="max-width: 100%;"> -->
<!-- <a href="/games_played_together.html"><img src="https://www.mikeread.com.au/images/clubsites/afl_logo.gif" style="max-width:100%;height:auto;"> -->
<!-- </figure>Games Played Together</a>` -->
html`<img src="https://www.mikeread.com.au/images/PremiershipCup.jpeg" style="max-width:60%;height:auto;">`
import { Legend, Swatches } from "@d3/color-legend"
import { aq, op } from "@uwdata/arquero"
import { Scrubber } from "@mbostock/scrubber"
vic2 = await FileAttachment("australian-states.min2.geojson").json()
melbgee = await FileAttachment("melbgee.geojson").json()
AFLlosses0624 = await FileAttachment("AFL_VFL_EXPENDITURE_LOCATION_POKIES.csv").csv()
venue_opyr = await FileAttachment("AFL_VFL_EXPENDITURE_LOCATION_POKIES.csv").csv({typed: true})
venue_end_yr_aq = aq.from(venue_opyr)
.select('venue', 'expenditure', 'FY_end', 'latitude', 'longitude', 'venue_EOY')
.groupby('venue')
.derive({max_ex: (d) => d3.max(d.expenditure)})
.filter((d) => d.FY_end === d3.max(d.FY_end))
.derive({full_end: (d) => d.venue_EOY === 0 ? d.FY_end - 1 : d.FY_end})
.select(aq.not("expenditure"))
.rename( {max_ex: "expenditure"} )
expscrub = range(2006, 2025, 1)
StartDate = new Date(Date.UTC(2024, 5, 30, 13, 0, 0))
htl.html`<br><br>
<h3>The Decline of AFL Club Operated Pokies Venues in Victoria</h3>
From a peak of $102m of player losses across 20 venues in 2012 to $40m lost at 8 venues in 2024
<br>
<br>
${Swatches(d3.scaleOrdinal(["CARLTON", "COLLINGWOOD", "ESSENDON", "GEELONG", "HAWTHORN", "MELBOURNE", "NORTH MELBOURNE", "RICHMOND", "ST KILDA", "WESTERN BULLDOGS"], ["#0e5fab", "black", "#c40215", "#1C3C63", "#4D2004", "#0f1131", "white", "#FED102", "#fc031b", "#014896"]), { columns: "140px" })}<br><br>${mapplot} <br><br>
<b>${scrubyr}:</b>
${d3.format("($,.2f")(d3.sum(EGMS.get(scrubyr), d => d.expenditure))} lost on ${d3.format("(,.0f")(d3.sum(EGMS.get(scrubyr), d => d.EGMs_EOY))} EGMs across ${d3.sum(EGMS.get(scrubyr), d => d.venue_EOY)} venues. <br>
<small><i>Venue and EGM figures are based on the number active at the end of each FY</i></small><br><br>`viewof scrubyr = Scrubber(expscrub, {autoplay: false, loop: false, delay: 800, loopDelay: 2000})
mapplot = Plot.plot({projection: {type: "reflect-y", domain: melbgee}, r: {domain: [0, 15000000], range: [1,20]}, className: "custom-plotpink",
marks: [
Plot.geo(vic2, {strokeOpacity: 10, stroke: "red", domain: melbgee}),
Plot.dot(venue_end_yr_aq, {x: d => d.longitude, y: d => d.latitude, r: d => d.expenditure, opacity: d => d.full_end < scrubyr ? 0.3 : 0, fill: "grey"}),
Plot.dot(venue_opyr.filter(d => d.FY_end === scrubyr), {x: d => d.longitude, y: d => d.latitude, r: d => d.expenditure, opacity: d => d.venue_EOY === 1 ? 0.8 : 0, fill: scrubcolAFL, tip: true, title: (d) => `${d.team}\n${d.venue} (${d.LGA})\nPlayer Losses: ${d3.format("($,.2f")(d.expenditure)}`}) ] })
dollarslostunf = {
while (true) {
yield Promises.delay(500, Math.max(0, Math.ceil((Date.now() - StartDate) / 1000)) * 0.457201347);
}
}
dollarslost = d3.format("($,.2f")(dollarslostunf)
scrubcolAFL = d => d.team === "ST KILDA" ? "#fc031b" : d.team === "CARLTON" ? "#0e5fab" : d.team === "ESSENDON" ? "#c40215" : d.team === "RICHMOND" ? "#FED102" : d.team === "HAWTHORN" ? "#4D2004" : d.team === "WESTERN BULLDOGS" ? "#014896" : d.team === "GEELONG" ? "#1C3C63" : d.team === "COLLINGWOOD" ? "black" : d.team === "MELBOURNE" ? "#0f1131" : d.team === "NORTH MELBOURNE" ? "white" : "green"
EGMS = d3.group(venue_opyr, d => d.FY_end)
range =
(start, stop, step) =>
Array.from(
{ length: Math.ceil((stop - start) / step) },
(_, i) => start + i * step,
);