Exemplo n.º 1
0
def signal_values():
    data = tresults.all().namedtuples()
    wp = jp.WebPage()
    chart_in, chart_out = jp.HighCharts(
        a=wp, options=CHART_DEF), jp.HighCharts(a=wp, options=CHART_DEF)
    series = defaultdict(lambda: defaultdict(list))
    for row in data:
        if row.ssid in ('Sunny Days 13', 'Sunny Days 3', 'Sunny Days 4',
                        'Sunny Days 15', 'SmallWall'):
            pass
        json = loads(row.json)
        series[row.type][row.ssid, 'recv'].append(
            to_Mbps(json['end']['sum_received']['bits_per_second']))
        series[row.type][row.ssid, 'sent'].append(
            -to_Mbps(json['end']['sum_sent']['bits_per_second']))

    chart_in.options.subtitle.text = 'Client to server direction'
    chart_in.options.series = [{
        'name': (ssid, type),
        'data': values
    } for (ssid, type), values in series[T_INPUT].items()]
    chart_out.options.subtitle.text = 'Server to client direction'
    chart_out.options.series = [{
        'name': (ssid, type),
        'data': values
    } for (ssid, type), values in series[T_OUTPUT].items()]
    return wp
Exemplo n.º 2
0
def app():
    wp = jp.QuasarPage()
    h1 = jp.QDiv(a=wp,
                 text="Analysis of Course Reviews",
                 classes="text-h4 text-center q-pa-md")

    hc = jp.HighCharts(a=wp, options=chart_def)
    hc.options.xAxis.categories = list(week_average.index)
    hc.options.series[0].data = list(week_average['Rating'])

    hc2 = jp.HighCharts(a=wp, options=chart_def2)
    hc2.options.xAxis.categories = list(month_average.index)
    hc2.options.series[0].data = list(month_average['Rating'])

    return wp
Exemplo n.º 3
0
def app():
    wp = jp.QuasarPage(dark=True)
    hc1 = jp.HighCharts(a=wp, options=aapl_chart)
    hc1.options.xAxis.categories = list(df_mon.index)
    hc1.options.series[0].data = list(df_mon["High"])

    return wp
def app():
    wp = jp.QuasarPage()
    h3z = jp.QDiv(a=wp,
                  text="Analysis of Course Reviews",
                  classes="text-h3 text-center")
    #    p1 = jp.QDiv(a=wp, text="The graphs represent review analysis")
    hc = jp.HighCharts(a=wp, options=chart_def)
    hc.options.title.text = "Average Rating by Day"
    hc.options.chart.inverted = False
    hc.options.subtitle.text = "The graphs represent review analysis"
    hc.options.xAxis.labels.format = "{value}"
    x = day_average.index
    y = day_average["Rating"]
    hc.options.xAxis.categories = list(x)
    hc.options.series[0].data = list(y)
    hc.options.xAxis.title.text = "Date"
    hc.options.yAxis.title.text = "Average Rating"
    hc.options.series[0].name = "Average Rating"
    hc.options.tooltip.pointFormat = "{point.x}: {point.y}"
    """
    x = [3, 6, 8]
    y = [4, 7, 9]
    hc.options.series[0].data = list(zip(x, y))
    hc.options.series[0].data = [[3, 4], [6, 7], [8, 9]]
    """
    return wp
Exemplo n.º 5
0
def grid_test():
    wp = jp.WebPage()
    grid = citi_df.jp.ag_grid(a=wp, options=grid_options)
    grid.options.pagination = True
    grid.options.paginationAutoPageSize = True
    grid.options.columnDefs[0].cellClass = ['text-white', 'bg-blue-500', 'hover:bg-blue-200']
    for col_def in grid.options.columnDefs[1:]:
        col_def.cellClassRules = {
            'font-bold': 'x < 20',
            'bg-red-300': 'x < 20',
            'bg-yellow-300': 'x >= 20 && x < 50',
            'bg-green-300': 'x >= 50'
        }
    #chart = jp.AgGrid(a=wp, options=ag_chart_options)
    high_chart = jp.HighCharts(a=wp,options=high_chart_options, classes='m-2 p-2 border', style='width: 600px')
    high_chart_2 = jp.HighCharts(a=wp,options=high_chart_options_2, classes='m-2 p-2 border', style='width: 600px')
    return wp
