本文整理汇总了Python中pygal.Line.add方法的典型用法代码示例。如果您正苦于以下问题:Python Line.add方法的具体用法?Python Line.add怎么用?Python Line.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pygal.Line
的用法示例。
在下文中一共展示了Line.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_stroke_config
# 需要导入模块: from pygal import Line [as 别名]
# 或者: from pygal.Line import add [as 别名]
def test_stroke_config():
line = Line(stroke_style={'width': .5})
line.add('test_no_line', range(12), stroke=False)
line.add('test', reversed(range(12)), stroke_style={'width': 3})
line.add(
'test_no_dots', [5] * 12,
show_dots=False,
stroke_style={
'width': 2,
'dasharray': '12, 31'
}
)
line.add(
'test_big_dots', [randint(1, 12) for _ in range(12)], dots_size=5
)
line.add(
'test_fill', [randint(1, 3) for _ in range(12)],
fill=True,
stroke_style={
'width': 5,
'dasharray': '4, 12, 7, 20'
}
)
line.x_labels = [
'lol', 'lol1', 'lol2', 'lol3', 'lol4', 'lol5', 'lol6', 'lol7',
'lol8', 'lol9', 'lol10', 'lol11'
]
return line.render_response()
示例2: test_interpolate_secondary
# 需要导入模块: from pygal import Line [as 别名]
# 或者: from pygal.Line import add [as 别名]
def test_interpolate_secondary():
chart = Line(title=u"Some different points", interpolate="cubic")
chart.add("line", [1000, 2000, 7000])
chart.add("other line", [100, 500, 500], secondary=True)
chart.range = 0, 10000
chart.secondary_range = 0, 1000
return chart.render_response()
示例3: test_value_formatter
# 需要导入模块: from pygal import Line [as 别名]
# 或者: from pygal.Line import add [as 别名]
def test_value_formatter():
line = Line(value_formatter=lambda x: str(x) + u('‰'))
line.add('_', [10 ** 4, 10 ** 5, 23 * 10 ** 4])
q = line.render_pyquery()
assert len(q(".y.axis .guides")) == 11
assert q(".axis.y text").map(texts) == list(map(
lambda x: str(x) + u('‰'), map(float, range(20000, 240000, 20000))))
示例4: test_simple_line
# 需要导入模块: from pygal import Line [as 别名]
# 或者: from pygal.Line import add [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']
示例5: test_only_major_dots_every
# 需要导入模块: from pygal import Line [as 别名]
# 或者: from pygal.Line import add [as 别名]
def test_only_major_dots_every():
"""Test major dots"""
line = Line(show_only_major_dots=True, x_labels_major_every=3)
line.add('test', range(12))
line.x_labels = map(str, range(12))
q = line.render_pyquery()
assert len(q(".dots")) == 4
示例6: test_only_major_dots_count
# 需要导入模块: from pygal import Line [as 别名]
# 或者: from pygal.Line import add [as 别名]
def test_only_major_dots_count():
line = Line(show_only_major_dots=True)
line.add('test', range(12))
line.x_labels = map(str, range(12))
line.x_labels_major_count = 2
q = line.render_pyquery()
assert len(q(".dots")) == 2
示例7: test_only_major_dots
# 需要导入模块: from pygal import Line [as 别名]
# 或者: from pygal.Line import add [as 别名]
def test_only_major_dots():
line = Line(show_only_major_dots=True,)
line.add('test', range(12))
line.x_labels = map(str, range(12))
line.x_labels_major = ['1', '5', '11']
q = line.render_pyquery()
assert len(q(".dots")) == 3
示例8: _generate_time_chart
# 需要导入模块: from pygal import Line [as 别名]
# 或者: from pygal.Line import add [as 别名]
def _generate_time_chart(self, datas):
"""
After generate a time chart,save to file and return the chart path
Keyword arguments:
datas -- Dict object of parsed information for a time chart
"""
if not datas:
return ""
line_chart = Line(x_label_rotation=30, sstyle=LightStyle, human_readable=True)
indices = sorted(datas.keys())
time_format = self.options["time_format"]
line_chart.x_labels = map(lambda x: dateutil.parser.parse(x).strftime(time_format), indices)
chart_data = {}
for index in indices:
for data in datas[index]:
if chart_data.get(data[0]):
chart_data.get(data[0]).append(data[1])
else:
chart_data[data[0]] = [data[1]]
for key in chart_data:
line_chart.add(key, chart_data[key])
path = os.path.join(tempfile.gettempdir(), "time{}.svg".format(str(int(time.time()))))
line_chart.render_to_file(path)
logging.info("Time chart was created successfully.")
return path
示例9: test_parametric_styles_with_parameters
# 需要导入模块: from pygal import Line [as 别名]
# 或者: from pygal.Line import add [as 别名]
def test_parametric_styles_with_parameters():
"""Test a parametric style with parameters"""
line = Line(style=RotateStyle(
'#de3804', step=12, max_=180, base_style=LightStyle))
line.add('_', [1, 2, 3])
line.x_labels = 'abc'
assert line.render()
示例10: test_stroke_config
# 需要导入模块: from pygal import Line [as 别名]
# 或者: from pygal.Line import add [as 别名]
def test_stroke_config():
line = Line(stroke_style={"width": 0.5})
line.add("test_no_line", range(12), stroke=False)
line.add("test", reversed(range(12)), stroke_style={"width": 3})
line.add("test_no_dots", [5] * 12, show_dots=False, stroke_style={"width": 2, "dasharray": "12, 31"})
line.add("test_big_dots", [randint(1, 12) for _ in range(12)], dots_size=5)
line.add(
"test_fill",
[randint(1, 3) for _ in range(12)],
fill=True,
stroke_style={"width": 5, "dasharray": "4, 12, 7, 20"},
)
line.x_labels = [
"lol",
"lol1",
"lol2",
"lol3",
"lol4",
"lol5",
"lol6",
"lol7",
"lol8",
"lol9",
"lol10",
"lol11",
]
return line.render_response()
示例11: test_config_behaviours
# 需要导入模块: from pygal import Line [as 别名]
# 或者: from pygal.Line import add [as 别名]
def test_config_behaviours():
"""Test that all different way to set config produce same results"""
line1 = Line()
line1.show_legend = False
line1.fill = True
line1.pretty_print = True
line1.no_prefix = True
line1.x_labels = ['a', 'b', 'c']
line1.add('_', [1, 2, 3])
l1 = line1.render()
q = line1.render_pyquery()
assert len(q(".axis.x")) == 1
assert len(q(".axis.y")) == 1
assert len(q(".plot .series path")) == 1
assert len(q(".legend")) == 0
assert len(q(".x.axis .guides")) == 3
assert len(q(".y.axis .guides")) == 11
assert len(q(".dots")) == 3
assert q(".axis.x text").map(texts) == ['a', 'b', 'c']
line2 = Line(
show_legend=False,
fill=True,
pretty_print=True,
no_prefix=True,
x_labels=['a', 'b', 'c'])
line2.add('_', [1, 2, 3])
l2 = line2.render()
assert l1 == l2
class LineConfig(Config):
show_legend = False
fill = True
pretty_print = True
no_prefix = True
x_labels = ['a', 'b', 'c']
line3 = Line(LineConfig)
line3.add('_', [1, 2, 3])
l3 = line3.render()
assert l1 == l3
line4 = Line(LineConfig())
line4.add('_', [1, 2, 3])
l4 = line4.render()
assert l1 == l4
line_config = Config()
line_config.show_legend = False
line_config.fill = True
line_config.pretty_print = True
line_config.no_prefix = True
line_config.x_labels = ['a', 'b', 'c']
line5 = Line(line_config)
line5.add('_', [1, 2, 3])
l5 = line5.render()
assert l1 == l5
示例12: test_same_max_and_relative_values_sparktext
# 需要导入模块: from pygal import Line [as 别名]
# 或者: from pygal.Line import add [as 别名]
def test_same_max_and_relative_values_sparktext():
chart = Line()
chart.add('_', [0, 0, 0, 0, 0])
assert chart.render_sparktext() == u('▁▁▁▁▁')
chart2 = Line()
chart2.add('_', [1, 1, 1, 1, 1])
assert chart2.render_sparktext(relative_to=1) == u('▁▁▁▁▁')
示例13: simulation
# 需要导入模块: from pygal import Line [as 别名]
# 或者: from pygal.Line import add [as 别名]
def simulation():
x = w.x_odeint(w.initial)
line = Line(show_dots=False,show_minor_x_labels=False)
for c in x:
line.add(c,x[c])
line.x_labels = map(str,x.index.values)
line.x_labels_major = map(str,range(x.index[0],x.index[-1]+50,50))
return line.render_response()
示例14: test_no_data_sparktext
# 需要导入模块: from pygal import Line [as 别名]
# 或者: from pygal.Line import add [as 别名]
def test_no_data_sparktext():
"""Test no data sparktext"""
chart2 = Line()
chart2.add('_', [])
assert chart2.render_sparktext() == u('')
chart3 = Line()
assert chart3.render_sparktext() == u('')
示例15: test_major_dots
# 需要导入模块: from pygal import Line [as 别名]
# 或者: from pygal.Line import add [as 别名]
def test_major_dots():
line = Line(x_labels_major_count=2, show_only_major_dots=True)
line.add('test', range(12))
line.x_labels = [
'lol', 'lol1', 'lol2', 'lol3', 'lol4', 'lol5',
'lol6', 'lol7', 'lol8', 'lol9', 'lol10', 'lol11']
# line.x_labels_major = ['lol3']
return line.render_response()