Пример #1
0
line_cumul_county = page.ui.charts.chartJs.line(y_columns=["cases", "deaths"],
                                                x_axis="date")
line_cumul_county.options.scales.y_axis().ticks.toNumber()
line_cumul_county.options.stacked = True
line_cumul_county.options.tooltips.callbacks.labelNumber()

# Create a container for the HTML page
box = page.studio.containers.box()
box.extend([
    dt, title_us, bar_states, title_state, line_cumul, title_county, row,
    title, line_cumul_county
])
box.style.standard()

# Group data for the processing on the JavaScript side
grp = page.data.js.record(std.var("covidData",
                                  global_scope=True)).filterGroup("aggData")
grp2 = page.data.js.record(std.var("covidData",
                                   global_scope=True)).filterGroup("aggData2")
grp3 = page.data.js.record(std.var("covidData",
                                   global_scope=True)).filterGroup("aggData3")
grp4 = page.data.js.record(std.var("covidData",
                                   global_scope=True)).filterGroup("aggData4")
grp5 = page.data.js.record(std.var("covidData",
                                   global_scope=True)).filterGroup("aggData5")

# Events sections for the interactivity
dt.select([
    bar_states.build(
        grp.match(datamap(components=[dt])).group().sumBy(
            ["cases", "deaths", "flips"], ["state"], cast_vals=True)),
])
Пример #2
0
    [cols_keys.dom.add(events.value),
     button.dom.events.trigger("click")])

line = page.ui.charts.chartJs.line(x_axis="Date", profile=True)
x_axis = line.options.scales.x_axes()
#x_axis.type = "time"
x_axis.ticks.callback("@")
line.options.elements.point.radius = 0
#line.options.scales.x_axes().distribution = 'linear'

tag = page.ui.rich.powered()
tag.style.css.margin_bottom = 5
tag.style.css.margin_top = 5

items.enter([cols_keys.dom.add(items.dom.content), items.dom.empty()])

button.click([
    std.var("graphData").fromArrayToRecord().setVar("records"),
    line.build(std.var("records"),
               options={
                   "y_columns": cols_keys.dom.content,
                   "x_axis": "Date"
               })
])

page.body.onReady([items.js.source(std.var("graphData")[0])])

if __name__ == "__main__":
    # If the script is run directly for Python.
    page.outs.html_file()
Пример #3
0
items.options.on_select([
  cols_keys.dom.add(events.value, category='Country/Region'),
  button.dom.events.trigger("click")
])

bar = page.ui.charts.chartJs.bar([], ['Confirmed', 'Deaths', 'Recovered'], 'Country/Region')
bar.options.scales.y_axis().ticks.toNumber()

ref = page.ui.texts.references.website(author="rsharankumar", name="Learn Data Science in 100Days", site="github",
                                       url="https://github.com/rsharankumar/Learn_Data_Science_in_100Days")

box = page.studio.containers.box()
box.extend([title, items, page.ui.div([button_all, button_clear]), cols_keys, button, bar, ref])
box.style.standard()

grp = page.data.js.record(std.var("covidData", global_scope=True)).filterGroup("aggData")

button.click([
  page.js.console.log(cols_keys.dom.content),
  bar.build(grp.match(cols_keys.dom.content).group().sumBy(['Confirmed', 'Deaths', 'Recovered'], ['Country/Region']))
])

countries = set()
for rec in data:
  countries.add(rec['Country/Region'])

button_all.click([
  cols_keys.dom.clear(), cols_keys.dom.add(list(countries), category='Country/Region', no_duplicate=False)])
button_clear.click([cols_keys.dom.clear()])

