Exemplo n.º 1
0
    def addtodoc(self, *_) -> List[Widget]:
        "creates the widget"
        cols  = [
            TableColumn(
                field      = i[0],
                title      = i[1],
                formatter  = (
                    StringFormatter() if i[2] == '' else
                    DpxNumberFormatter(format = i[2], text_align = 'right')
                ),
                width      = i[3]
            )
            for i in self.__theme.columns
        ]

        self.__widget = DataTable(
            source         = ColumnDataSource(self.__data()),
            columns        = cols,
            editable       = False,
            index_position = None,
            width          = self.__theme.width,
            height         = self.__theme.height,
            name           = "Messages:List"
        )
        return [self.__widget]
Exemplo n.º 2
0
 def __columns(self):
     return [
         TableColumn(
             field=i[0],
             title=i[1],
             width=i[2],
             formatter=DpxNumberFormatter(format=i[3], text_align='right')
             if i[3] else StringFormatter()) for i in self.__theme.columns
     ]
Exemplo n.º 3
0
        def get_formatter(data):
            if data.dtype.name == 'datetime64[ns]':
                return DateFormatter(format='%Y-%m-%d %H:%M:%S')
            if data.dtype.name in ['float64', 'int64']:
                return NumberFormatter(format='0.0[000]')
            if data.dtype.name == 'bool':
                return BooleanFormatter()

            return StringFormatter()
Exemplo n.º 4
0
    def __init__(self, datatable_height=300, datatable_width=700, check_shape=None):
        """Initialize a metadata handler.

        Args:
            datatable_height (int, optional): Height of datatable in screen pixels. Defaults to 300.
            datatable_width (int, optional): Width of plot area in screen pixels. Defaults to 700.
            check_shape (tuple, optional): A tuple to be used for checking shape of received images.
                If None, then no shape checks are conducted. Defaults to None.
        """
        # If we should verify image shape
        self.check_shape = check_shape

        # Metadata datatable
        datatable_source = ColumnDataSource(dict(metadata=["", "", ""], value=["", "", ""]))
        datatable = DataTable(
            source=datatable_source,
            columns=[
                TableColumn(field="metadata", title="Metadata Name"),
                TableColumn(field="value", title="Value"),
            ],
            width=datatable_width,
            height=datatable_height,
            index_position=None,
            selectable=False,
        )

        self._datatable_source = datatable_source
        self.datatable = datatable

        # Metadata issues datatable
        self._issues_menu = []
        issues_datatable_formatter = StringFormatter(font_style="bold", text_color="red")
        issues_datatable_source = ColumnDataSource(dict(issues=[]))
        issues_datatable = DataTable(
            source=issues_datatable_source,
            columns=[
                TableColumn(
                    field="issues", title="Metadata Issues", formatter=issues_datatable_formatter
                )
            ],
            width=datatable_width,
            height=datatable_height,
            index_position=None,
            selectable=False,
        )

        self._issues_datatable_source = issues_datatable_source
        self.issues_datatable = issues_datatable

        # Show all toggle
        show_all_toggle = CheckboxGroup(labels=["Show All Metadata"], default_size=145)
        self.show_all_toggle = show_all_toggle
 def _get_formatter(self, ctype: ColummDataType):
     if ctype == ColummDataType.FLOAT:
         return NumberFormatter(format=self._scheme.number_format)
     elif ctype == ColummDataType.INT:
         return NumberFormatter()
     elif ctype == ColummDataType.DATETIME:
         return DateFormatter(format="%c")
     elif ctype == ColummDataType.STRING:
         return StringFormatter()
     elif ctype == ColummDataType.PERCENTAGE:
         return NumberFormatter(format="0.000 %")
     else:
         raise Exception(f"Unsupported ColumnDataType: '{ctype}'")
    def create_table(self) -> None:
        """
        Create the table and populate prelim data.
        """
        self.table_data = dict(x=self.names, y=self.output_values)
        self.source = ColumnDataSource(self.table_data)
        columns = [
            TableColumn(field="x",
                        title="Outputs",
                        formatter=StringFormatter(font_style="bold")),
            TableColumn(field="y", title="Current Value"),
        ]

        self.table = DataTable(source=self.source,
                               columns=columns,
                               width=400,
                               height=280)
