当前位置: 首页>>代码示例>>Python>>正文


Python pygal.style方法代码示例

本文整理汇总了Python中pygal.style方法的典型用法代码示例。如果您正苦于以下问题:Python pygal.style方法的具体用法?Python pygal.style怎么用?Python pygal.style使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pygal的用法示例。


在下文中一共展示了pygal.style方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: graph_users

# 需要导入模块: import pygal [as 别名]
# 或者: from pygal import style [as 别名]
def graph_users():
    clio = Clio()
    
    bar_chart = pygal.Bar(style=LightColorizedStyle, show_x_labels=True, config=PYGAL_CONFIG)
    bar_chart.title = "Kippo/Cowrie Top Users"
    clio = Clio()
    top_users = clio.hpfeed.count_users(get_credentials_payloads(clio))
    for user_list in top_users:
        user,password = user_list
        user = remove_control_characters(user)
        bar_chart.add(user, [{'label':user, 'xlink':'', 'value':password}])

    return bar_chart.render_response() 
开发者ID:CommunityHoneyNetwork,项目名称:CHN-Server,代码行数:15,代码来源:views.py

示例2: assignment_stats

# 需要导入模块: import pygal [as 别名]
# 或者: from pygal import style [as 别名]
def assignment_stats(cid, aid):
    courses, current_course = get_courses(cid)
    assign = Assignment.query.filter_by(id=aid, course_id=cid).one_or_none()
    if not Assignment.can(assign, current_user, 'edit'):
        flash('Insufficient permissions', 'error')
        return abort(401)

    stats = Assignment.assignment_stats(assign.id)

    submissions = [d for d in stats.pop('raw_data')]

    pie_chart = pygal.Pie(half_pie=True, disable_xml_declaration=True,
                          style=CleanStyle,
                          inner_radius=.5, legend_at_bottom=True)
    pie_chart.title = 'Students submission status'
    pie_chart.add('Students with Submissions', stats['students_with_subm'])
    pie_chart.add('Students with Backups', stats['students_with_backup'])
    pie_chart.add('Not Started', stats['students_no_backup'])

    return render_template('staff/course/assignment/assignment.stats.html',
                           assignment=assign, subm_chart=pie_chart,
                           courses=courses, stats=stats, submissions=submissions,
                           current_course=current_course) 
开发者ID:okpy,项目名称:ok,代码行数:25,代码来源:admin.py

示例3: graph_combos

# 需要导入模块: import pygal [as 别名]
# 或者: from pygal import style [as 别名]
def graph_combos():
    clio = Clio()
    
    bar_chart = pygal.Bar(style=LightColorizedStyle, show_x_labels=True, config=PYGAL_CONFIG)
    bar_chart.title = "Kippo/Cowrie Top User/Passwords"
    clio = Clio()
    top_combos = clio.hpfeed.count_combos(get_credentials_payloads(clio))
    for combo_list in top_combos:
        user,password = combo_list
        user = remove_control_characters(user)
        bar_chart.add(user,[{'label':user,'xlink': '', 'value':password}])

    return bar_chart.render_response() 
开发者ID:CommunityHoneyNetwork,项目名称:CHN-Server,代码行数:15,代码来源:views.py

示例4: graph_passwords

# 需要导入模块: import pygal [as 别名]
# 或者: from pygal import style [as 别名]
def graph_passwords():
    clio = Clio()
    
    bar_chart = pygal.Bar(style=LightColorizedStyle, show_x_labels=True, config=PYGAL_CONFIG)
    bar_chart.title = "Kippo/Cowrie Top Passwords"
    clio = Clio()
    top_passwords = clio.hpfeed.count_passwords(get_credentials_payloads(clio))
    for password_data in top_passwords:
        password,count = password_data
        password = remove_control_characters(password)
        bar_chart.add(password, [{'label': password, 'xlink': '', 'value':count}])

    return bar_chart.render_response() 
开发者ID:CommunityHoneyNetwork,项目名称:CHN-Server,代码行数:15,代码来源:views.py

示例5: graph_top_attackers

# 需要导入模块: import pygal [as 别名]
# 或者: from pygal import style [as 别名]
def graph_top_attackers():
    clio = Clio()
    
    bar_chart = pygal.Bar(style=LightColorizedStyle, show_x_labels=True, config=PYGAL_CONFIG)
    bar_chart.title = "Kippo/Cowrie Top Attackers"
    clio = Clio()
    top_attackers = top_kippo_cowrie_attackers(clio)
    print(top_attackers)
    for attacker in top_attackers:
        bar_chart.add(str(attacker['source_ip']), attacker['count'])

    return bar_chart.render_response() 
开发者ID:CommunityHoneyNetwork,项目名称:CHN-Server,代码行数:14,代码来源:views.py

示例6: item_view