page.body.onReady([std.var("covidData", data, global_scope=True), items.js.source(list(countries))])
Пример #4
0
def create_page():
    page = Report()
    page.headers.dev()
    page.body.add_template(defined_style="doc")
    page.theme = ThemeBlue.BlueGrey()

    title = page.ui.title("Python")
    page.ui.layouts.underline()
    title.options.editable = True

    sub_title = page.ui.titles.subtitle("The Python Community")
    page.ui.menu(sub_title, post="/bar")

    p = page.ui.paragraph('''
  The [Python Software Foundation](https://www.python.org/psf/) and the global Python community welcome and encourage 
  participation by everyone. Our community is based on mutual respect, tolerance, and encouragement, and we are working 
  to help each other live up to these principles.
  ''',
                          options={"markdown": True})
    page.ui.menu(p)

    table = page.ui.tables.tabulator(mocks.languages)
    page.ui.tables.menu(table, post="/table")

    page.ui.titles.subtitle("Zoom on a package")
    pkg_name = page.ui.fields.input("epyk",
                                    label="Package name",
                                    html_code="package")

    bar_chart = page.ui.charts.chartJs.bar(y_columns=["download"],
                                           x_axis="name")
    menu_bar = page.ui.charts.menu(bar_chart,
                                   post={
                                       "url": "/chart",
                                       "components": [pkg_name]
                                   })

    pie_chart = page.ui.charts.chartJs.pie(y_columns=["value"], x_axis="type")
    menu_pie = page.ui.charts.menu(pie_chart,
                                   post={
                                       "url": "/pie",
                                       "components": [pkg_name]
                                   })

    row = page.ui.row([[menu_bar, bar_chart], [menu_pie, pie_chart]],
                      position="top")
    row.options.responsive = False
    row.options.autoSize = False

    sub_title2 = page.ui.titles.subtitle("Conferences and Workshops")
    sub_title2.options.editable = True
    p2 = page.ui.paragraph('''
  There are a number of conferences held each year where the Python community gathers together (listed alphabetically):
  ''',
                           options={"markdown": True})
    page.ui.menu(p2,
                 save_funcs=[page.js.alert(p2.dom.content)],
                 update_funcs=[p2.build("Updated paragraph")],
                 profile=True)

    sq = page.ui.lists.squares(["DjangoCon Europe"])
    page.ui.lists.menu(sq)

    page.ui.layouts.hr().css({"margin-top": '20px'})
    page.ui.titles.subtitle("Report powered by")
    page.ui.rich.powered()

    page.ui.icons.fixed("fas fa-file-download").click([
        std.var("backboneData", global_scope=True).addComponent(sub_title),
        page.js.clipboard(
            std.var("backboneData", global_scope=True).stringify()),
        page.js.window.download(
            page.js.window.btoa(
                std.var("backboneData", global_scope=True).stringify()),
            "configuration.json")
        # page.js.location.download(page.js.location.getUrlFromData(std.var("backboneData", global_scope=True).stringify()))
    ])

    page.body.onReady([
        std.var("backboneData", value={}, global_scope=True),
    ])
    return page
Пример #5
0
line_cumul.options.stacked = True
line_cumul.options.tooltips.callbacks.labelNumber()

title = page.ui.title()
line_cumul_county = page.ui.charts.chartJs.line(y_columns=["cases", "deaths"], x_axis="date")
line_cumul_county.options.scales.y_axis().ticks.toNumber()
line_cumul_county.options.stacked = True
line_cumul_county.options.tooltips.callbacks.labelNumber()

# Create a container for the HTML page
box = page.studio.containers.box()
box.extend([dt, page.ui.row([us, [title_state, line_cumul]]), title_county, row, title, line_cumul_county])
box.style.configs.doc(background=page.theme.greys[0])

# Group data for the processing on the JavaScript side
grp = page.data.js.record(std.var("covidData", global_scope=True)).filterGroup("aggData")
grp2 = page.data.js.record(std.var("covidData", global_scope=True)).filterGroup("aggData2")
grp3 = page.data.js.record(std.var("covidData", global_scope=True)).filterGroup("aggData3")
grp4 = page.data.js.record(std.var("covidData", global_scope=True)).filterGroup("aggData4")
grp5 = page.data.js.record(std.var("covidData", global_scope=True)).filterGroup("aggData5")

