gosling.js
gosling.js copied to clipboard
Revisit the property names of the TS schema and their structure
Thanks to @manzt's experiment, we now know that, if we build a Python API using Altair's script, the names of TypeScript types and interfaces will be exposed to users. In other words, users will use those names to set values, such as Root, DataDeep, and Channel:
import gosling as gos
spec = gos.Root(
title="Basic Marks: Bar",
subtitle="Tutorial Examples",
tracks=[
gos.Track(
layout="linear",
width=800,
height=180,
data=gos.DataDeep(
url="https://resgen.io/api/v1/tileset_info/?d=UvVPeLHuRDiYA3qwFlm7xQ",
type="multivec",
row="sample",
column="position",
value="peak",
categories=["sample 1"],
binSize=5
),
mark="bar",
y=gos.Channel(field="peak", type="quantitative"),
x=gos.Channel(field="start", type="genomic"),
xe=gos.Channel(field="end", type="genomic"),
stroke=gos.Channel(value=0.5),
strokeWidth=gos.Channel(value=0.5),
)
]
)
We will need to revisit the property names in gosling.schema.ts to make them clear and concise. For example, we can rename DataDeep() to Data().
Related to #273
Another approach would be to try pydantic code generation with datamodel-code-generator, instead of all the vendored altair scripts (it's just a single command given a schema). I've used pydantic on a couple of projects and it's really excellent for end users , given its use of python type annotations. Either way these approaches respect and expose the naming in the json schema, so a good enhancement to be thoughtful about the naming!