In [1]:
import dash
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
import dash_bootstrap_components as dbc
from pyhive import hive
import plotly.graph_objs as go

host_name = "your IP"
port = your port
user = "your username"
password = "your password"
database="your DB name"
def hiveconnection(host_name, port, user,password, database):
    conn = hive.Connection(host=host_name, port=port, username=user, password=password,
                           database=database, auth='CUSTOM')
    cur = conn.cursor()
    cur.execute('''
        your Hive Query''')

    result = pd.DataFrame(cur.fetchall(), columns=['Time', 'Transactions', 'DataCenter'])
    return result
   
# Call above function
output = hiveconnection(host_name, port, user,password, database)
output2 = output.groupby(['Time']).sum().reset_index()
In [2]:
app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])
app.layout = html.Div([
        dbc.NavbarSimple(
    sticky="top",
    color="dark"
),
        dbc.Row(
            [
                #dbc.Col(dcc.Graph(id='per-dab', figure=px.line(output, x="Time", y="Transactions", color="DataCenter", hover_name="DataCenter", template='plotly_dark').update_layout(legend_orientation="h", margin=dict(l=20, r=20, t=20, b=20))),width=6),
                dbc.Col(dcc.Graph(id='overall', figure=px.line(output, x="Time", y="Transactions", facet_col="DataCenter", color="DataCenter").update_layout(showlegend=False, margin=dict(l=20, r=20, t=60, b=20))),width=12)
            ],
        )   
    ])
In [3]:
if __name__ == "__main__":
    app.run_server()
 * Serving Flask app "__main__" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://127.0.0.1:8050/ (Press CTRL+C to quit)

Other things I was testing

In [4]:
'''
DC1 = output.where(output['DataCenter'] == 'DC1').dropna()
DC2 = output.where(output['DataCenter'] == 'DC2').dropna()


       dbc.Row(
            [
                dbc.Col(dcc.Graph(id='dc1', figure=px.line(DC1, x="Time", y="Transactions", title="DC1 Counts").update_layout(margin=dict(l=0, r=0, t=50, b=20))),width=2),
                dbc.Col(dcc.Graph(id='dc2', figure=px.line(DC2, x="Time", y="Transactions", title="DC2 Counts").update_layout(margin=dict(l=0, r=0, t=50, b=20))),width=2),
            ],
        )  '''