Esempio n. 1
0
            self.plotly_user_config['plotly_streaming_tokens'][0])
        self.stream.open()

    def notify(self, observable, *args, **kwargs):
        # write to plotly
        if 'value' in kwargs:
            # self.stream.write({'x': datetime.datetime.now(), 'y': kwargs['value']})
            self.stream.write({'x': kwargs['timestamp'], 'y': kwargs['value']})


# import plotly.plotly as py
# from plotly.graph_objs import *

# trace0 = Scatter(
#     x=[1, 2, 3, 4],
#     y=[10, 15, 13, 17]
# )
# trace1 = Scatter(
#     x=[1, 2, 3, 4],
#     y=[16, 5, 11, 9]
# )
# data = Data([trace0, trace1])

# unique_url = py.plot(data, filename = 'basic-line')

if __name__ == '__main__':
    subject = Observable()
    plyobs = plotlyObserver(subject, 'config.json', 'test stream plot')
    subject.notify_observers(value=45)
    subject.notify_observers(value=55)