Giter Club home page Giter Club logo

Comments (3)

manzt avatar manzt commented on May 18, 2024

I think this is a good idea, but unfortunately the types are distinct. Track currently inherits from gosling.schema.Track so it cannot be instantiated without arguments -- this is all autogenerated code that does validation. gos.Track just inherits some additional "mixins" that allow method chaining for assiging properties to the underlying gosling.schema.Track.

Another option would be to export a singleton of PartialTrack for use in this situation:

# gosling/api.py
track = PartialTrack()

# example.py
bar_overview = bar_base.properties(
    width=300, height=300,
    alignment='overlay',
    tracks=[
        gos.track, # since overlay alignment is used with tracks, this is PartialTrack
        gos.track.mark_brush().encode(x=gos.Channel(linkingId='detail-1')),
        gos.track.mark_brush().encode(x=gos.Channel(linkingId='detail-2'))
    ]
)

With that said, there is likely a way to make Track more "magical" and I'll take a look.

from gos.

manzt avatar manzt commented on May 18, 2024

Another option would be to have a gos.track() util that inspects the arguments to decide whether to return a Track vs PartialTrack instance.

bar_overview = gos.track(data=data).properties(
    width=300, height=300,
    alignment='overlay',
    tracks=[
        gos.track(), # since overlay alignment is used with tracks, this is PartialTrack
        gos.track().mark_brush().encode(x=gos.Channel(linkingId='detail-1')),
        gos.track().mark_brush().encode(x=gos.Channel(linkingId='detail-2'))
    ]
)

The less magic the better IMO. And this is clearly a function that just adds some shorthand.

from gos.

sehilyi avatar sehilyi commented on May 18, 2024

Closing this for now since I think this is addressed by #19 (comment)

from gos.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.