Exemplo n.º 7
0
def addtodoc(ctrl, theme, data) -> Tuple[Any, ColumnDataSource, DataTable]:
    "creates the widget"
    theme  = ctrl.theme.add(theme, False)
    src    = ColumnDataSource(data)
    cols   = [
        TableColumn(
            field = i[0], title = i[1], width = i[2],
            formatter = (
                StringFormatter() if i[3] == "" else
                DpxNumberFormatter(format = i[3], text_align = 'right')
            )
        )
        for i in theme.columns
    ]
    widget = DataTable(source         = src,
                       columns        = cols,
                       editable       = False,
                       index_position = None,
                       width          = theme.width,
                       height         = theme.tableheight,
                       header_row     = theme.headers)
    return theme, src, widget
Exemplo n.º 8
0
    def create_table(self) -> None:
        """
        Creates the bokeh table and populates variable data.
        """
        x_vals = [self._labels[var] for var in self._output_values.keys()]
        y_vals = list(self._output_values.values())

        table_data = dict(x=x_vals, y=y_vals)
        self._source = ColumnDataSource(table_data)
        columns = [
            TableColumn(
                field="x",
                title="Variable",
                formatter=StringFormatter(font_style="bold"),
            ),
            TableColumn(field="y", title="Current Value"),
        ]

        self.table = DataTable(
            source=self._source,
            columns=columns,
            sizing_mode="stretch_both",
            index_position=None,
        )
Exemplo n.º 9
0
    "SSSCC", "Bottle", "CTDPRS", "CTDSAL", "SALNTY", "Residual", "Flag",
    "Comments"
]
widths = [40, 20, 75, 65, 65, 65, 15, 135]
for (field, title, width) in zip(fields, titles, widths):
    if field == "flag":
        strfmt_in = {"text_align": "center", "font_style": "bold"}
    elif field == "Comments":
        strfmt_in = {}
    else:
        strfmt_in = {"text_align": "right"}
    columns.append(
        TableColumn(field=field,
                    title=title,
                    width=width,
                    formatter=StringFormatter(**strfmt_in)))

columns_changed = []
fields = ["SSSCC", "SAMPNO", "diff", "flag_old", "flag_new", "Comments"]
titles = ["SSSCC", "Bottle", "Residual", "Old", "New", "Comments"]
widths = [40, 20, 40, 20, 20, 200]
for (field, title, width) in zip(fields, titles, widths):
    if field == "flag_old":
        strfmt_in = {"text_align": "center", "font_style": "bold"}
    elif field == "flag_new":
        strfmt_in = {
            "text_align": "center",
            "font_style": "bold",
            "text_color": "red"
        }
    elif field == "Comments":
Exemplo n.º 10
0
from bokeh.embed import file_html
from bokeh.models import (ColumnDataSource, DataCube, GroupingInfo,
                          StringFormatter, SumAggregator, TableColumn)
from bokeh.resources import INLINE
from bokeh.util.browser import view

source = ColumnDataSource(data=dict(
    d0=['A', 'E', 'E', 'E', 'J', 'L', 'M'],
    d1=['B', 'D', 'D', 'H', 'K', 'L', 'N'],
    d2=['C', 'F', 'G', 'H', 'K', 'L', 'O'],
    px=[10, 20, 30, 40, 50, 60, 70],
))

target = ColumnDataSource(data=dict(row_indices=[], labels=[]))

formatter = StringFormatter(font_style='bold')

columns = [
    TableColumn(field='d2', title='Name', width=80, sortable=False, formatter=formatter),
    TableColumn(field='px', title='Price', width=40, sortable=False),
]

grouping = [
    GroupingInfo(getter='d0', aggregators=[SumAggregator(field_='px')]),
    GroupingInfo(getter='d1', aggregators=[SumAggregator(field_='px')])
]

cube = DataCube(source=source, columns=columns, grouping=grouping, target=target)

