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


Python Line.title方法代码示例

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


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

示例1: graph

# 需要导入模块: from pygal import Line [as 别名]
# 或者: from pygal.Line import title [as 别名]
def graph(graph, type, year, month):
    """Create graphs with the parameters passed."""
    db = get_db()
    now = datetime.now()
    timestamp = now.timestamp()
    time_first_day = datetime(year, month, 1).timestamp()
    first_day = datetime(year, month, 1)
    cal = calendar.monthrange(year, month)
    time_last_day = datetime(year, month, cal[1], 23, 59, 59).timestamp()
    last_day = datetime(year, month, cal[1])
    
    if graph in ['ligne', 'histogramme']:
        line_chart = Line(interpolate='cubic') if graph == 'ligne' else Bar()
        if type == 'hour':
            line_chart.title = (
                'Somme des hoquets par heure en %s' % 
                calendar.month_name[month])
            requete = db.execute(
                'select CAST(strftime(\'%H\', datetime(moment, \'unixepoch\','
                ' \'localtime\')) as integer) as hour, count(*) from ok '
                'where moment between (?) and (?) group by hour', 
                [time_first_day, time_last_day])
            hoquet = dict(requete)
            line_chart.x_labels = [
               str(hour) for hour, val in sorted(hoquet.items())]
            line_chart.add('Annabelle', [
                val for hour, val in sorted(hoquet.items())])
        else:
            hoquet = []
            x_labels = []
            x_labels_major = []
            line_chart.title = (
                'Nombre de hoquets par jour en %s' % 
                calendar.month_name[month])
            for i,day in enumerate(range (int(time_first_day),
            int(time_last_day), 86400)):                 
                if is_in_weekend(day):
                    requete = None
                else:
                    requete = db.execute(
                        'select count(*) from ok where moment >= (?) '
                        'and moment <= (?)', [day, day+86400]).fetchone()[0]
                    x_labels_major.append(i+1)
                    
                x_labels.append(i+1)                   
                hoquet.append(requete)
            line_chart.x_labels = map(str, x_labels)
            line_chart.x_labels_major = list(map(str, x_labels_major))
            line_chart.add('Annabelle', hoquet)
        return line_chart.render_response()
            
        return gauge_chart.render_response()
开发者ID:Kozea,项目名称:hadokey,代码行数:54,代码来源:hadokey.py

示例2: test_simple_line

# 需要导入模块: from pygal import Line [as 别名]
# 或者: from pygal.Line import title [as 别名]
def test_simple_line():
    """Simple line test"""
    line = Line()
    rng = range(-30, 31, 5)
    line.add('test1', [cos(x / 10) for x in rng])
    line.add('test2', [sin(x / 10) for x in rng])
    line.add('test3', [cos(x / 10) - sin(x / 10) for x in rng])
    line.x_labels = map(str, rng)
    line.title = "cos sin and cos - sin"
    q = line.render_pyquery()
    assert len(q(".axis.x")) == 1
    assert len(q(".axis.y")) == 1
    assert len(q(".plot .series path")) == 3
    assert len(q(".legend")) == 3
    assert len(q(".x.axis .guides")) == 13
    assert len(q(".y.axis .guides")) == 13
    assert len(q(".dots")) == 3 * 13
    assert q(".axis.x text").map(texts) == [
        '-30', '-25', '-20', '-15', '-10', '-5',
        '0', '5', '10', '15', '20', '25', '30']
    assert q(".axis.y text").map(texts) == [
        '-1.2', '-1', '-0.8', '-0.6', '-0.4', '-0.2',
        '0', '0.2', '0.4', '0.6', '0.8', '1', '1.2']
    assert q(".title").text() == 'cos sin and cos - sin'
    assert q(".legend text").map(texts) == ['test1', 'test2', 'test3']
开发者ID:aroraumang,项目名称:pygal,代码行数:27,代码来源:test_line.py

示例3: word_count

