def drawRadar_pygal(title, case_data, path, showPlot): title = title[0:1] + title[-1:0:-1] case_data = case_data[0:1] + case_data[-1:0:-1] dark_lighten_style = LightenStyle(theme_color, step=5, max_=10) dark_lighten_style1 = LightenStyle('#ff0000') colorset = ['#cfefdf', '#a7e1c4', '#76d0a3'] dark_lighten_style.opacity = 0.5 dark_lighten_style.background = '#ffffff' dark_lighten_style.font_family = "DejaVu Sans" dark_lighten_style.legend_font_family = "DejaVu Sans" dark_lighten_style.major_label_font_family = "DejaVu Sans" dark_lighten_style.title_font_family = "DejaVu Sans" dark_lighten_style.tooltip_font_family = "DejaVu Sans" dark_lighten_style.label_font_family = "DejaVu Sans" dark_lighten_style.label_font_size = 40 dark_lighten_style.major_label_font_size = 40 dark_lighten_style.legend_font_size = 40 dark_lighten_style.colors = [colorset[1], theme_color] # dark_lighten_style.foreground = 'rgba(0, 0, 0, .87)' # raise radar_chart = pygal.Radar(show_legend=True, width=1600, height=1200, style=dark_lighten_style, margin=25, spacing=20, stroke_style={'width': 5}, dots_size=8, show_dots=1, stroke=1) # radar_chart.title = 'V8 benchmark results' radar_chart.x_labels = title if max(case_data) < 1: case_data = [c * 100 for c in case_data] # radar_chart.add('Chrome1', [{'value':50,'style': 'fill: False; stroke: red; stroke-width: 4;stroke-dasharray: 15, 10, 5, 10, 15'}]*len(case_data)) radar_chart.add('Standard score', [50] * len(case_data), fill=True, show_dots=0, stroke_style={ 'width': 2, 'dasharray': '3, 6' }) radar_chart.add('Your score', case_data) # radar_chart._fill('red') radar_chart.y_labels = [0, 50, 100] # radar_chart.render_to_file('plot/Radar_pygal.svg',fill = True) radar_chart.render_to_png(path + 'Radar_pygal.png', fill=True) if showPlot: display({'image/svg+xml': radar_chart.render(fill=True)}, raw=True)
def drawPercentile(percentile, x_label, path, showPlot): config = Config() config.show_legend = False # config.range = (0,1) dark_lighten_style = LightenStyle('#336676', base_style=LightColorizedStyle) dark_lighten_style.background = '#ffffff' dark_lighten_style.opacity = 1 dark_lighten_style.font_family = "DejaVu Sans" dark_lighten_style.legend_font_family = "DejaVu Sans" dark_lighten_style.major_label_font_family = "DejaVu Sans" dark_lighten_style.title_font_family = "DejaVu Sans" dark_lighten_style.tooltip_font_family = "DejaVu Sans" dark_lighten_style.label_font_family = "DejaVu Sans" dark_lighten_style.label_font_size = 40 dark_lighten_style.major_label_font_size = 40 # print(dark_lighten_style.to_dict()) bar_chart = pygal.Bar(config, width=1600, height=1000, rounded_bars=6, style=dark_lighten_style, margin=0) bar_chart.x_labels = x_label #['Concentration', 'Stability', 'Focus Continuity'] #map(str, range(2002, 2013)) bar_chart.y_labels = (0, 0.2, 0.4, 0.6, 0.8, 1) # bar_chart.add('Percentile0', rd1.percentile[0]) # bar_chart.add('Percentile1', rd1.percentile[1]) # bar_chart.add('Percentile2', rd1.percentile[2]) bar_chart.add('Percentile', [{ 'value': 1 - percentile[0], 'color': selectColor(percentile[0]) }, { 'value': 1 - percentile[1], 'color': selectColor(percentile[1]) }, { 'value': 1 - percentile[2], 'color': selectColor(percentile[2]) }]) if showPlot: display({'image/svg+xml': bar_chart.render()}, raw=True, dpi=200) bar_chart.render_to_png(path + 'Percentile.png', fill=True, dpi=200)
solved_ext = 0 else: solved_ext = int(solved_ext) if solved_ext == 0: solved = solved[:20] notSolved_ext = request.args.get('notSolved_ext') if not notSolved_ext: notSolved_ext = 0 else: notSolved_ext = int(notSolved_ext) if notSolved_ext == 0: notSolved = notSolved[:20] customStyle = LightenStyle('#337ab7') customStyle.background = '#eeeeee' customStyle.label_font_size = 14 customStyle.tooltip_font_size = 25 chart_type = request.args.get('chart_type') if not chart_type: chart_type = 0 else: chart_type = int(chart_type) chart = None if chart_type == 0: chart = pygal.Bar(show_legend=False, style=customStyle, order_min=0) chart.title = 'Problems solved per tag' chart.x_labels = allTags chart.x_label_rotation = 45
forecast = 0.0 if bill_ratio > 0.0: forecast = this_mon.used / bill_ratio our_text = "At this rate we will take %.2f units into next month" % -(this_mon.bf+forecast-this_mon.allowance) over = False if this_mon.used > this_mon.allowance: our_text = "We are ALREADY using more data than we buy each month!" over = True elif forecast > this_mon.allowance: our_text = "We are forecast to use more data than we buy each month" from pygal.style import LightenStyle, LightColorizedStyle ourstyle = LightenStyle('#235670', step=5, base_style=LightColorizedStyle) ourstyle.background = '#ffffff' conf = pygal.Config() conf.style = ourstyle conf.legend_at_bottom = True usage_pie = pygal.Pie(conf) usage_pie.title = "Current monthly usage (units)" if over: usage_pie.add("Over-usage", this_mon.used - this_mon.allowance) usage_pie.add("Allowance", this_mon.allowance) else: usage_pie.add("Usage", this_mon.used) usage_pie.add("Remaining", this_mon.allowance - this_mon.bf) pop = pygal.Pie(conf)