doc = Document()
doc.add_root(cube)
Exemplo n.º 11
0
def upload_table_data(attr, old, new):
	curdoc().get_model_by_name('informUser').text = 'uploading fusions'
	decoded = b64decode(new)
	f = io.BytesIO(decoded)
	totalData = []
	count = 0
	c = 0
	for line in f:
		line = line.decode('utf-8').strip().split('\t')
		if c == 0:
			line.insert(1, "subgroup")
		else:
			line.insert(1, " ")
		c += 1
		genes = line[0].split('--')
		totalData.append(line)
		if len(genes) > 2:
			count += 1
			for i in range(len(genes)-1):
				temp = [" "]*len(line)
				temp[10] = line[-(((len(genes)-1)*2)-(2*i))]
				temp[11] = line[-(((len(genes)-1)*2)-(2*i)-1)]
				temp[1] = "--".join(genes[i:i+2])
				totalData.append(temp)
	if count == 0:
		curdoc().get_model_by_name('tableSource').columns = [curdoc().get_model_by_name('tableSource').columns[0]] + curdoc().get_model_by_name('tableSource').columns[2:]
	else:
		if len(curdoc().get_model_by_name('tableSource').columns) < 7:
			curdoc().get_model_by_name('tableSource').columns.insert(1, TableColumn(field = " ", title = "Subgroup Name", formatter=StringFormatter(), width=450))
	headers = totalData.pop(0)
	new_df = pd.DataFrame(totalData, columns=headers)
	tableSource.data.update(ColumnDataSource(new_df).data)
	data_table = data_table_formatter(0, tableSource)
	currLayout = curdoc().get_model_by_name('subColumn').children
	currLayout.remove(curdoc().get_model_by_name("tableSource"))
	currLayout.append(data_table)
	curdoc().get_model_by_name('informUser').text = 'fusions uploaded'
Exemplo n.º 12
0
 def _fmt(i, j):
     return (StringFormatter(**self.__model.text) if i == '' else
             ((NumberFormatter if j else DpxNumberFormatter)(
                 format=i, **self.__model.number)))
Exemplo n.º 13
0
 def _fmt(line):
     return (StringFormatter(text_align='center') if line == '' else
             DpxNumberFormatter(format=line, text_align='right'))
Exemplo n.º 14
0
                          NumberEditor, NumberFormatter, Plot, SelectEditor,
                          StringEditor, StringFormatter, TableColumn)
from bokeh.resources import INLINE
from bokeh.sampledata.autompg2 import autompg2 as mpg
from bokeh.util.browser import view

source = ColumnDataSource(mpg)

manufacturers = sorted(mpg["manufacturer"].unique())
models = sorted(mpg["model"].unique())
transmissions = sorted(mpg["trans"].unique())
drives = sorted(mpg["drv"].unique())
classes = sorted(mpg["class"].unique())

columns = [
    TableColumn(field="manufacturer", title="Manufacturer", editor=SelectEditor(options=manufacturers), formatter=StringFormatter(font_style="bold")),
    TableColumn(field="model",        title="Model",        editor=StringEditor(completions=models)),
    TableColumn(field="displ",        title="Displacement", editor=NumberEditor(step=0.1),              formatter=NumberFormatter(format="0.0")),
    TableColumn(field="year",         title="Year",         editor=IntEditor()),
    TableColumn(field="cyl",          title="Cylinders",    editor=IntEditor()),
    TableColumn(field="trans",        title="Transmission", editor=SelectEditor(options=transmissions)),
    TableColumn(field="drv",          title="Drive",        editor=SelectEditor(options=drives)),
    TableColumn(field="class",        title="Class",        editor=SelectEditor(options=classes)),
    TableColumn(field="cty",          title="City MPG",     editor=IntEditor()),
    TableColumn(field="hwy",          title="Highway MPG",  editor=IntEditor()),
]
data_table = DataTable(source=source, columns=columns, editable=True, width=1000,
                       index_position=-1, index_header="row index", index_width=60)

plot = Plot(title=None, width=1000, height=300)
Exemplo n.º 15
0
def save_data():

    print("Save button clicked...")

    # df_out =


button.on_click(save_data)