# Events sections for the interactivity
dt.select(
  us.build(grp.match(datamap(components=[dt])).group().sumBy(["deaths"], ["state"], cast_vals=True).to_dict('state', 'deaths') )
)

us.click([
  title_state.build(us.activePoints().label),
  bar.build(grp.match(datamap(attrs={"state": us.activePoints().label}, components=[dt])).group().sumBy(["cases", "deaths"], ["county"], cast_vals=True)),
  bar_total.build(grp4.match(datamap(attrs={"state": us.activePoints().label}, components=[dt])).group().sumBy(["cases", "deaths", "fips"], ["state"], cast_vals=True)),
  line_cumul.build(grp2.match(datamap(attrs={"state": us.activePoints().label})).group().sumBy(["cases", "deaths"], ["date"], cast_vals=True)),
Пример #6
0
button_all = page.ui.button("All languages")
button_all.style.css.margin_top = 5
button_all.style.css.margin_left = 20
button_all.style.css.margin_bottom = 5

table = page.ui.table()
table.config.layout.fitDataFill()
table.config.paginationSize = 10
table.style.strip()

box = page.studio.containers.box()
box.extend([title, items, cols_keys, items, button, button_all, table])
box.style.standard()

button.click([
    table.js.clearData(),
    table.js.setDataFromArray(
        std.var("graphData"),
        header=cols_keys.dom.content,
        formatters={
            "Date":
            "(function(data){return data['Date'].toISOString().split('T')[0]})"
        }),
    table.js.redraw(True),
])

button_all.click([cols_keys.dom.add(std.var("graphData")[0])])

page.body.onReady([items.js.source(std.var("graphData")[0])])
Пример #7
0
cols_keys.items_style(style="bullets")
cols_keys.drop()

button = page.ui.buttons.colored("Display")
button.style.css.margin_top = 5

items.options.on_select([
  cols_keys.dom.add(events.value),
  button.dom.events.trigger("click")
])

line = page.ui.charts.c3.line(x_axis="Date")

tag = page.ui.rich.powered()
tag.style.css.margin_bottom = 5
tag.style.css.margin_top = 5

box = page.studio.containers.box()
box.extend([title, tag, items, cols_keys, button, line])
box.style.standard()

items.enter([cols_keys.dom.add(items.dom.content), items.dom.empty()])

button.click([
  std.var("graphData").fromArrayToRecord().setVar("records"),
  page.js.console.log(cols_keys.dom.content),
  line.build(std.var("records"), options={"y_columns": cols_keys.dom.content, "x_axis": "Date"})
])

page.body.onReady([items.js.source(std.var("graphData")[0])])
Пример #8
0
row2 = page.ui.row([world2, [title_country2, bar2]], position="top")
row2.set_size_cols(7)
row2.options.responsive = False

powered = page.ui.rich.powered()
ref = page.ui.texts.references.website(author="rsharankumar", name="Learn Data Science in 100Days", site="github",
                                       url="https://github.com/rsharankumar/Learn_Data_Science_in_100Days")

# Create a container for the HTML page
box = page.ui.div()
box.extend([title, powered, row, row2, ref])
box.style.configs.doc(background="white")

# Group data for the processing on the JavaScript side
grp = page.data.js.record(std.var("covidData", global_scope=True)).filterGroup("aggData")
grp3 = page.data.js.record(std.var("covidData", global_scope=True)).filterGroup("aggData3")
grp2 = page.data.js.record(std.var("covidData", global_scope=True)).filterGroup("aggData2")

world.click([
  page.js.if_(world.activePoints().label == "United States of America", [
    title_country.build("US"),
    bar.build(grp.match(datamap(attrs={"Country/Region": "US"})).group().sumBy(
      ["Deaths", 'Confirmed', 'Recovered'], ["Country/Region"], cast_vals=True))
  ]).else_([
    title_country.build(world.activePoints().label),
    bar.build(grp3.match(datamap(attrs={"Country/Region": world.activePoints().label})).group().sumBy(
      ["Deaths", 'Confirmed', 'Recovered'], ["Country/Region"], cast_vals=True))
  ])
])