viewof year1 = Inputs.number(
[1970, 2020],
{value: 1970, step: 1, label: "YoC1"}
)
viewof year2 = Inputs.number(
[1970, 2020],
{value: 2020, step: 1, label: "YoC2"}
)
viewof sector = Inputs.toggle({label: "Codes", value: true})
innovations = dbfile.query(`select id, name_sv, prod_code, year from innovation where ${year1} <= year and ${year2} >= year`)
trend = sector ? dbfile.query(`select year, count(*) as count, "p"||substr(prod_code, 0, 3) as prod_code from innovation where ${year1} <= year and ${year2} >= year group by year, prod_code`) : dbfile.query(`select year, count(*) as count from innovation where ${year1} <= year and ${year2} >= year group by year`)Plot.plot({
marks:
sector ? [
Plot.rectY(trend, Plot.binX({y: "count"}) ,{x:"year", fill: "prod_code"}),
// Plot.dot(trend, {x:"year", y:"count", fill: "prod_code", tip: true})
Plot.ruleY[0]
] : [
Plot.line(
trend,
{
x: "year",
y: "count",
stroke: "black",
tip: true
})
],
y: {grid: true, zero: true, tip: true }
})More visualisations coming soon, data is availabie here