def app():
    wp = jp.QuasarPage()
    h1 = jp.QDiv(a=wp, text="Analysis of Course Reviews", classes="text-h4 text-center q-pa-md")
    
    hc = jp.HighCharts(a=wp, options=chart_def)
    month_crs_series = [{'name':course_name, 'data':[r for r in month_avg_crs[course_name]]} for course_name in month_avg_crs.columns]
    hc.options.xAxis.categories = list(month_avg_crs.index)
    hc.options.series = month_crs_series
    return wp
def app():
    wp = jp.QuasarPage()
    h1 = jp.QDiv(a=wp, text="Analysis of Course Reviews", classes="text-h3 text-center q-pa-md")
 
    hc = jp.HighCharts(a=wp, options=chart_def)
    hc.options.xAxis.categories = list(weekday_average.index.get_level_values(0))
    hc.options.series[0].data = list(round(weekday_average['Rating'],2))
 
    return wp
Exemplo n.º 8
0
def app():
    wp = jp.QuasarPage()
    

    hc = jp.HighCharts(a=wp, options=chart_def)
    hc.options.xAxis.categories = list(share.index)
    hc_data = [{"name":v1, "y":v2 } for v1,v2 in zip(share.index,share)]
    hc.options.series[0].data = hc_data

    return wp
Exemplo n.º 9
0
def app():
    wp = jp.QuasarPage() # We are creating a Quasar page object instance. Will return that instance.
    h1 = jp.QDiv(a=wp, text="Analysis of the happiest day of the week", classes="text-h3 text-center q-pa-md") # H1 Element
    p1 = jp.QDiv(a=wp, text="These graphs represent which day people are the happiest", classes="text-body1") # p Element

    hc = jp.HighCharts(a=wp, options=chart_def)
    hc_data = [{"name":course, "y":ratings} for course,ratings in zip(share.index, share)]
    hc.options.series[0].data = hc_data

    return wp
Exemplo n.º 10
0
def tab_comp_test():
    wp = jp.WebPage(data={'tab': 'id2556'})

    t = Tabs(a=wp,
             classes='w-3/4 m-4',
             style='',
             animation=True,
             content_height=550)
    for chart_type in ['bar', 'column', 'line', 'spline']:
        d = jp.Div(style=Tabs.wrapper_style, delete_flag=True)
        my_chart = jp.HighCharts(a=d,
                                 classes='m-2 p-2 border',
                                 style='width: 1000px;',
                                 options=my_chart_def,
                                 use_cache=False)
        my_chart.options.chart.type = chart_type
        my_chart.options.title.text = f'Chart of Type {chart_type.capitalize()}'
        my_chart.options.subtitle.text = f'Subtitle {chart_type.capitalize()}'
        t.add_tab(f'id{chart_type}', f'{chart_type}', d)

    d_flex = Div(classes='flex',
                 a=wp)  # Container for the two dog pictures tabs

    t = Tabs(a=d_flex,
             classes=' w-1/2 m-4',
             animation=True,
             content_height=550,
             model=[wp, 'tab'],
             change=tab_change)
    for pic_id in pics_papillons:
        d = jp.Div(style=Tabs.wrapper_style)
        jp.Img(
            src=
            f'https://images.dog.ceo/breeds/papillon/n02086910_{pic_id}.jpg',
            a=d)
        t.add_tab(f'id{pic_id}', f'Pic {pic_id}', d)

    t = TabsPills(a=d_flex,
                  classes='w-1/2 m-4',
                  animation=True,
                  content_height=550,
                  change=tab_change)
    for pic_id in pics_french_bulldogs:
        d = jp.Div(style=Tabs.wrapper_style)
        jp.Img(
            src=
            f'https://images.dog.ceo/breeds/bulldog-french/n02108915_{pic_id}.jpg',
            a=d)
        t.add_tab(f'id{pic_id}', f'Pic {pic_id}', d)

    input_classes = "w-1/3 m-2 bg-gray-200 border-2 border-gray-200 rounded w-64 py-2 px-4 text-gray-700 focus:outline-none focus:bg-white focus:border-purple-500"

    in1 = jp.Input(classes=input_classes, model=[wp, 'tab'], a=wp)

    return wp
