Published
Edited
Sep 21, 2020
Importers
2 stars
Insert cell
md`# View Data Transformed by Vega`
Insert cell
Insert cell
md`## viewDataTransformed`
Insert cell
Insert cell
vega = require('vega@5')
Insert cell
Insert cell
Insert cell
table(sample_1)
Insert cell
md` And we want to generate new column of data where the value are twice of x using transform formula in vega as per stated below.`
Insert cell
transform = {
return ([{"type":"formula","as":"x2","expr": "datum.x*2"}])
}
Insert cell
sample_1_transformed = viewDataTransformed(sample_1.slice(),transform)
Insert cell
table(sample_1_transformed)
Insert cell
md` That's it. I hope this vega utility will help you working with data manipulation. Any feedback are welcomed.`
Insert cell
import {table} from '@binarmaya/table-from-array-of-data'
Insert cell
Insert cell
urlCovid19Jabar ="https://covid19-public.digitalservice.id/api/v1/rekapitulasi/jabar/kumulatif"
Insert cell
import {data} from '@binarmaya/top-level-vega-spec'
Insert cell
Insert cell
Insert cell
Insert cell
viewDataTransformedBasedArray_2 = viewUrlDataTransformed([{
"name":"source1",
"url":"https://vega.github.io/vega-datasets/data/cars.json"
},{
"name":"source2",
"values":sample_1,
"transform":[{"type":"formula","as":"y","expr": "datum.x*3"}]
}])
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more