def __init__(self, *args, **kwargs):
        """Create a Vega Line Chart"""

        super(Line, self).__init__(*args, **kwargs)

        # Scales
        x_type = 'time' if self._is_datetime else 'linear'
        self.scales += [
            Scale(name='x', type=x_type, range='width',
                  domain=DataRef(data='table', field="data.idx")),
            Scale(name='y', range='height', nice=True,
                  domain=DataRef(data='table', field="data.val")),
            Scale(name='color', type='ordinal',
                  domain=DataRef(data='table', field='data.col'),
                  range='category20')
        ]

        # Axes
        self.axes += [Axis(type='x', scale='x'),
                      Axis(type='y', scale='y')]

        # Marks
        from_ = MarkRef(
            data='table',
            transform=[Transform(type='facet', keys=['data.col'])])
        enter_props = PropertySet(
            x=ValueRef(scale='x', field="data.idx"),
            y=ValueRef(scale='y', field="data.val"),
            stroke=ValueRef(scale="color", field='data.col'),
            stroke_width=ValueRef(value=2))
        marks = [Mark(type='line',
                      properties=MarkProperties(enter=enter_props))]
        mark_group = Mark(type='group', from_=from_, marks=marks)
        self.marks.append(mark_group)
def __init__ ( self , * args , ** kwargs ) : super ( Line , self ) . __init__ ( * args , ** kwargs ) x_type = 'time' if self . _is_datetime else 'linear' self . scales += [ Scale ( name = 'x' , type = x_type , range = 'width' , domain = DataRef ( data = 'table' , field = "data.idx" ) ) , Scale ( name = 'y' , range = 'height' , nice = True , domain = DataRef ( data = 'table' , field = "data.val" ) ) , Scale ( name = 'color' , type = 'ordinal' , domain = DataRef ( data = 'table' , field = 'data.col' ) , range = 'category20' ) ] self . axes += [ Axis ( type = 'x' , scale = 'x' ) , Axis ( type = 'y' , scale = 'y' ) ] from_ = MarkRef ( data = 'table' , transform = [ Transform ( type = 'facet' , keys = [ 'data.col' ] ) ] ) enter_props = PropertySet ( x = ValueRef ( scale = 'x' , field = "data.idx" ) , y = ValueRef ( scale = 'y' , field = "data.val" ) , stroke = ValueRef ( scale = "color" , field = 'data.col' ) , stroke_width = ValueRef ( value = 2 ) ) marks = [ Mark ( type = 'line' , properties = MarkProperties ( enter = enter_props ) ) ] mark_group = Mark ( type = 'group' , from_ = from_ , marks = marks ) self . marks . append ( mark_group )
Create a Vega Line Chart