Exemplo n.º 11
0
def app():
    wp = jp.QuasarPage()
    h1 = jp.QDiv(a=wp,
                 text="Analysis of Course Reviews",
                 classes="text-h3 text-center q-pa-md")
    p1 = jp.QDiv(a=wp, text="These graphs represent course review analysis")

    hc = jp.HighCharts(a=wp, options=chart_def)
    hc_data = [{"name": v1, "y": v2} for v1, v2 in zip(share.index, share)]
    hc.options.series[0].data = hc_data
    return wp
Exemplo n.º 12
0
def app():
    wp = jp.QuasarPage()
    h1 = jp.QDiv(a=wp, text="Analysis of Course Reviews", classes="text-h3 text-center q-pa-md")
    p1 = jp.QDiv(a=wp, text="These graphs represent course review analysis")
    hc = jp.HighCharts(a=wp, options=chart_def)
    hc.options.title.text = "Average Rating by Day"

    hc.options.xAxis.categories = list(day_average.index)
    hc.options.series[0].data = list(day_average['Rating'])

    return wp
def app():
    wp = jp.QuasarPage()
    hc = jp.HighCharts(a=wp, options=contents)
    hc.options.xAxis.categories = list(month_average_courses.index)
    hc.options.series = []
    for i in range(len(month_average_courses["Rating"].columns)):
        hc.options.series.append({})
        hc.options.series[i]["name"] = month_average_courses.columns[i]
        hc.options.series[i]["data"] = list(month_average_courses["Rating"].iloc[:, i])
    hc.options.legend.floating = False
    return wp
Exemplo n.º 14
0
def app():
    wp = jp.QuasarPage()
    

    hc = jp.HighCharts(a=wp, options=chart_def)
    hc.options.xAxis.categories = list(month_average_crs.index)

    hc_data = [{'name': v1, 'data': [v2 for v2 in month_average_crs[v1]]}
               for v1 in month_average_crs.columns]
    hc.options.series = hc_data

    return wp
Exemplo n.º 15
0
def app():
    wp = jp.QuasarPage()
    h1 = jp.QDiv(a=wp,
                 text="Analysis of Course Reviews",
                 classes="text-h1 text-right text-bold q-pa-sm")
    p1 = jp.QDiv(a=wp,
                 text="There graphs represent course reviedw analysis",
                 classes='q-mt-xl')

    hc = jp.HighCharts(a=wp, options=chart_def)
    hc.options.title.text = "Average Rating by Day"
    hc.options.xAxis.categories = list(week_average.index)
    hc.options.series[0].data = list(week_average['Rating'])

    return wp
Exemplo n.º 16
0
def app():
    wp = jp.QuasarPage()
    h1 = jp.QDiv(a=wp,
                 text="Happiness across Weekdays",
                 classes="text-h4 text-center q-pa-md")

    hc = jp.HighCharts(a=wp, options=chart_def)
    x = [avg_rating_weekday.index[i][1] for i in range(7)]
    print(x)
    y = list(avg_rating_weekday['Rating'])
    print(y)
    hc.options.xAxis.categories = x
    hc.options.series[0].name = "all courses"
    hc.options.series[0].data = y
    return wp
Exemplo n.º 17
0
def app():

    wp = jp.QuasarPage()
    h1 = jp.QDiv(a=wp, text="Analysis of Course Reviews", classes="text-h3 text-center q-pa-md") # H1 Element
    p1 = jp.QDiv(a=wp, text="These graphs represent course review analysis", classes="text-body1") # p Element

    hc = jp.HighCharts(a=wp, options=chart_def)

    hc.options.xAxis.categories = list(month_average_crs.index)

    hc_data = [ {"name": course, "data": [rating for rating in month_average_crs[course]]} for course in month_average_crs.columns ]

    hc.options.series = hc_data

    return wp
