コード例 #1
0
def PygalConfigFile():
    config = Config()
    config.human_readable = True
    config.height = 250
    config.width = 700
    config.style = NeonStyle
    config.show_minor_y_labels = True
    config.x_label_rotation = 25
    config.value_font_size = 8
    config.title_font_size = 8
    config.legend_font_size = 8
    config.legend_box_size = 12
    config.label_font_size = 6

    return (config)
コード例 #2
0
def PygalConfigFileBlue():
    configB = Config()
    configB.human_readable = True
    configB.height = 250
    configB.width = 700
    configB.style = NeonStyle
    configB.show_minor_y_labels = True
    configB.x_label_rotation = 25
    configB.value_font_size = 8
    configB.title_font_size = 8
    configB.legend_font_size = 8
    configB.legend_box_size = 12
    configB.label_font_size = 6
    configB.colors = ['#000099', '#009999']

    return (configB)
コード例 #3
0
ファイル: CCTrending.py プロジェクト: ccworld1000/CCTrending
def languages_draw(prefix, file_name, dir_name, time_title, names, counts):
    chart = pygal.Bar(interpolate='cubic', width=1000)

    config = Config()
    config.show_legend = False
    config.human_readable = True
    config.fill = True
    config.style = DarkColorizedStyle
    config.label_font_size = 36
    config.x_label_rotation = 45

    chart.config = config

    chart.title = file_name + " [" + time_title + "]"
    chart.x_labels = names
    chart.add(prefix, counts)

    save_name = os.path.join(dir_name, file_name + ".svg")
    chart.render_to_file(save_name)
コード例 #4
0
    def get(self):
        self._context.error = ''
        step = self.get_argument("step", 0)
        self._context.next = self.get_next_url()
        #获取用户uid
        user_info = None
        uid = self.get_secure_cookie('uid', None)
        if (step == '1' or step == '2' or step == '3'
                or step == 'end') and (not uid):
            self.redirect('/reg/?step=0')
            return
        else:
            #获取用户信息
            user_info = self.user.getItem(uid)
        if urlparse.urlparse(self._context.next).path == '/reg':
            self._context.next = '/index'
        if step == '0':
            self.assignDirection()
            if uid:
                self._context.user_info = user_info
                self._context.area = ','.join(
                    self.d.getDistrictParents(user_info['area_id'], res=[]))
            else:
                self._context.user_info = None
            self._handler_template = 'user/reg.html'
        elif step == '1':
            #判断用户是否保存到cookie中
            if not uid:
                self.redirect('/reg/?step=0')
            #获取用户信息
            user_info = self.user.getItem(uid)
            self._context.user_info = user_info
            self._context.user_email = user_info['user_email']
            #判断是否给用户发送了邮件
            self._context.is_send = True
            uv = UserVerify()
            uv_info = uv.getVerifyInfo(uid)
            if uv_info:
                #不需要发送邮件
                self._context.is_send = False
                #验证url没有过期
                now = int(time.mktime(datetime.datetime.now().timetuple()))
                if user_info[
                        'is_verify'] != 1 and utiles.formateDateToTimestamp(
                            uv_info['verify_expire_time']) > now:
                    self._context.error = ErrorMessage.error_message['016']
                elif user_info[
                        'is_verify'] != 1 and utiles.formateDateToTimestamp(
                            uv_info['verify_expire_time']) <= now:
                    self._context.is_send = True
            self._handler_template = 'user/reg_step_1.html'

        elif step == '2':
            #判断是否给用户发送了邮件
            ret = self.checkTokenUrl(uid)
            self._context.is_send = True if ret['code'] == 'success' else False
            if ret['code'] == 'error':
                self._context.error = ret['msg']
                self._handler_template = 'user/reg_step_1.html'
            else:
                list = self.getChaList()
                self._context.list = list
                self._context.ids = ','.join(
                    [str(item['id']) for item in list])
                self._handler_template = 'user/reg_step_2.html'

        elif step == '3':
            ut = UserBfiTest()
            ut_info = ut.queryOne(filterString=[('uid', uid)],
                                  fields=ut._table_columns)
            if ut_info:
                #获取性格测试平均值
                sysconfig = SysConfig()
                bfi_vals = sysconfig.getConfig('bfi_total')
                bfi_user_total = int(
                    sysconfig.getConfig('bfi_user_total')['val'])

                #建立雷达图
                config = Config()
                config.explicit_size = True
                config.width = 500
                config.height = 450
                config.label_font_size = 14
                config.x_label_rotation = 1
                radar_chart = pygal.Radar(config)
                radar_chart.title = u'人格初测结果'
                radar_chart.x_labels = [
                    u'开放性O', u'神经质N', u'宜人性A', u'外向型E', u'尽职性C'
                ]
                radar_chart.add(user_info['user_name'], [
                    int(ut_info['O_val']),
                    int(ut_info['N_val']),
                    int(ut_info['A_val']),
                    int(ut_info['E_val']),
                    int(ut_info['C_val'])
                ])
                radar_chart.add(u'平均值', [
                    bfi_vals['O'] / bfi_user_total, bfi_vals['N'] /
                    bfi_user_total, bfi_vals['A'] / bfi_user_total,
                    bfi_vals['E'] / bfi_user_total,
                    bfi_vals['C'] / bfi_user_total
                ])
                self._context.radar = radar_chart.render()
                #评价
                self._context.N_msg = BfiCharacterTest.transform(
                    'N', int(ut_info['N_val']))[0]
                self._context.O_msg = BfiCharacterTest.transform(
                    'O', int(ut_info['O_val']))[0]
                self._context.A_msg = BfiCharacterTest.transform(
                    'A', int(ut_info['A_val']))[0]
                self._context.E_msg = BfiCharacterTest.transform(
                    'E', int(ut_info['E_val']))[0]
                self._context.C_msg = BfiCharacterTest.transform(
                    'C', int(ut_info['C_val']))[0]
                #从人格特点推荐好友

                #活动推荐

            else:
                self._context.radar = None

            self._handler_template = 'user/reg_step_3.html'

        #跳转到活动列表页
        elif step == 'end':
            self.redirect('/activity')

        self.render(self._handler_template)
        return
コード例 #5
0
ファイル: app.py プロジェクト: haiyangd/MonitO-
global MemUsage
global diskUsage

global sender
global receivers

sender = 'Monito admin <*****@*****.**>'
receivers = ['*****@*****.**']

config = Config()
config.range=(.0001, 5)
config.legend_font_size=30
config.tooltip_font_size=30
config.legend_box_size=18
config.title_font_size=30
config.label_font_size=20
config.legend_at_bottom=True
config.major_label_font_size=20
config.no_data_text='Fetching data..'

config1 = Config()
config1.fill=True
config1.spacing=50
config1.range=(1, 100)
config1.legend_font_size=30
config1.tooltip_font_size=30
config1.legend_box_size=18
config1.title_font_size=30
config1.label_font_size=20
config1.legend_at_bottom=True
config1.major_label_font_size=20