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


Python Pie.add方法代码示例

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


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

示例1: test_pie_serie_radius

# 需要导入模块: from pygal import Pie [as 别名]
# 或者: from pygal.Pie import add [as 别名]
    def test_pie_serie_radius():
        pie = Pie()
        pie.js = ('http://a.zi:2343/2.0.x/pygal-tooltips.js', )
        for i in range(10):
            pie.add(str(i), i, inner_radius=(10 - i) / 10)

        return pie.render_response()
开发者ID:Kozea,项目名称:pygal,代码行数:9,代码来源:tests.py

示例2: test_64_colors

# 需要导入模块: from pygal import Pie [as 别名]
# 或者: from pygal.Pie import add [as 别名]
 def test_64_colors():
     n = 64
     colors = [rotate('#ff0000', i * 360 / n) for i in range(n)]
     pie = Pie(style=Style(colors=colors))
     for i in range(n):
         pie.add(str(i), 1)
     return pie.render_response()
开发者ID:fredtantini,项目名称:pygal,代码行数:9,代码来源:tests.py

示例3: test_half_pie

# 需要导入模块: from pygal import Pie [as 别名]
# 或者: from pygal.Pie import add [as 别名]
 def test_half_pie():
     pie = Pie(half_pie=True)
     for i in range(20):
         pie.add(str(i), i, inner_radius=.1)
     pie.legend_at_bottom = True
     pie.legend_at_bottom_columns = 4
     return pie.render_response()
开发者ID:fredtantini,项目名称:pygal,代码行数:9,代码来源:tests.py

示例4: test_donut

# 需要导入模块: from pygal import Pie [as 别名]
# 或者: from pygal.Pie import add [as 别名]
def test_donut():
    chart = Pie(inner_radius=0.3, pretty_print=True)
    chart.title = "Browser usage in February 2012 (in %)"
    chart.add("IE", 19.5)
    chart.add("Firefox", 36.6)
    chart.add("Chrome", 36.3)
    chart.add("Safari", 4.5)
    chart.add("Opera", 2.3)
    assert chart.render()
开发者ID:jespinoza711,项目名称:pygal,代码行数:11,代码来源:test_pie.py

示例5: test_donut

# 需要导入模块: from pygal import Pie [as 别名]
# 或者: from pygal.Pie import add [as 别名]
def test_donut():
    chart = Pie(inner_radius=.3, pretty_print=True)
    chart.title = 'Browser usage in February 2012 (in %)'
    chart.add('IE', 19.5)
    chart.add('Firefox', 36.6)
    chart.add('Chrome', 36.3)
    chart.add('Safari', 4.5)
    chart.add('Opera', 2.3)
    assert chart.render()
开发者ID:AlanRun,项目名称:UiAutoTest,代码行数:11,代码来源:test_donut.py

示例6: test_pie_table

# 需要导入模块: from pygal import Pie [as 别名]
# 或者: from pygal.Pie import add [as 别名]
def test_pie_table():
    chart = Pie(inner_radius=.3, pretty_print=True)
    chart.title = 'Browser usage in February 2012 (in %)'
    chart.add('IE', 19.5)
    chart.add('Firefox', 36.6)
    chart.add('Chrome', 36.3)
    chart.add('Safari', 4.5)
    chart.add('Opera', 2.3)
    q = pq(chart.render_table())
    assert len(q('table')) == 1
开发者ID:AlanRun,项目名称:UiAutoTest,代码行数:12,代码来源:test_table.py

示例7: test_multiseries_donut

# 需要导入模块: from pygal import Pie [as 别名]
# 或者: from pygal.Pie import add [as 别名]
def test_multiseries_donut():
    # this just demos that the multiseries pie does not respect
    # the inner_radius
    chart = Pie(inner_radius=.3, pretty_print=True)
    chart.title = 'Browser usage by version in February 2012 (in %)'
    chart.add('IE', [5.7, 10.2, 2.6, 1])
    chart.add('Firefox', [.6, 16.8, 7.4, 2.2, 1.2, 1, 1, 1.1, 4.3, 1])
    chart.add('Chrome', [.3, .9, 17.1, 15.3, .6, .5, 1.6])
    chart.add('Safari', [4.4, .1])
    chart.add('Opera', [.1, 1.6, .1, .5])
    assert chart.render()
开发者ID:AlanRun,项目名称:UiAutoTest,代码行数:13,代码来源:test_donut.py

示例8: test_multiseries_donut

# 需要导入模块: from pygal import Pie [as 别名]
# 或者: from pygal.Pie import add [as 别名]
def test_multiseries_donut():
    # this just demos that the multiseries pie does not respect
    # the inner_radius
    chart = Pie(inner_radius=0.3, pretty_print=True)
    chart.title = "Browser usage by version in February 2012 (in %)"
    chart.add("IE", [5.7, 10.2, 2.6, 1])
    chart.add("Firefox", [0.6, 16.8, 7.4, 2.2, 1.2, 1, 1, 1.1, 4.3, 1])
    chart.add("Chrome", [0.3, 0.9, 17.1, 15.3, 0.6, 0.5, 1.6])
    chart.add("Safari", [4.4, 0.1])
    chart.add("Opera", [0.1, 1.6, 0.1, 0.5])
    assert chart.render()
