Пример #1
0
def explore_layout(app):
    graph_data = graph_conversion(propnet_nx_graph,
                                  hide_unconnected_nodes=False)
    graph_component = html.Div(
        id='graph_component',
        children=[
            Cytoscape(id='pn-graph',
                      elements=graph_data,
                      stylesheet=GRAPH_STYLESHEET,
                      layout=GRAPH_LAYOUT_CONFIG,
                      **GRAPH_SETTINGS['full_view'])
        ],
    )

    graph_layout = html.Div(id='graph_top_level',
                            children=[
                                dcc.Checklist(
                                    id='graph_options',
                                    options=[{
                                        'label': 'Show models',
                                        'value': 'show_models'
                                    }, {
                                        'label': 'Show properties',
                                        'value': 'show_properties'
                                    }],
                                    value=['show_properties'],
                                    labelStyle={'display': 'inline-block'}),
                                html.Div(id='graph_explorer',
                                         children=[graph_component])
                            ])

    @app.callback(Output('pn-graph',
                         'elements'), [Input('graph_options', 'value')],
                  [State('pn-graph', 'elements')])
    def change_propnet_graph_label_selection(props, elements):
        show_properties = 'show_properties' in props
        show_models = 'show_models' in props

        update_labels(elements,
                      show_models=show_models,
                      show_symbols=show_properties)

        return elements

    layout = html.Div([
        html.Div([graph_layout], className='row'),
        html.Div([
            html.Div([models_index], className='six columns'),
            html.Div([symbols_index()], className='six columns'),
        ],
                 className='row')
    ])

    return layout
Пример #2
0
def display_page(pathname, search):
    """

    Args:
      pathname:
      search:

    Returns:

    """

    path_info = parse_path(pathname, search)

    if path_info:
        if path_info['mode'] == 'model':
            if path_info['value']:
                return model_layout(path_info['value'])
            else:
                return models_index
        elif path_info['mode'] == 'property':
            if path_info['value']:
                property_name = path_info['value']
                return symbol_layout(property_name)
            else:
                return symbols_index()
        elif path_info['mode'] == 'explore':
            return EXPLORE_LAYOUT
        elif path_info['mode'] == 'plot':
            props = None
            if path_info['value'] is not None:
                props = path_info['value']
            return get_plot_layout(props)
        elif path_info['mode'] == 'generate':
            return INTERACTIVE_LAYOUT
        elif path_info['mode'] == 'correlate':
            return CORRELATE_LAYOUT
        elif path_info['mode'] == 'refs':
            return REFS_LAYOUT
        elif path_info['mode'] == 'home':
            return home_layout()
        else:
            return '404'
    else:
        return home_layout()
Пример #3
0
def display_page(pathname):
    """

    Args:
      pathname:

    Returns:

    """

    path_info = parse_path(pathname)

    if path_info:
        if path_info['mode'] == 'model':
            if path_info['value']:
                return model_layout(path_info['value'])
            else:
                return models_index
        elif path_info['mode'] == 'property':
            if path_info['value']:
                property_name = path_info['value']
                return symbol_layout(property_name)
            else:
                return symbols_index()
        elif path_info['mode'] == 'load_material':
            return material_layout
        elif path_info['mode'] == 'graph':
            return graph_layout
        elif path_info['mode'] == 'ashby':
            return ASHBY_LAYOUT
        elif path_info['mode'] == 'interactive':
            return INTERACTIVE_LAYOUT
        else:
            return '404'
    else:
        return index
Пример #4
0
def display_page(pathname):
    """

    Args:
      pathname:

    Returns:

    """

    path_info = parse_path(pathname)

    if path_info:
        if path_info['mode'] == 'model':
            if path_info['value']:
                return model_layout(path_info['value'])
            else:
                return models_index
        elif path_info['mode'] == 'property':
            if path_info['value']:
                property_name = path_info['value']
                return symbol_layout(property_name)
            else:
                return symbols_index()
        elif path_info['mode'] == 'explore':
            return EXPLORE_LAYOUT
        elif path_info['mode'] == 'plot':
            return PLOT_LAYOUT
        elif path_info['mode'] == 'generate':
            return INTERACTIVE_LAYOUT
        elif path_info['mode'] == 'home':
            return home_layout()
        else:
            return '404'
    else:
        return home_layout()
Пример #5
0
def explore_layout(app):

    g = Graph().get_networkx_graph()

    graph_data = graph_conversion(g)
    graph_component = html.Div(id='graph_component',
                               children=[
                                   GraphComponent(
                                       id='propnet-graph',
                                       graph=graph_data,
                                       options=AESTHETICS['global_options'])
                               ],
                               style={
                                   'width': '100%',
                                   'height': '800px'
                               })

    graph_layout = html.Div(id='graph_top_level',
                            children=[
                                dcc.Checklist(
                                    id='graph_options',
                                    options=[{
                                        'label': 'Show models',
                                        'value': 'show_models'
                                    }, {
                                        'label': 'Show properties',
                                        'value': 'show_properties'
                                    }],
                                    values=['show_properties'],
                                    labelStyle={'display': 'inline-block'}),
                                html.Div(id='graph_explorer',
                                         children=[graph_component])
                            ])

    # Define default graph component
    # TODO: this looks bad, re-evaluate
    @app.callback(Output('graph_explorer', 'children'),
                  [Input('graph_options', 'values')])
    def get_graph_component(props):
        aesthetics = AESTHETICS.copy()
        show_properties = 'show_properties' in props
        show_models = 'show_models' in props
        set_(aesthetics, "node_aesthetics.Symbol.show_labels", show_properties)
        set_(aesthetics, "node_aesthetics.Model.show_labels", show_models)
        graph_data = graph_conversion(g, aesthetics=aesthetics)
        graph_component = html.Div(
            id=str(uuid4()),
            children=[
                GraphComponent(id=str(uuid4()),
                               graph=graph_data,
                               options=AESTHETICS['global_options'])
            ],
            style={
                'width': '100%',
                'height': '800px'
            })
        return [graph_component]

    layout = html.Div([
        html.Div([graph_layout], className='row'),
        html.Div([
            html.Div([models_index], className='six columns'),
            html.Div([symbols_index()], className='six columns'),
        ],
                 className='row')
    ])

    return layout