# 需要导入模块: from pygal import Line [as 别名]
# 或者: from pygal.Line import title [as 别名]
def word_count(text_sample_directory):

    print "Opening '" + text_sample_directory + "'"

    # Dictionary of each word that gets encountered
    words = {}

    for text_file in os.listdir(text_sample_directory):
        with open(text_sample_directory + text_file) as f:
            sys.stdout.write(".")
            sys.stdout.flush()

            for line in f:

                line = line.lower()
                line = clean(line)

                replace_characters = '[email protected]#$%^&*:;<>(){}[]|\/\'`"_,.'
                for character in replace_characters:
                    line = line.replace(character, "")

                word_list = line.split(" ")
                for word in word_list:

                    if word and word in words:
                        words[word] += 1
                    else:
                        words[word] = 1

    output_name = text_sample_directory.strip("/")

    writer = csv.writer(open(output_name + ".csv", "wb"))
    sorted_dict = sorted(words.items(), key=lambda x:x[1], reverse=True)

    # Get the count of occurance for the word that occurs the most
    max_value = int(sorted_dict[0][1])
    keys = []
    values = []

    for key, value in sorted_dict:
        keys.append(key)
        values.append(value)
        writer.writerow([key, value])

    line_chart = Line()
    line_chart.title = "Word Occurance Graph"
    line_chart.x_labels = keys
    line_chart.add(output_name,  values)

    svg_data = line_chart.render()
    graphfile = open(output_name + ".svg", "w")
    graphfile.write(svg_data)


    print "\nWriting '" + output_name + "'"
开发者ID:gunthercox,项目名称:AttitudeEngine,代码行数:57,代码来源:word_count.py

示例4: test_line

# 需要导入模块: from pygal import Line [as 别名]
# 或者: from pygal.Line import title [as 别名]
def test_line():
    line = Line()
    rng = [8, 12, 23, 73, 39, 57]
    line.add('Single serie', rng)
    line.title = "One serie"
    q = line.render_pyquery()
    assert len(q(".axis.x")) == 0
    assert len(q(".axis.y")) == 1
    assert len(q(".plot .series path")) == 1
    assert len(q(".x.axis .guides")) == 0
    assert len(q(".y.axis .guides")) == 7
开发者ID:andreasnuesslein,项目名称:pygal,代码行数:13,代码来源:test_line.py

示例5: test_line_secondary

# 需要导入模块: from pygal import Line [as 别名]
# 或者: from pygal.Line import title [as 别名]
def test_line_secondary():
    """Test line with a secondary serie"""
    line = Line()
    rng = [8, 12, 23, 73, 39, 57]
    line.add('First serie', rng)
    line.add('Secondary serie', map(lambda x: x * 2, rng), secondary=True)
    line.title = "One serie"
    q = line.render_pyquery()
    assert len(q(".axis.x")) == 0
    assert len(q(".axis.y")) == 1
    assert len(q(".plot .series path")) == 2
    assert len(q(".x.axis .guides")) == 0
    assert len(q(".y.axis .guides")) == 7
开发者ID:Kozea,项目名称:pygal,代码行数:15,代码来源:test_line.py

示例6: get_line_chart

# 需要导入模块: from pygal import Line [as 别名]
# 或者: from pygal.Line import title [as 别名]
    def get_line_chart(self, title, lines):
        """Make chart of type line and return it.

        title: Title of chart (string)
        step: x label step and poll interval (integer)
        start: x label start value (integer)
        stop: x label end value and end of polling (integer)
        lines: tuple or list of tuples or lists (line_name, data_points)
            line_name (string)
            data_points (list of ints)

        returns line_chart (pygal.Line())
        """

        chart = Line()
        chart.title = title
        chart.x_labels = self.points
        if type(lines[0]) == type(str()):
            lines = list(lines)
        for line in lines:
            label = line[0]
            data = line[1]
            chart.add(label, data)
        return chart
开发者ID:jbutler42,项目名称:pynet_class,代码行数:26,代码来源:exercise2.py


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