jupyter / declarativewidgets

[RETIRED] Jupyter Declarative Widget Extension
http://jupyter.org/declarativewidgets/docs.html
Other
120 stars 38 forks source link

Can't select the number format for multiple columns #523

Closed Etiennepi closed 8 years ago

Etiennepi commented 8 years ago

Hi, I have a table with a column for each day of the week and the time (0 to 1 am, 2 to 3 am, etc) as indexes. Each cell should pe a percentage, but I can't affect more than one column with a urth-viz-col with type=numeric. I've attempted placing one urth-viz-col tag for each day, only the first got taken into account. I've tried giving a list of all the columns as index, as well as not giving it an index at all. The best result I've been able to get was to set a single column's data as percentages. Any ideas what I might be doing wrong? Or could this be a bug?

peller commented 8 years ago

You should be able to provide separate <urth-viz-col> tags for each column. Can you provide an example?

Etiennepi commented 8 years ago

Hi, sure. Here's an example of the data I have:

columns_names = ['mon', 'tues', 'wed', 'thurs', 'fri', 'sat', 'sun']

data = np.random.rand(24, 7)
df = pd.DataFrame(data=data, columns=columns_names)

Here's the function that feeds the data to the table:

def table_function():
    newDf = df
    return newDf.reset_index()

And here is how my table is defined:

%%html
<template is="urth-core-bind">
    <urth-core-function ref="table_function"
                        result="{{table_function_result}}"
                        auto>
    </urth-core-function>
    <urth-viz-table datarows="{{table_function_result.data}}"
                    rows-visible="10"
                    columns="{{table_function_result.columns}}"
                    selection-as-object>
        <urth-viz-col format='0.00%' index=1 type=numeric></uth-viz-col>
        <urth-viz-col format='0.00%' index=2 type=numeric></uth-viz-col>
        <urth-viz-col format='0.00%' index=3 type=numeric></uth-viz-col>
        <urth-viz-col format='0.00%' index=4 type=numeric></uth-viz-col>
        <urth-viz-col format='0.00%' index=5 type=numeric></uth-viz-col>
        <urth-viz-col format='0.00%' index=6 type=numeric></uth-viz-col>
        <urth-viz-col format='0.00%' index=7 type=numeric></uth-viz-col>
    </urth-viz-table>
</template>

And here's the result I get, with only the 'mon' row appearing as percentages:

tablepercent

peller commented 8 years ago

@aluu317

lbustelo commented 8 years ago

@peller Any thoughts?

parente commented 8 years ago

Mobile thumb press. Sorry!

aluu317 commented 8 years ago

You're missing an 'r' at the closing tags for </urth-viz-col>

peller commented 8 years ago

Thanks @aluu317

Etiennepi commented 8 years ago

You were right, sorry for not catching that myself, and thanks.