Public
Edited
Jan 24, 2023
Insert cell
Insert cell
fuel_prices@2.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
filteredPrices = (type, max = 100) => fuel_prices2.filter(d => d.descCarburante === type && d.prezzo > 1 && d.prezzo < 5).slice(0,max)
Insert cell
getMinMax = (type, max = 100) => {
const data = fuel_prices2.filter(d => d.descCarburante === type && d.prezzo > 1 && d.prezzo < 5).map(d => d.prezzo) //.slice(0,max)
return [Math.min(...data), Math.max(...data)];
}
Insert cell
chrt.Chrt()
.size(width, 150)
.margins({left:20,bottom: 40, right: 20})
.add(
chrt.points()
.data(filteredPrices('Gasolio', 1000), d => ({
x: d.prezzo,
y: 0
}))
.color('#333')
.opacity(0.5)
.radius(5)
)
.add(
chrt.points()
.data(filteredPrices('Benzina', 1000), d => ({
x: d.prezzo,
y: 2
}))
.color('#333')
.opacity(0.5)
.radius(5)
)
.add(chrt.xAxis())
.node()
Insert cell
Insert cell
Insert cell
Insert cell
chrt=require('chrt')
Insert cell
chrt.Chrt()
.size(width, 300)
.x({scale:'time'})
.add(
chrt.xAxis()
.interval('year')
.format((x, i) => {
const d = new Date(x);
const month = d.toLocaleString(undefined, {month: "short"})
if(!i || !d.getMonth()) {
return `${d.getFullYear()}`;
}
return month;
})
)
.add(chrt.yAxis())
.add(
chrt.line()
.data(weekly_fuel_prices_from_2005_to_20230124, (d,i) => ({
x: new Date(d.SURVEY_DATE),
y: d['EURO-SUPER_95']
}))
)
.add(
chrt.line()
.data(weekly_fuel_prices_from_2005_to_20230124, (d,i) => ({
x: new Date(d.SURVEY_DATE),
y: d['AUTOMOTIVE_GAS_OIL']
}))
.color('#f00')
)
.node()
Insert cell
weekly_fuel_prices_from_2005_to_20230124
Insert cell
weekly_fuel_prices_from_2005_to_20230124.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

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