Published
Edited
Jun 20, 2022
Insert cell
# <span style="font-family: Lato, sans-serif"> Древнейшая профессия в Москве </span>
Insert cell
{
const Brush = vl.selectInterval()
.encodings("x");

const hover = vl.selectSingle()
.on("mouseover")
.encodings("x")
.nearest(true);

const Line = vl.markLine()
.select(Brush)
.title("Как менялась средняя цена в Москве")
.width(1000)
.height(300)
.encode(
vl.x().fieldT("date"),
vl.y().fieldQ("price").aggregate("mean"));


const Bars = vl.markBar({tooltip: true})
.transform(
vl.filter(Brush),
vl.aggregate(vl.mean("price").as("Mean")).groupby("district"),
vl.window(vl.rank().as('rank')).sort(vl.field("Mean").order('descending')),
vl.filter('datum.rank < 10'))
.height(400)
.width(600)
//.transform(vl.filter(Brush))
.encode(
vl.x().fieldQ("Mean"),
vl.y().fieldN('district').sort("-x").title(false)

); return vl.vconcat( vl.layer(Line), vl.layer(Bars))
.data(data_clean)
.render()
}

Insert cell
Insert cell
Insert cell
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Lato:wght@300;400&display=swap" rel="stylesheet">
Insert cell
Insert cell
data = FileAttachment("поменял (2).csv").csv()
Insert cell
import {vl} from "@vega/vega-lite-api"
Insert cell
data_clean = {
return data_years.map(
(e)=>{
return { "date" : e["0"] + "/12/30" , "price" : parseFloat(e.Price) , "district" : e.District }
}
).filter(e=>e.district)
}
Insert cell
data_years = FileAttachment("data_with_years.csv").csv()
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