Exemplo n.º 18
0
def app():
    wp = jp.QuasarPage()
    h1 = jp.QDiv(a=wp,
                 text="Analysis of Course Reviews",
                 classes="text-h3 text-center q-pa-md")
    p1 = jp.QDiv(a=wp, text="These graphs represent course review analysis")

    hc = jp.HighCharts(a=wp, options=chart_def)
    hc.options.xAxis.categories = list(month_average_crs.index)

    hc_data = [{
        "name": v1,
        "data": [v2 for v2 in month_average_crs[v1]]
    } for v1 in month_average_crs.columns]
    hc.options.series = hc_data
    return wp
Exemplo n.º 19
0
def app():
    wp = jp.QuasarPage()
    hc = jp.HighCharts(a=wp, options=contents)
    total = 0
    for i in share:
        total += i
    percent = []
    for i in range(len(share)):
        percent.append(share[i] * 100 / total)
    hc.options.series[0].data = []
    names = share.index
    for i in range(len(percent)):
        d = {"name": names[i], "y": percent[i]}
        hc.options.series[0].data.append(d)
    hc.options.title.text = "Percent ratings for each course"
    return wp
def app():

    wp = jp.QuasarPage()
    h1 = jp.QDiv(a=wp,
                 text="Analysis of Course Reviews",
                 classes="text-h3 text-center q-pa-md")  # H1 Element
    p1 = jp.QDiv(a=wp,
                 text="These graphs represent course review analysis",
                 classes="text-body1")  # p Element

    hc = jp.HighCharts(a=wp, options=chart_def)

    hc.options.xAxis.categories = list(month_average.index)
    hc.options.series[0].data = list(month_average['Rating'])

    return wp
Exemplo n.º 21
0
def app():
    wp = jp.QuasarPage(
    )  # We are creating a Quasar page object instance. Will return that instance.
    h1 = jp.QDiv(a=wp,
                 text="Analysis of Course Reviews",
                 classes="text-h3 text-center q-pa-md")  # H1 Element
    p1 = jp.QDiv(a=wp,
                 text="These graphs represent course review analysis",
                 classes="text-body1")  # p Element

    hc = jp.HighCharts(a=wp,
                       options=chart_def)  # We will create our HighChart here.

    hc.options.xAxis.categories = list(week_average.index)
    hc.options.series[0].data = list(week_average['Rating'])

    return wp
Exemplo n.º 22
0
def app():
    web_page = jp.QuasarPage()
    h1 = jp.QDiv(a=web_page,
                 text="Analysis of Course Reviews",
                 classes="text-h1 text-center q-pa-md")

    hc = jp.HighCharts(a=web_page, options=chart_def)
    #print(hc.options)
    #print(type(hc.options))

    hc.options.title.text = 'Average Rating by Week'
    hc.options.series[0].name = 'Weekly Rating'
    hc.options.xAxis.categories = list(week_average.index)
    #hc.options.series[0].data = list(zip(day_average.index, day_average['Rating']))
    hc.options.series[0].data = list(week_average['Rating'])

    return web_page
def app():
    web_page = jp.QuasarPage()
    h1 = jp.QDiv(a=web_page,
                 text="Analysis of Course Reviews",
                 classes="text-h1 text-center q-pa-md")

    hc = jp.HighCharts(a=web_page, options=chart_def)

    hc.options.title.text = 'Monthly Average Rating by courses'
    #hc.options.series[0].name = 'Monthly Rating'
    hc.options.xAxis.categories = list(month_average_by_crs.index)
    hc_data = [{
        "name": v1,
        "data": [round(v2, 2) for v2 in month_average_by_crs[v1]]
    } for v1 in month_average_by_crs.columns]
    hc.options.series = hc_data

    return web_page
Exemplo n.º 24
0
def app():
    wp = jp.QuasarPage(
    )  # We are creating a Quasar page object instance. Will return that instance.
    h1 = jp.QDiv(a=wp,
                 text="Analysis of the happiest day of the week",
                 classes="text-h3 text-center q-pa-md")  # H1 Element
    p1 = jp.QDiv(
        a=wp,
        text="These graphs represent which day people are the happiest",
        classes="text-body1")  # p Element

    hc = jp.HighCharts(a=wp,
                       options=chart_def)  # We will create our HighChart here.

    hc.options.xAxis.categories = list(
        weekday_average.index.get_level_values(0))
    hc.options.series[0].data = list(weekday_average['Rating'])

    return wp
