Python Forum
Get input for reading DB and refreshing plotly.graph_objects
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get input for reading DB and refreshing plotly.graph_objects
#1
Hi,

there is a simple Python appilaction, which reads data from SQL database and shows the result as plotly.graph_objects.

I want the get two values from UI for stock and day and read data from SQl database and show the data with plotly.graph_objects.
At the moment are both data hard coded:

stocksTicker = 'GRVI'
the_day='2021-10-14'

Could you please giv me some instractions how to extend the code to implement the requirements ?

Thanks in advance, Michel

df = pd.read_sql(selectString ,con=Engine)

trace1 = {
    'x': df.t_datetime,
    'open': df.o,
    'close': df.c,
    'high': df.h,
    'low': df.l,
    'type': 'candlestick',
    'name': stocksTicker,
    'showlegend': True
}

# Config graph layout
layout = go.Layout({
    'title': {
        'text': 'Moving Averages',
        'font': {
            'size': 15
        }
    }
})

fig=go.Figure([trace1])
fig.show()
Reply
#2
(May-18-2022, 08:55 PM)michel77777 Wrote: Hi,

there is a simple Python appilaction, which reads data from SQL database and shows the result as plotly.graph_objects.

I want the get two values from UI for stock and day and read data from SQl database and show the data with plotly.graph_objects.
At the moment are both data hard coded:

stocksTicker = 'GRVI'
the_day='2021-10-14'

Could you please giv me some instractions how to extend the code to implement the requirements ?

Thanks in advance, Michel

df = pd.read_sql(selectString ,con=Engine)

trace1 = {
    'x': df.t_datetime,
    'open': df.o,
    'close': df.c,
    'high': df.h,
    'low': df.l,
    'type': 'candlestick',
    'name': stocksTicker,
    'showlegend': True
}

# Config graph layout
layout = go.Layout({
    'title': {
        'text': 'Moving Averages',
        'font': {
            'size': 15
        }
    }
})

fig=go.Figure([trace1])
fig.show()

solved
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Canvas refreshing problem Faruk 2 2,476 Dec-04-2018, 08:52 AM
Last Post: Faruk

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020