# 需要导入模块: import pygal [as 别名]
# 或者: from pygal import style [as 别名]
def item_view(itm_code):
    all_check_items = dashboard_check_cfg.getAllChkItems()
    if not [c for c in all_check_items if c.itm_code == itm_code]:
        flash('There is no checking item with code as "%s", pls check.' % (itm_code), category="info")
        check_item = None
    else:
        check_item = [c for c in all_check_items if c.itm_code == itm_code][0]

    svg_status_stat_short = None
    svg_status_stat_long = None

    if check_item:
        chart = initStatusChart(check_item, isShortTerm=True)
        svg_status_stat_short = chart.render()
        chart = initStatusChart(check_item, isShortTerm=False)
        svg_status_stat_long = chart.render()
        svg_status_stat_long = '<svg  style="width:2100px" ' + svg_status_stat_long[4:]  # set canvas size

    svg_value_stat_short = None
    svg_value_stat_long = None
    owner_teams = []
    if check_item:
        owner_teams = check_item.owner_team_list.replace(',', ';').split(';')
        owner_teams = [team.strip() for team in owner_teams]

        if check_item.check_value_is_number == 'Y':
            chart = initValueChart(check_item, isShortTerm=True)
            svg_value_stat_short = chart.render()

            chart = initValueChart(check_item, isShortTerm=False)
            svg_value_stat_long = chart.render()
            svg_value_stat_long = '<svg  style="width:2100px" ' + svg_value_stat_long[4:]  # set canvas size

    return render_template("check_item.html",
                           check_item=check_item,
                           owner_teams=owner_teams,
                           svg_status_stat_short=svg_status_stat_short,
                           svg_status_stat_long=svg_status_stat_long,
                           svg_value_stat_short=svg_value_stat_short,
                           svg_value_stat_long=svg_value_stat_long,
                           ) 
开发者ID:harryliu,项目名称:edwin,代码行数:43,代码来源:views.py

示例7: _show_plot

# 需要导入模块: import pygal [as 别名]
# 或者: from pygal import style [as 别名]
def _show_plot(self, start, finish, center, points, title):

    from pygal.style import Style

    custom_style = Style(colors=('#aaaaaa', '#00ff00', '#ff0000', '#0000ff'))

    xy_chart = pygal.XY(stroke=False, style=custom_style)
    xy_chart.title = title
    xy_chart.add('path', points)
    xy_chart.add('start', [(start['X'], start['Y'])])
    xy_chart.add('finish', [(finish['X'], finish['Y'])])
    xy_chart.add('center', [(center['X'], center['Y'])])
    xy_chart.render_to_file('{}.svg'.format(title)) 
开发者ID:intelligent-agent,项目名称:redeem,代码行数:15,代码来源:test_G2_G3.py

示例8: initStatusChart

# 需要导入模块: import pygal [as 别名]
# 或者: from pygal import style [as 别名]
def initStatusChart(check_item, isShortTerm=True):
    statistics = CheckItemStatistics(check_item)
    if isShortTerm:
        data = statistics.getShortTermStatusData()
        # data elements: [date_list, normal_list, warning_list, critical_list, term_month_count]
        term_month_count = data[4]
        title = 'Status statistics in short term(%d months)' % (term_month_count)

    else:
        data = statistics.getLongTermStatusData()
        # data elements: [date_list, normal_list, warning_list, critical_list, term_month_count]
        term_month_count = data[4]
        title = 'Status statistics in long term(%d months)' % (term_month_count)

    date_list = data[0]
    date_list_short_format = getDatesInShortFormat(date_list)
    key_date_list_short_format = getDatesInShortFormat(getKeyDates(date_list))
    normal_list = data[1]
    warning_list = data[2]
    critical_list = data[3]

    custom_style = Style(colors=(
        '#b6e354'  # green
        , '#fd971f'  # yellow
        , '#DC3912'  # red
        ))
    chart = pygal.Line(style=custom_style, legend_at_bottom=True, legend_box_size=18)
    SITE_ROOT = os.path.realpath(os.path.dirname(__file__))
    chart.js = [os.path.join(SITE_ROOT, "static/js/", "svg.jquery.js"),
                os.path.join(SITE_ROOT, "static/js/", "pygal-tooltips.js")]
    if isShortTerm:
        chart.height = 420
        chart.width = 900
    else:
        chart.height = 420
        chart.width = 2000
    chart.disable_xml_declaration = True  # disable xml root node
    chart.x_label_rotation = 30
    chart.title = title
    chart.x_title = 'Timeline'
    chart.y_title = 'Status count'

    chart.x_labels = map(str, date_list_short_format)
    chart.x_labels_major = key_date_list_short_format
    chart.add('Normal count', normal_list)
    chart.add('Warning count', warning_list)
    chart.add('Critical count', critical_list)

    return chart 
开发者ID:harryliu,项目名称:edwin,代码行数:51,代码来源:views.py

示例9: initValueChart