Exemplo n.º 25
0
def app():
    web_page = jp.QuasarPage()
    h1 = jp.QDiv(a=web_page,
                 text="Analysis of Course Reviews",
                 classes="text-h1 text-center q-pa-md")
    #p1 = jp.QDiv(a = web_page, text = "These graphs represent course review analysis",
    #             classes = "text-body1 text-weight-medium")

    hc = jp.HighCharts(a=web_page, options=chart_def)
    #print(hc.options)
    #print(type(hc.options))

    hc.options.title.text = 'Average Rating by Day'
    hc.options.series[0].name = 'Daily Rating'
    hc.options.xAxis.categories = list(day_average.index)
    #hc.options.series[0].data = list(zip(day_average.index, day_average['Rating']))
    hc.options.series[0].data = list(day_average['Rating'])

    return web_page
def app():
    wp = jp.QuasarPage()
    h3 = jp.QDiv(a=wp, text="Happiness over the week", classes="text-h3 text-center")
    hc = jp.HighCharts(a=wp, options=contents)
    hc.options.xAxis.categories = list(happiness.index.get_level_values(0))
    """
    hc.options.series = []
    for i in range(len(happiness["Rating"])):
        hc.options.series.append({})
        hc.options.series[i]["name"] = happiness.columns[i]
        hc.options.series[i]["data"] = list(happiness["Rating"].iloc[:, i])
    hc.options.legend.floating = False
"""
    del hc.options.series[1]
    """
    for i in range(len(happiness.index.get_level_values(0))):
        hc.options.series[i].name = happiness.index.get_level_values(0)[i]
"""
    hc.options.series[0].data = list(happiness["Rating"])
    hc.options.yAxis.title.text = "Rating"
    hc.options.title = "Happiness versus Day of the Week"
    return wp
Exemplo n.º 27
0
def iris_data():
    wp = jp.WebPage(highcharts_theme='gray', title='Iris Dataset', debug=True)
    jp.Div(
        text='Iris Dataset',
        classes=
        'text-3xl m-2 p-2 font-medium tracking-wider text-yellow-300 bg-gray-800 text-center',
        a=wp)
    d1 = jp.Div(classes='m-2 p-2 border-2', a=wp)
    chart_list = []
    for i, col1 in enumerate(iris.columns[:4]):
        d2 = jp.Div(classes='flex', a=d1)
        for j, col2 in enumerate(iris.columns[:4]):
            if i != j:  # Not on the diagonal
                chart = jp.HighCharts(a=d2,
                                      style='width: 300px; height: 300px',
                                      classes='flex-grow m-1')
                chart_list.append(chart.id)
                chart.chart_list = chart_list
                chart.on('tooltip', tooltip_formatter)
                chart.tooltip_y = 85
                chart.on('point_click', click_point)
                chart.col1 = col1
                chart.col2 = col2
                o = chart.options
                o.chart.type = 'scatter'
                o.chart.zoomType = 'xy'
                o.title.text = ''
                o.legend.enabled = False
                o.credits.enabled = False if i < 3 or j < 3 else True  # https://api.highcharts.com/highcharts/credits.enabled
                o.xAxis.title.text = col2 if i == 3 else ''
                o.yAxis.title.text = col1 if j == 0 else ''
                o.xAxis.crosshair = o.yAxis.crosshair = True
                for k, v in iris_species_frames.items():
                    s = jp.Dict()
                    s.name = k
                    s.allowPointSelect = True  # https://api.highcharts.com/highcharts/series.scatter.allowPointSelect
                    s.marker.states.select.radius = 8
                    s.data = list(zip(v.iloc[:, j], v.iloc[:, i]))
                    o.series.append(s)
            else:
                chart = jp.Histogram(list(iris.iloc[:, j]),
                                     a=d2,
                                     style='width: 300px; height: 300px',
                                     classes='flex-grow m-1')
                o = chart.options
                o.title.text = ''
                o.legend.enabled = False
                o.xAxis[0].title.text = col2 if i == 3 else ''
                o.xAxis[1].title.text = ''
                o.yAxis[0].title.text = col1 if j == 0 else ''
                o.yAxis[1].title.text = ''
                o.credits.enabled = False if i < 3 or j < 3 else True

    # Add two grids, first with the data and second with statistics describing the data
    iris.jp.ag_grid(a=wp,
                    classes='m-2 p-2',
                    style='height: 500px; width: 800px',
                    auto_size=True,
                    theme='ag-theme-balham-dark')
    iris_stats.jp.ag_grid(a=wp,
                          classes='m-2 p-2 border',
                          style='height: 500px; width: 950px',
                          auto_size=True,
                          theme='ag-theme-material')
    return wp
