✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚡️ Concerned about the grid? Kyle Baranko teaches how to predicting peak loads using XGBoost. Register for the August webinar!

How to get returned list to HTML.div() and plot a node graph

Hi Everyone,

import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import dash_cytoscape as cyto
import pyTigerGraph as tg
import pandas as pd

external_stylesheets = [“https://codepen.io/chriddyp/pen/bWLwgP.css”]

app = dash.Dash(name, external_stylesheets=external_stylesheets)

app.layout = html.Div(
[
html.I(“Try typing in input 1 & 2, and observe how debounce is impacting the callbacks. Press Enter and/or Tab key in Input 2 to cancel the delay”),
html.Br(),
dcc.Input(id=“input1”, type=“text”, placeholder=""),
#dcc.Input(id=“input2”, type=“text”, placeholder="", debounce=True),
cyto.Cytoscape(
id=‘cytoscape-two-nodes’,
layout={‘name’: ‘circle’},
style={‘width’: ‘100%’, ‘height’: ‘400px’}),

    html.Div(id="output",),
]

)

@app.callback(
Output(“output”, “children”),
[Input(“input1”, “value”)],
)
def update_output(input1):
conn = tg.TigerGraphConnection(host=“https://7043247e92154773a170f7805bd3e345.i.tgcloud.io”,
graphname=“MY_GRAPH”,
username=“tigergraph”, password=“dheeraj1”,
apiToken=“24c6jv527g9cp903478gif8onu35r1an”)
authToken = conn.getToken(“cbt31n9nac93nagraldfu9m5ba9ahjr3”, “100000000000000000”)
# search1 =request.form[‘search’]
results = conn.runInstalledQuery(“count_query”, {
“doi”: input1},
timeout=20000, sizeLimit=40000000)
df = pd.DataFrame.from_dict(results[0][“SIMILAR_PUBLICATIONS”])
df3_auth = pd.concat([df[‘v_id’], df[‘v_type’], df[‘attributes’].apply(pd.Series)], axis=1)
graph_df = pd.DataFrame()
#print(df3_auth)
output =
for i in range(5):
output.extend(
[{‘data’: {‘id’: df3_auth[‘v_id’][i], ‘label’: df3_auth[‘v_id’][i]}, ‘position’: {‘x’: 75, ‘y’: 75}},
{‘data’: {‘id’: df3_auth[‘pub_extract’][i], ‘label’: df3_auth[‘pub_extract’][i]},
‘position’: {‘x’: 200, ‘y’: 200}},
{‘data’: {‘source’: df3_auth[‘v_id’][i], ‘target’: df3_auth[‘pub_extract’][i]}}])
#print(output)
return output

if name == “main”:
app.run_server(debug=True)

I am getting error while executing this program,

Error:
An object was provided as children instead of a component, string, or number (or list of those). Check the children property that looks something like:
{
“data”: {
“id”: “10.1128/jvi.00747-07”,
“label”: “10.1128/jvi.00747-07”
},
“position”: {
“x”: 75,
“y”: 75
}
}

Can any one help me on this??