# 需要导入模块: import pygal [as 别名]
# 或者: from pygal import style [as 别名]
def initValueChart(check_item, isShortTerm=True):
    statistics = CheckItemStatistics(check_item)
    if isShortTerm:
        data = statistics.getShortTermValueData()
        term_month_count = data[6]
        # data elements: [date_list, avg_value_list, min_value_list, max_value_list, warning_limit_list, critical_limit_list, term_month_count]
        title = 'Value statistics in short term(%d months)' % (term_month_count)
    else:
        data = statistics.getLongTermValueData()
        # data elements: [date_list, avg_value_list, min_value_list, max_value_list, warning_limit_list, critical_limit_list, term_month_count]
        term_month_count = data[6]
        title = 'Value statistics in long term(%d months)' % (term_month_count)

    date_list = data[0]
    date_list_short_format = getDatesInShortFormat(date_list)
    key_date_list_short_format = getDatesInShortFormat(getKeyDates(date_list))
    avg_value_list = data[1]
    min_value_list = data[2]
    max_value_list = data[3]
    warning_limit_list = data[4]
    critical_limit_list = data[5]

    custom_style = Style(colors=(
        '#fd971f'  # yellow--warning
        , '#DC3912'  # red--critical
        , '#6c71c4'  # min
        , '#8000FF'  # max
        , '#00FFFF'  # avg
        ))
    chart = pygal.Line(style=custom_style, legend_at_bottom=True, legend_box_size=18)
    SITE_ROOT = os.path.realpath(os.path.dirname(__file__))
    chart.js = [os.path.join(SITE_ROOT, "static/js/", "svg.jquery.js"),
                os.path.join(SITE_ROOT, "static/js/", "pygal-tooltips.js")]
    if isShortTerm:
        chart.height = 420
        chart.width = 900
    else:
        chart.height = 700
        chart.width = 2000
    chart.disable_xml_declaration = True  # disable xml root node
    chart.x_label_rotation = 30
    chart.title = title
    chart.x_title = 'Timeline'
    chart.y_title = 'Value'

    chart.x_labels = map(str, date_list_short_format)
    chart.x_labels_major = key_date_list_short_format
    chart.add('Warning limit', warning_limit_list)
    chart.add('Critical limit', critical_limit_list)
    chart.add('Min value', min_value_list)
    chart.add('Max value', max_value_list)
    chart.add('Avg value', avg_value_list)

    return chart


# http://127.0.0.1:5000/items/UNIT_TEST_NONNUMERICAL
# http://127.0.0.1:5000/items/UNIT_TEST_NUMERICAL 
开发者ID:harryliu,项目名称:edwin,代码行数:60,代码来源:views.py

示例10: raw_svgs

# 需要导入模块: import pygal [as 别名]
# 或者: from pygal import style [as 别名]
def raw_svgs():
    chart = pygal.Line(legend_at_bottom=True, legend_box_size=18)

    # =======================================
    # Declare the location of svg.jquery.js and pygal-tooltips.js in server side.
    # =======================================
    # It must be declare in server side, not html file
    # if not declare in server, by default it will load the two js files located in http://kozea.github.com/pygal.js. And it will slow down the page loading

    # 1, It works, load local js files
    SITE_ROOT = os.path.realpath(os.path.dirname(__file__))
    chart.js = [os.path.join(SITE_ROOT, "static/js/", "svg.jquery.js"),
                os.path.join(SITE_ROOT, "static/js/", "pygal-tooltips.js")]

    # 2.a, It Works, but it is ugly because it use local absolute http url
    # chart.js =['http://127.0.0.1:5000/static/js/svg.jquery.js',
    #     'http://127.0.0.1:5000/static/js/pygal-tooltips.js']

    # 2.b, works, use local CDN absolute http url
    # chart.js =['http://another_server/pygal-tooltips.js',
    #     'http://another_server/svg.jquery.js']

    # 3, Does not work, error raised at visiting, IOError: [Errno 2] No such file
    # chart.js = [url_for('static', filename='js/svg.jquery.js'),
    #            url_for('static', filename='js/pygal-tooltips.js')]

    # disable xml root node
    chart.disable_xml_declaration = True
    chart.title = 'Browser usage evolution (in %)'
    chart.width = 2000
    chart.height = 2000
    chart.x_labels = map(str, range(2002, 2013))
    chart.add('Firefox', [None, None, 0, 16.6, 25, 31, 36.4, 45.5, 46.3, 42.8, 37.1])
    chart.add('Chrome', [None, None, None, None, None, None, 0, 3.9, 10.8, 23.8, 35.3])
    chart.add('IE', [85.8, 84.6, 84.7, 74.5, 66, 58.6, 54.7, 44.8, 36.2, 26.6, 20.1])
    chart.add('Others', [14.2, 15.4, 15.3, 8.9, 9, 10.4, 8.9, 5.8, 6.7, 6.8, 7.5])

    svg_xml = chart.render()
    svg_xml = '<svg  style="width:2000px" ' + svg_xml[4:]
    svg_xml1 = svg_xml[:100]
    response = make_response(render_template('test_svg.html', title=svg_xml1, svg_xml=svg_xml))
    # response.headers['Content-Type']='image/svg+xml' 不能设置Content-Type为svg模式
    return response 
开发者ID:harryliu,项目名称:edwin,代码行数:45,代码来源:views.py


注:本文中的pygal.style方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。