开发者ID:jespinoza711,项目名称:pygal,代码行数:13,代码来源:test_pie.py

示例9: node_apply_end

# 需要导入模块: from pygal import Pie [as 别名]
# 或者: from pygal.Pie import add [as 别名]
def node_apply_end(repo, node, duration=None, interactive=None, result=None, **kwargs):
    if environ.get('TERM_PROGRAM', None) != "iTerm.app" or not interactive:
        LOG.debug("skipping iTerm stats (wrong terminal)")
        return

    if not IMPORTS:
        LOG.error("failed to import dependencies of itermstats plugin")
        return

    css_file = NamedTemporaryFile(delete=False)
    css_file.write(".text-overlay { display: none; }")
    css_file.close()

    config = Config(
        height=150,
        style=STYLE,
        width=350,
    )
    config.css.append(css_file.name)

    chart = Pie(config)
    chart.add('correct', result.correct)
    chart.add('fixed', result.fixed)
    chart.add('skipped', result.skipped)
    chart.add('failed', result.failed)

    png_data = cairosvg.svg2png(bytestring=chart.render())
    png_data_b64 = b64encode(png_data)

    remove(css_file.name)

    print("\033]1337;File=inline=1:{}\007".format(png_data_b64))
开发者ID:bundlewrap,项目名称:plugins,代码行数:34,代码来源:itermstats.py

示例10: test_donut

# 需要导入模块: from pygal import Pie [as 别名]
# 或者: from pygal.Pie import add [as 别名]
def test_donut():
    file_name = '/tmp/test_graph-%s.svg' % uuid.uuid4()
    if os.path.exists(file_name):
        os.remove(file_name)
    chart = Pie(inner_radius=.3, pretty_print=True)
    chart.title = 'Browser usage in February 2012 (in %)'
    chart.add('IE', 19.5)
    chart.add('Firefox', 36.6)
    chart.add('Chrome', 36.3)
    chart.add('Safari', 4.5)
    chart.add('Opera', 2.3)
    chart.render_to_file(file_name)
    with open(file_name) as f:
        assert 'pygal' in f.read()
    os.remove(file_name)
开发者ID:cleder,项目名称:pygal,代码行数:17,代码来源:test_donut.py

示例11: test_multiseries_donut

# 需要导入模块: from pygal import Pie [as 别名]
# 或者: from pygal.Pie import add [as 别名]
def test_multiseries_donut():
    #this just demos that the multiseries pie does not respect the inner_radius
    file_name = '/tmp/test_graph-%s.svg' % uuid.uuid4()
    if os.path.exists(file_name):
        os.remove(file_name)
    chart = Pie(inner_radius=.3, pretty_print=True)
    chart.title = 'Browser usage by version in February 2012 (in %)'
    chart.add('IE', [5.7, 10.2, 2.6, 1])
    chart.add('Firefox', [.6, 16.8, 7.4, 2.2, 1.2, 1, 1, 1.1, 4.3, 1])
    chart.add('Chrome', [.3, .9, 17.1, 15.3, .6, .5, 1.6])
    chart.add('Safari', [4.4, .1])
    chart.add('Opera', [.1, 1.6, .1, .5])
    chart.render_to_file(file_name)
    with open(file_name) as f:
        assert 'pygal' in f.read()
    os.remove(file_name)
开发者ID:cleder,项目名称:pygal,代码行数:18,代码来源:test_donut.py

示例12: _generate_pie_chart

# 需要导入模块: from pygal import Pie [as 别名]
# 或者: from pygal.Pie import add [as 别名]
    def _generate_pie_chart(self, datas):
        """
        After generate the pie chart,save to file and return the chart path

        Keyword arguments:
        datas -- Dict object of parsed information for a pie chart
        """
        if not datas:
            return ""

        pie_chart = Pie(fill=True, interpolate="cubic", style=LightStyle)

        for key, value in datas.items():
            pie_chart.add(key, value)

        path = os.path.join(tempfile.gettempdir(), "pie{}.svg".format(str(int(time.time()))))
        pie_chart.render_to_file(path)
        logging.info("Pie chart was created successfully.")

        return path
开发者ID:burakkose,项目名称:reporter-daemon,代码行数:22,代码来源:generator.py

示例13: test_half_pie

# 需要导入模块: from pygal import Pie [as 别名]
# 或者: from pygal.Pie import add [as 别名]
def test_half_pie():
    """Test a half pie chart"""
    pie = Pie()
    pie.add('IE', 19.5)
    pie.add('Firefox', 36.6)
    pie.add('Chrome', 36.3)
    pie.add('Safari', 4.5)
    pie.add('Opera', 2.3)

    half = Pie(half_pie=True)
    half.add('IE', 19.5)
    half.add('Firefox', 36.6)
    half.add('Chrome', 36.3)
    half.add('Safari', 4.5)
    half.add('Opera', 2.3)
    assert pie.render() != half.render()