columns = [
    TableColumn(
        field="SSSCC",
        title="SSSCC",
        width=40,
        formatter=StringFormatter(text_align="right"),
    ),
    TableColumn(
        field="CTDPRS",
        title="CTDPRS",
        width=80,
        formatter=StringFormatter(text_align="right"),
    ),
    TableColumn(
        field="REFOXY",
        title="REFOXY",
        width=80,
        formatter=StringFormatter(text_align="right"),
    ),
    TableColumn(
        field="CTDRINKO",
def TablaKmResumen(df):
    """
        DATOS EN FORMA DE TABLA POR PARCIALES KILOMETRICOS
    """
    dfTramosKm = TablaParcialesKilometricos(df)
    dfTramosKm['Ritmo_STR'] = dfTramosKm.Ritmo.apply(
        lambda x: FormateoTiempos(x, 'R'))
    OrigenTramosKm = ColumnDataSource(dfTramosKm)
    TablaKmResumen = [
        TableColumn(field='TramoKm',
                    title='Km',
                    width=40,
                    default_sort='ascending',
                    sortable=False,
                    formatter=StringFormatter(font_style='normal',
                                              text_align='center',
                                              text_color='black')),
        TableColumn(field='Ritmo_STR',
                    title='Ritmo[min/Km]',
                    width=80,
                    default_sort='ascending',
                    sortable=False,
                    formatter=StringFormatter(font_style='normal',
                                              text_align='center',
                                              text_color='black')),
        TableColumn(field='FrecuenciaCardiaca',
                    title='FC[ppm]',
                    width=80,
                    default_sort='ascending',
                    sortable=False,
                    formatter=NumberFormatter(format='0,0',
                                              language='es',
                                              rounding='round',
                                              font_style='normal',
                                              text_align='center',
                                              text_color='black')),
        TableColumn(field='Cadencia',
                    title='Cadencia[ppm]',
                    width=80,
                    default_sort='ascending',
                    sortable=False,
                    formatter=NumberFormatter(format='0,0',
                                              language='es',
                                              rounding='round',
                                              font_style='normal',
                                              text_align='center',
                                              text_color='black')),
        TableColumn(field='DesnivelAcumulado',
                    title='Desnivel',
                    width=80,
                    default_sort='ascending',
                    sortable=False,
                    formatter=NumberFormatter(format='0,0',
                                              language='es',
                                              rounding='round',
                                              font_style='normal',
                                              text_align='center',
                                              text_color='black'))
    ]
    PLT_TablaKmResumen = DataTable(source=OrigenTramosKm,
                                   columns=TablaKmResumen,
                                   width=360,
                                   height=550,
                                   fit_columns=False,
                                   sortable=False,
                                   reorderable=False,
                                   selectable=True,
                                   editable=False,
                                   index_position=None,
                                   header_row=True,
                                   row_height=25)

    return PLT_TablaKmResumen
Exemplo n.º 17
0
def TabParcialesKilometricos(df):
    """
        PREPARACION DE DATOS
    """
    # Calculo de los valores agregados
    AVG_Altitud, MAX_Altitud, MIN_Altitud, \
    AVG_Velocidad, MAX_Velocidad, MIN_Velocidad, \
    AVG_Ritmo, MAX_Ritmo, MIN_Ritmo, \
    AVG_FrecuenciaCardiaca, MAX_FrecuenciaCardiaca, MIN_FrecuenciaCardiaca, \
    AVG_Cadencia, MAX_Cadencia, MIN_Cadencia, \
    AVG_Temperatura, MAX_Temperatura, MIN_Temperatura, \
    AVG_LongitudZancada, MAX_LongitudZancada, MIN_LongitudZancada, \
    AVG_Pendiente, MAX_Pendiente , MIN_Pendiente = CalculosVectoresAgregados(df)

    # Calculo de desniveles finales
    DesnivelPositivo = df['DesnivelPositivoAcumulado'].max()
    DesnivelNegativo = df['DesnivelNegativoAcumulado'].max()
    DesnivelAcumulado = DesnivelPositivo + DesnivelNegativo
    DesnivelPorKilometro = (DesnivelAcumulado / df['Distancia'].max()) * 1000

    # Factor de achatamiento de la altitud
    if DesnivelPorKilometro > 40:
        OffsetSuperiorAltitud = 0.1
        OffsetInferiorAltitud = 0.03
    else:
        OffsetSuperiorAltitud = 2.5
        OffsetInferiorAltitud = 0.5

    dfTramosKm = TablaParcialesKilometricos(df)
    dfTramosKm['Ritmo_STR'] = dfTramosKm.Ritmo.apply(
        lambda x: FormateoTiempos(x, 'R'))

    # Seleccion de un subconjunto de datos para visualizar
    dfBokehParcialesKM = df[[
        'Bloque', 'Distancia', 'Altitud', 'FrecuenciaCardiaca', 'Cadencia'
    ]].copy()
    dfBokehParcialesKM['AltitudEscalada'] = Reescalado(
        dfBokehParcialesKM['Altitud'], [
            MIN_Altitud[0] -
            (MAX_Altitud[0] - MIN_Altitud[0]) * OffsetInferiorAltitud,
            MAX_Altitud[0] +
            (MAX_Altitud[0] - MIN_Altitud[0]) * OffsetSuperiorAltitud
        ], [0, dfTramosKm.Velocidad.max()])
    dfBokehParcialesKM['FrecuenciaCardiacaEscalada'] = Reescalado(
        dfBokehParcialesKM['FrecuenciaCardiaca'],
        [MIN_FrecuenciaCardiaca[0], MAX_FrecuenciaCardiaca[0]],
        [0, dfTramosKm.Velocidad.max()])
    dfBokehParcialesKM['CadenciaEscalada'] = Reescalado(
        dfBokehParcialesKM['Cadencia'], [MIN_Cadencia[0], MAX_Cadencia[0]],
        [0, dfTramosKm.Velocidad.max()])

    #  Reducion de la frecuencia de muestreo
    dfBokehParcialesKM_Agg = dfBokehParcialesKM.groupby('Bloque').resample(
        '10S').agg({
            'Distancia': np.max,
            'Cadencia': np.mean
        })
    dfBokehParcialesKM_Agg['Cadencia'] = dfBokehParcialesKM_Agg[
        'Cadencia'].round()
    dfBokehParcialesKM_Agg['CadenciaEscalada'] = Reescalado(
        dfBokehParcialesKM_Agg['Cadencia'], [MIN_Cadencia[0], MAX_Cadencia[0]],
        [0, dfTramosKm.Velocidad.max()])

    # Creacion de los ColumnDataSource de origen de Bokeh
    OrigenParcialesKM = ColumnDataSource(dfBokehParcialesKM)
    OrigenParcialesKM_Agg = ColumnDataSource(dfBokehParcialesKM_Agg)
    OrigenTramosKm = ColumnDataSource(dfTramosKm)

    # Asignacion de tamaño segun el total de puntos
    if df['Distancia'].max() < 5:
        SizeCircle = 10
    elif df['Distancia'].max() < 10:
        SizeCircle = 8
    else:
        SizeCircle = 5

    # Definicion de la paleta de colores por cadencia
    MapaColorCadencia = LinearColorMapper(palette=paleta_cadencia,
                                          low=110,
                                          high=190)
    """
        TRAMOS KILOMETRICOS | STRAVA
    """
    PLT_TramosKm = figure(plot_width=900,
                          plot_height=500,
                          x_range=(0, df['Distancia'].max()),
                          y_range=(0, dfTramosKm.Velocidad.max() * 1.1),
                          tools='',
                          toolbar_location=None)
    PLT_TramosKm.add_layout(
        Span(location=AVG_Velocidad[0],
             dimension='width',
             line_color=BlueJeans[2],
             line_dash='dashed',
             line_width=0.1,
             line_alpha=0.3))
    PLT_BarrasKM = PLT_TramosKm.rect(x='x',
                                     y='y',
                                     width='Distancia',
                                     height='Velocidad',
                                     source=OrigenTramosKm,
                                     line_width=1,
                                     line_color=BlueJeans[2],
                                     fill_color=BlueJeans[1])
    PLT_TramosKm.add_tools(
        HoverTool(tooltips=[('', '@Ritmo_STR')],
                  renderers=[PLT_BarrasKM],
                  mode='mouse'))

    PropiedadesLineas = dict(line_width=2,
                             line_alpha=0.7,
                             line_cap='round',
                             visible=False)
    PLT_TramosKM_Altitud = PLT_TramosKm.line('Distancia',
                                             'AltitudEscalada',
                                             source=OrigenParcialesKM,
                                             color=paleta_verde[6],
                                             **PropiedadesLineas)
    PLT_TramosKM_FC = PLT_TramosKm.line('Distancia',
                                        'FrecuenciaCardiacaEscalada',
                                        source=OrigenParcialesKM,
                                        color=paleta_rojo[6],
                                        **PropiedadesLineas)
    PLT_TramosKM_Cadencia = PLT_TramosKm.circle(
        'Distancia',
        'CadenciaEscalada',
        source=OrigenParcialesKM_Agg,
        size=SizeCircle,
        line_color=transform('Cadencia', MapaColorCadencia),
        color=transform('Cadencia', MapaColorCadencia),
        fill_alpha=1,
        visible=False)

    # Atributos
    PLT_TramosKm.title.text = 'RITMO MEDIO KILOMETRICO'
    PLT_TramosKm.sizing_mode = 'fixed'
    PLT_TramosKm.xaxis.axis_label = 'Distancia'
    PLT_TramosKm.xaxis.formatter = NumeralTickFormatter(format='0 a')
    PLT_TramosKm.yaxis.axis_label = 'Ritmo [min/km]'
    PLT_TramosKm.grid.visible = False
    PLT_TramosKm.yaxis.major_label_overrides = {
        1: '16:40',
        1.5: '16:06',
        2: '8:20',
        2.5: '6:40',
        3: '5:33',
        3.5: '4:45',
        4: '4:10',
        4.5: '3:42',
        5: '3:20',
        5.5: '3:01',
        6: '2:46',
        6.5: '2:34',
        7: '2:22'
    }
    PLT_TramosKm.xaxis.ticker = SingleIntervalTicker(interval=1000)
    PLT_TramosKm.xaxis.major_label_overrides = FormateoEjes(
        OrigenParcialesKM.data['Distancia'], 1000, 1000, 0, 0)
    """
        DATOS EN FORMA DE TABLA POR PARCIALES KILOMETRICOS
    """
    TablaKm = [
        TableColumn(field='TramoKm',
                    title='Km',
                    width=40,
                    default_sort='ascending',
                    sortable=False,
                    formatter=StringFormatter(font_style='normal',
                                              text_align='center',
                                              text_color='black')),
        TableColumn(field='Ritmo_STR',
                    title='Ritmo[min/Km]',
                    width=80,
                    default_sort='ascending',
                    sortable=False,
                    formatter=StringFormatter(font_style='normal',
                                              text_align='center',
                                              text_color='black')),
        TableColumn(field='FrecuenciaCardiaca',
                    title='FC[ppm]',
                    width=80,
                    default_sort='ascending',
                    sortable=False,
                    formatter=NumberFormatter(format='0,0',
                                              language='es',
                                              rounding='round',
                                              font_style='normal',
                                              text_align='center',
                                              text_color='black')),
        TableColumn(field='Cadencia',
                    title='Cadencia[ppm]',
                    width=80,
                    default_sort='ascending',
                    sortable=False,
                    formatter=NumberFormatter(format='0,0',
                                              language='es',
                                              rounding='round',
                                              font_style='normal',
                                              text_align='center',
                                              text_color='black')),
        TableColumn(field='DesnivelAcumulado',
                    title='Desnivel',
                    width=80,
                    default_sort='ascending',
                    sortable=False,
                    formatter=NumberFormatter(format='0,0',
                                              language='es',
                                              rounding='round',
                                              font_style='normal',
                                              text_align='center',
                                              text_color='black'))
    ]
    PLT_TablaKm = DataTable(source=OrigenTramosKm,
                            columns=TablaKm,
                            width=360,
                            height=550,
                            fit_columns=False,
                            sortable=False,
                            reorderable=False,
                            selectable=True,
                            editable=False,
                            index_position=None,
                            header_row=True,
                            row_height=25)
    """
        BOTONES
    """

    CodigoJS = """
    var indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
    
    l0.visible = indexOf.call(checkbox.active,0)>=0;
    l1.visible = indexOf.call(checkbox.active,1)>=0;
    l2.visible = indexOf.call(checkbox.active,2)>=0;
    """
    BotonesTramosKm = CheckboxButtonGroup(
        labels=["Altitud", "Frecuencia Cardiaca", "Cadencia"],
        active=[],
        width=300,
        height=30)
    CodigoJSTramosKm = CustomJS(code=CodigoJS,
                                args=dict(l0=PLT_TramosKM_Altitud,
                                          l1=PLT_TramosKM_FC,
                                          l2=PLT_TramosKM_Cadencia,
                                          checkbox=BotonesTramosKm))
    BotonesTramosKm.js_on_click(CodigoJSTramosKm)
    """
        LAYOUT
    """
    GridGraficaTramosKm = layout([
        Column(PLT_TramosKm, width=900, height=500),
        [
            Spacer(width=300, height=30),
            Column(BotonesTramosKm, width=300, height=30),
            Spacer(width=300, height=30)
        ]
    ],
                                 sizing_mode='stretch_width',
                                 width=900,
                                 height=570)
    GridTablaTramosKm = layout([
        Spacer(width=360, height=25),
        Column(PLT_TablaKm, width=360, height=550)
    ],
                               sizing_mode='stretch_width',
                               width=360,
                               height=570)
    GridAnalisisKm = gridplot([GridGraficaTramosKm, GridTablaTramosKm],
                              ncols=2,
                              sizing_mode='stretch_width',
                              toolbar_location=None,
                              plot_width=1000,
                              plot_height=570)

    return GridAnalisisKm
Exemplo n.º 18
0
pre_text = PreText(text="some text")

def mk_tab(color):
    plot = figure(width=300, height=300)
    plot.scatter(flowers["petal_length"], flowers["petal_width"], color=color, fill_alpha=0.2, size=12)
    return Panel(title="Tab 1: %s" % color.capitalize(), child=plot)

tabs = Tabs(tabs=[mk_tab("red"), mk_tab("green"), mk_tab("blue")])

source = ColumnDataSource(data=mpg)
columns = [
    TableColumn(field="manufacturer",
                title="Manufacturer",
                editor=SelectEditor(options=sorted(mpg["manufacturer"].unique())),
                formatter=StringFormatter(font_style="bold")),
    TableColumn(field="model",
                title="Model",
                editor=StringEditor(completions=sorted(mpg["model"].unique()))),
    TableColumn(field="displ",
                title="Displacement",
                editor=NumberEditor(step=0.1),
                formatter=NumberFormatter(format="0.0")),
    TableColumn(field="year",
                title="Year",
                editor=IntEditor()),
    TableColumn(field="cyl",
                title="Cylinders",
                editor=IntEditor()),
    TableColumn(field="trans",
                title="Transmission",
elements['name_lower'] = elements['name'].str.lower()
source = ColumnDataSource(elements)

html_font_template = '<font color="<%= CPK %>"><%= value %></font>'
html_image_template = """
<a href="http://images-of-elements.com/<%= value %>.php" target="_blank">
  <img src="http://images-of-elements.com/<%= value %>.jpg" style="width:40px;height:40px;border:0">
</a>
"""
columns = [
    TableColumn(field='atomic number',
                title='Atomic Number',
                formatter=NumberFormatter(text_align="right")),
    TableColumn(field='symbol',
                title='Symbol',
                formatter=StringFormatter(text_align="center")),
    TableColumn(field='name',
                title='Name',
                formatter=HTMLTemplateFormatter(template=html_font_template)),
    TableColumn(field='name_lower',
                title='Image',
                formatter=HTMLTemplateFormatter(template=html_image_template))
]
data_table = DataTable(source=source,
                       columns=columns,
                       editable=False,
                       row_height=45)

save(data_table)
Exemplo n.º 20
0
###########################

table_dict = {}
table_dict["tok"]  = []
table_dict["rate"] = []
table_dict["liq"]  = []
for tok in tokens:
    table_dict["tok"].append(tok.upper())
    table_dict["rate"].append(round(_rate[tok][-1],2))
    table_dict["liq"].append(int(_liq[tok][-1]))


pdsource = ColumnDataSource(data=pd.DataFrame(table_dict))

columns = [
    TableColumn(field="tok", title="Token", formatter=StringFormatter(text_align="center")),
    TableColumn(field="rate", title="Price [ZIL]",  formatter=StringFormatter(text_align="center")),
    TableColumn(field="liq", title="Liquitidy [ZIL]", formatter=NumberFormatter(text_align="center")),
]
table = DataTable(source=pdsource, columns=columns, height=193, width=330, name="table", sizing_mode="scale_both")

#layout = row(region, table)
curdoc().add_root(region)
curdoc().add_root(table)


###########################
###        Setup       ####
###########################