Esempio n. 1
0
    p.grid.grid_line_color = None

    # add a text renderer to out plots (no data yet)
    r = p.text(x=[], y=[], text=[], text_color=[], text_font_size="20pt",
               text_baseline="middle", text_align="center")

    i = 0

    ds = r.data_source

    # create a callback that will add a number in a random location
    def callback():
        nonlocal i
        ds.data['x'].append(np.random.random()*70 + 15)
        ds.data['y'].append(np.random.random()*70 + 15)
        ds.data['text_color'].append(RdYlBu3[i%3])
        ds.data['text'].append(str(i))
        ds.trigger('data', ds.data, ds.data)
        i = i + 1

    # add a button widget and configure with the call back
    button = Button(label="Press Me")
    button.on_click(callback)

    plot_this = vplot(button, p)

    return plot_this

if __name__ == "__main__":
    plotman.run_session( plot(), session_id='test' )
    sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
    import context

### STANDARD-LIB IMPORTS ###
None

### 3RD-PARTY IMPORTS ###
None

### PROJECT IMPORTS ###
import gliderops.plots.plotman as plotman
from gliderops.dataman.mongoman import mongo_fetch
from gliderops.dataman.mongoclass import Sensor


### BOKEH IMPORTS ###

from bokeh.plotting import Figure
from bokeh.models.widgets import Slider, TextInput, Select

def plot():

    fig = Figure(title='template fig')

    return fig, []


if __name__ == "__main__":
    plotman.run_session( *plot() )

def get_sensornames(collection: str, db = util.DB,  connection = util.CONN):
    collection = connection[db][collection]
    cursor = collection.find({'_class':'gliderops.dataman.mongoclass.Sensor'},
                             {'name': 1, '_id': 0}) #get just the name, not the data
    sensor_names = []
    for s in cursor:
        sensor_names.append(s['name'])
    return sorted(sensor_names)

def truncate_filechunk(chunk_index, platformID) -> (int, int, str):

    chunk_index = abs(chunk_index)

    collection = util.CONN[util.DB][platformID]
    cursor = collection.find({'_class':'gliderops.dataman.parsers.ascmrg_parser.XBD_File'})
    print(cursor.count())
    cursor = cursor.sort('start',-1)
    doc = CLASSON.decode(cursor[chunk_index])

    return doc.start, doc.end, doc.filename




if __name__ == "__main__":
    import gliderops.plots.plotman as plotman
    plotman.run_session( plot(), session_id='timeseries')
else:
    curdoc().add_root( plot() )