Example #1
0
def _single_time_vis(channel, props) -> Javascript:
    ##########################################################################################
    # TODO: Horrible hack due to horrible JS interface. Change!
    #   chartType is a visualization concern, and should therefore be in props, not channel
    #   (also, channel should probably be called src to align with new word for concept)
    if 'chart_type' in props:
        channel['chartType'] = props['chart_type']
    ##########################################################################################

    js_source = f'renderTimeChannel(element.get(0), {channel}, {props})'.replace(
        'True', 'true').replace('None', 'null')
    jsobj = Javascript(js_source)
    jsobj._trace = {'channel': channel, 'props': props}
    return jsobj
Example #2
0
def time_vis(channels, props=None) -> Javascript:
    """
    Render multiple channels.

    :param channels: The channels to render, a list of dicts.
    :return:
    """
    if not props:
        props = {}
    channels = [_preprocess_channel(channel) for channel in channels]
    js_source = f'renderMultiTimeVis(element.get(0), {channels}, {props})'.replace(
        'True', 'true').replace('None', 'null')
    jsobj = Javascript(js_source)
    jsobj._trace = {'channels': channels, 'props': props}
    return jsobj