开发者ID:ConnorMooreLUC,项目名称:pygal,代码行数:18,代码来源:test_pie.py

示例14: test_pie_serie_radius

# 需要导入模块: from pygal import Pie [as 别名]
# 或者: from pygal.Pie import add [as 别名]
    def test_pie_serie_radius():
        pie = Pie()
        for i in range(10):
            pie.add(str(i), i, inner_radius=(10 - i) / 10)

        return pie.render_response()
开发者ID:fredtantini,项目名称:pygal,代码行数:8,代码来源:tests.py

示例15: __init__

# 需要导入模块: from pygal import Pie [as 别名]
# 或者: from pygal.Pie import add [as 别名]
class Charter:
	def __init__(self, font, filepath, webview, webview_window, 
					loading_spinner):
		self.font = font
		self.filepath = filepath
		self.webview = webview
		# Turn off the right click menu for the webview
		self.webview.props.settings.props.enable_default_context_menu = False
		self.webview_window = webview_window
		self.loading_spinner = loading_spinner
		self.loading_spinner.set_visible(False)
		self.data = []
		self.type = None
		# Size is a tuple of (width, height)
		self.size = (450, 350)
		self.chart = None
		self.colorlist = ['#729fcf', '#ef2929', '#fce94f', '#8ae234', '#ad7fa8', 
							'#fcaf3e',	'#3465a4', '#cc0000', '#edd400', '#73d216', 
							'#75507b', '#f57900', '#204a87', '#a40000', '#c4a000', 
							'#4e9a06', '#5c3566', '#ce5c00', '#d3d7cf']
		#self.sort_colorlist()
		# The custom pygal style used for the pie graph.
		self.style = Style(background='#F7F6F6',
							plot_background='#F7F6F6',
							foreground='#888a85',
							foreground_light='#888a85',
							foreground_dark='#555753',
							opacity='.6',
							opacity_hover='.9',
							transition='200ms ease-in',
	  						colors=(self.colorlist))
		self.visible = True

	def add_entry(self, label, time, color):
		"""Adds an entry to data and gives it a label, time, and color"""
		# If the color is not set
		if color == None:
			# Set the color to light grey
			color = len(self.colorlist)-1
		# If color is specified
		else:
			# Make sure it is a valid color from the colorlist
			while color >= len(self.colorlist)-1:
				color -= len(self.colorlist)-1
		# add the entry to the data
		self.data.append((label, time, color))

	def compound_other_data(self, data):
		"""Compounds smallest data entries into 'other' entry"""
		# This function is necessary to keep legend from growing larger than the 
		# widget it is contained in.
		# Get the sum of all values (the [1] index in the entries)
		sum_of_values = 0
		for entry in data:
			sum_of_values += entry[1]
		# Set the minimum amount to one percent of the total amount
		minimum_amount = 0.01 * sum_of_values
		# Create a list item 'other' and give it a value of 0 and the last color
		# in the CONST_COLOR_LIST.
		other = ['Other ', 0, len(CONST_COLOR_LIST)-1]
		entries_to_compound = []
		entries_compunded = False
		for entry in data:
			if entry[1] <= minimum_amount:
				other[1] += entry[1]
				entries_to_compound.append(entry)
				entries_compunded = True
		# If there is more than one entry to compound into other
		if len(entries_to_compound) > 1:
			for entry in entries_to_compound:
				del data[data.index(entry)]	
		# If the data still has too many entries, compound the smallest into the
		# 'Other' entry
		if len(data) > CONST_MAX_DATA_ENTRIES:
			self.sort_data_by_size(data)
			entries_to_compound = []
			for entry in xrange((len(data) - CONST_MAX_DATA_ENTRIES)):
				other[1] += data[entry][1]
				entries_to_compound.append(data[entry])
				entries_compunded = True
			for entry in entries_to_compound:
				del data[data.index(entry)]
		if entries_compunded:
			data.append(other)

	def create_chart(self, chart_type=None, span=None):
		"""Creates a chart of the given type based the data"""
		if not chart_type == None:
			self.type = chart_type
		if self.type == 'pie':
			self.create_pie_chart(self.data, span)
		elif self.type == 'bar':
			self.create_bar_chart(self.data, span)
	
	def create_pie_chart(self, data=None, span='all', no=None):
		"""Creates a pie chart from the the data"""
		# Create the list of objects to be added to the chart
		chart_list = []
		# If the span has been specified, then get the logs only for that time
		if not span == None and not span == 'all':
#.........这里部分代码省略.........
开发者ID:NicholasShatokhin,项目名称:spindl,代码行数:103,代码来源:charter.py


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