Exemplo n.º 28
0
def app():
    wp = jp.QuasarPage()
    hc = jp.HighCharts(a=wp, options=chart_def)

    return wp
Exemplo n.º 29
0
def app():
    wp = jp.QuasarPage(
    )  # We are creating a Quasar page object instance. Will return that instance.
    h1 = jp.QDiv(a=wp,
                 text="Analysis of Course Reviews",
                 classes="text-h3 text-center q-pa-md")  # H1 Element
    p1 = jp.QDiv(a=wp,
                 text="These graphs represent course review analysis",
                 classes="text-body1")  # p Element
    # We will add HighChart (another JustPy componenent) Graph. For choosing which graph we need, go to:
    # https://www.highcharts.com/docs/index > Charts and Series Types - HighCharts is a JavaScript Library
    # to produce Graphs.
    # Same as Quasar, which is another JavaScript Library, whoever it is unrelated to HighCharts.
    # Python is getting these 2 JavaScript Frameworks together.

    # In our case, we will use Spline Chart: https://www.highcharts.com/docs/chart-and-series-types/spline-chart
    # For this, we need the JavaScript code, so we open the chart in jsFiddle (upper-right corner of the graph),
    # and copy JS code after "   Highcharts.chart('container',   "   All the WAY to the last curly bracket (}) - and
    # we will paste it in our variable chart_def from above ^^^.

    hc = jp.HighCharts(a=wp,
                       options=chart_def)  # We will create our HighChart here.

    # Above 2 prints will only print (on VS Code Terminal, or whethever you run the script from) after we access the page.
    ###print(hc.options.) # same as the JS (actually JSON) code above on the chart_def variable. Python converts it into a Dictionary
    ###print(type(hc.options))

    # NOTE: We can ACCESS and MODIFY all the Dictionary attributes from above (i.e Title, Subtitle, etc) using
    # hc.options.<attribute>

    ###print(hc.options.title.text)
    hc.options.title.text = "Average Rating by Day"
    ###hc.options.series[0].data = [[3,4], [6,7], [8,9]] # [X,Y] axis values. However this is cumbersome and not the
    # proper way to add data. We add data this way:
    # x = [3, 6, 8]
    # y = [4, 7, 9]
    ###hc.options.series[0].data = list(zip(x, y)) # Will produce: [(3,4), (6,7), (8,9)]

    # NOW what really matter. Injecting data from a Dataframe to produce useful Graphs.

    import pandas
    from datetime import datetime
    from pytz import utc
    import matplotlib.pyplot as plt

    data = pandas.read_csv(
        '/Users/jose/Documents/Python Lessons (GitHub)/Python Mega Course - Udemy/Third Application: Data Analysis and Visualization (Part 2: Interactive Charts)/reviews.csv',
        parse_dates=['Timestamp'])

    # Average Rating by Day
    data['Day'] = data['Timestamp'].dt.date
    day_average = data.groupby(['Day']).mean()

    ###hc.options.series[0].data = list(zip(day_average.index, day_average['Rating']))
    # NOTE: However, this also won't fill out the graph because HighCharts considers the dates (day_average.index) as
    # categories types of data, not numbers. To solve this, we need to provide this data in this way:

    hc.options.xAxis.categories = list(
        day_average.index
    )  # We are creating "categories" key inside "xAxis" dictionary.
    hc.options.series[0].data = list(day_average['Rating'])

    return wp