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


Python BarChart.add_serie方法代码示例

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


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

示例1: test_write_no_ascii

# 需要导入模块: from openpyxl.chart import BarChart [as 别名]
# 或者: from openpyxl.chart.BarChart import add_serie [as 别名]
    def test_write_no_ascii(self):

        ws = self.make_worksheet()
        ws.append(["D\xc3\xbcsseldorf"] * 10)
        serie = Serie(values=Reference(ws, (0, 0), (0, 9)), legend=Reference(ws, (1, 0), (1, 9)))
        c = BarChart()
        c.add_serie(serie)
        cw = ChartWriter(c)
开发者ID:Jian-Zhan,项目名称:customarrayformatter,代码行数:10,代码来源:test_chart.py

示例2: numbers

# 需要导入模块: from openpyxl.chart import BarChart [as 别名]
# 或者: from openpyxl.chart.BarChart import add_serie [as 别名]
def numbers(wb):
    ws = wb.create_sheet(1, "Numbers")
    for i in range(10):
        ws.append([i])
    chart = BarChart()
    values = Reference(ws, (0, 0), (9, 0))
    series = Serie(values)
    chart.add_serie(series)
    ws.add_chart(chart)
开发者ID:Jian-Zhan,项目名称:customarrayformatter,代码行数:11,代码来源:charts.py

示例3: negative

# 需要导入模块: from openpyxl.chart import BarChart [as 别名]
# 或者: from openpyxl.chart.BarChart import add_serie [as 别名]
def negative(wb):
    ws = wb.create_sheet(1, "Negative")
    for i in range(-5, 5):
        ws.append([i])
    chart = BarChart()
    values = Reference(ws, (0, 0), (9, 0))
    series = Serie(values)
    chart.add_serie(series)
    ws.add_chart(chart)
开发者ID:Jian-Zhan,项目名称:customarrayformatter,代码行数:11,代码来源:charts.py

示例4: dates

# 需要导入模块: from openpyxl.chart import BarChart [as 别名]
# 或者: from openpyxl.chart.BarChart import add_serie [as 别名]
def dates(wb):
    ws = wb.create_sheet(3, "Dates")
    for i in range(1, 10):
        ws.append([date(2013, i, 1), i])
    chart = BarChart()
    values = Reference(ws, (0, 1), (9, 1))
    labels = Reference(ws, (0, 0), (9, 0))
    labels.number_format = 'd-mmm'
    series = Serie(values, labels=labels)
    chart.add_serie(series)
    ws.add_chart(chart)
开发者ID:Jian-Zhan,项目名称:customarrayformatter,代码行数:13,代码来源:charts.py

示例5: letters

# 需要导入模块: from openpyxl.chart import BarChart [as 别名]
# 或者: from openpyxl.chart.BarChart import add_serie [as 别名]
def letters(wb):
    ws = wb.create_sheet(2, "Letters")
    for idx, l in enumerate("ABCDEFGHIJ"):
        ws.append([l, idx, idx])
    chart = BarChart()
    labels = Reference(ws, (0, 0), (9, 0))
    values = Reference(ws, (0, 1), (9, 1))
    series = Serie(values, labels=labels)
    chart.add_serie(series)
    #  add second series
    values = Reference(ws, (0, 2), (9, 2))
    series = Serie(values, labels=labels)
    chart.add_serie(series)
    ws.add_chart(chart)
开发者ID:Jian-Zhan,项目名称:customarrayformatter,代码行数:16,代码来源:charts.py

示例6: draw_chart

# 需要导入模块: from openpyxl.chart import BarChart [as 别名]
# 或者: from openpyxl.chart.BarChart import add_serie [as 别名]
    def draw_chart(self, wsheet, series, left=0, title=""):
        chart = BarChart()
        chart.title = title
        chart.drawing.left = 500 + left
        chart.drawing.top = 250 + left
        chart.drawing.height = 200
        chart.drawing.width = 500

        i = 0
        for serie in series:
            if len(serie) == 4:

                x1 = int(serie[0])
                y1 = int(serie[1])
                x2 = int(serie[2])
                y2 = int(serie[3])

                if x2 > 3:

                    if i == 0:
                        legend = Reference(wsheet, (0, 0))
                        labels = Reference(wsheet, (x1, 0), (x2, 0))
                    else:
                        if y1 < 13:
                            legend = Reference(wsheet, (0, 4))
                        if y1 >= 13:
                            legend = Reference(wsheet, (0, 13))

                    #value = wsheet.cell(row=4,column=0).value
                    title = wsheet.title
                    if title.find("Rate") < 0:
                        isLabel = True
                    else:
                        if len(title) > 12:
                            isLabel = True
                        else:
                            isLabel = False

                    if i == 0 and isLabel:  # type(value).__name__ <> 'int':
                        seri = Serie(
                            Reference(wsheet, (x1, y1), (x2, y2)), labels=labels, legend=legend)
                    else:
                        seri = Serie(
                            Reference(wsheet, (x1, y1), (x2, y2)), legend=legend)

                    chart.add_serie(seri)

            i += 1

        wsheet.add_chart(chart)
开发者ID:foss-transportationmodeling,项目名称:simtravel,代码行数:52,代码来源:to_msexcel_nogui.py

示例7: TestChartWriter

# 需要导入模块: from openpyxl.chart import BarChart [as 别名]
# 或者: from openpyxl.chart.BarChart import add_serie [as 别名]
class TestChartWriter(object):

    def setUp(self):

        wb = Workbook()
        ws = wb.get_active_sheet()
        ws.title = u'data'
        for i in range(10):
            ws.cell(row = i, column = 0).value = i
        self.chart = BarChart()
        self.chart.title = 'TITLE'
        self.chart.add_serie(Serie(Reference(ws, (0, 0), (10, 0))))
        self.chart._series[-1].color = Color.GREEN
        self.cw = ChartWriter(self.chart)
        self.root = Element('test')

    def test_write_title(self):
        self.cw._write_title(self.root)
        eq_(get_xml(self.root), '<?xml version=\'1.0\' encoding=\'UTF-8\'?><test><c:title><c:tx><c:rich><a:bodyPr /><a:lstStyle /><a:p><a:pPr><a:defRPr /></a:pPr><a:r><a:rPr lang="fr-FR" /><a:t>TITLE</a:t></a:r></a:p></c:rich></c:tx><c:layout /></c:title></test>')

    def test_write_xaxis(self):

        self.cw._write_axis(self.root, self.chart.x_axis, 'c:catAx')
        eq_(get_xml(self.root), '<?xml version=\'1.0\' encoding=\'UTF-8\'?><test><c:catAx><c:axId val="60871424" /><c:scaling><c:orientation val="minMax" /></c:scaling><c:axPos val="b" /><c:tickLblPos val="nextTo" /><c:crossAx val="60873344" /><c:crosses val="autoZero" /><c:auto val="1" /><c:lblAlgn val="ctr" /><c:lblOffset val="100" /></c:catAx></test>')

    def test_write_yaxis(self):

        self.cw._write_axis(self.root, self.chart.y_axis, 'c:valAx')
        eq_(get_xml(self.root), '<?xml version=\'1.0\' encoding=\'UTF-8\'?><test><c:valAx><c:axId val="60873344" /><c:scaling><c:orientation val="minMax" /><c:max val="10.0" /><c:min val="0" /></c:scaling><c:axPos val="l" /><c:majorGridlines /><c:numFmt formatCode="General" sourceLinked="1" /><c:tickLblPos val="nextTo" /><c:crossAx val="60871424" /><c:crosses val="autoZero" /><c:crossBetween val="between" /><c:majorUnit val="2.0" /></c:valAx></test>')

    def test_write_series(self):

        self.cw._write_series(self.root)
        eq_(get_xml(self.root), '<?xml version=\'1.0\' encoding=\'UTF-8\'?><test><c:ser><c:idx val="0" /><c:order val="0" /><c:spPr><a:solidFill><a:srgbClr val="00FF00" /></a:solidFill><a:ln><a:solidFill><a:srgbClr val="00FF00" /></a:solidFill></a:ln></c:spPr><c:marker><c:symbol val="none" /></c:marker><c:val><c:numRef><c:f>data!$A$1:$A$11</c:f><c:numCache><c:formatCode>General</c:formatCode><c:ptCount val="11" /><c:pt idx="0"><c:v>0</c:v></c:pt><c:pt idx="1"><c:v>1</c:v></c:pt><c:pt idx="2"><c:v>2</c:v></c:pt><c:pt idx="3"><c:v>3</c:v></c:pt><c:pt idx="4"><c:v>4</c:v></c:pt><c:pt idx="5"><c:v>5</c:v></c:pt><c:pt idx="6"><c:v>6</c:v></c:pt><c:pt idx="7"><c:v>7</c:v></c:pt><c:pt idx="8"><c:v>8</c:v></c:pt><c:pt idx="9"><c:v>9</c:v></c:pt><c:pt idx="10"><c:v>None</c:v></c:pt></c:numCache></c:numRef></c:val></c:ser></test>')

    def test_write_legend(self):

        self.cw._write_legend(self.root)
        eq_(get_xml(self.root), '<?xml version=\'1.0\' encoding=\'UTF-8\'?><test><c:legend><c:legendPos val="r" /><c:layout /></c:legend></test>')

    def test_write_print_settings(self):

        self.cw._write_print_settings(self.root)
        eq_(get_xml(self.root), '<?xml version=\'1.0\' encoding=\'UTF-8\'?><test><c:printSettings><c:headerFooter /><c:pageMargins b="0.75" footer="0.3" header="0.3" l="0.7" r="0.7" t="0.75" /><c:pageSetup /></c:printSettings></test>')

    def test_write_chart(self):

        self.cw._write_chart(self.root)
        eq_(get_xml(self.root), '<?xml version=\'1.0\' encoding=\'UTF-8\'?><test><c:chart><c:title><c:tx><c:rich><a:bodyPr /><a:lstStyle /><a:p><a:pPr><a:defRPr /></a:pPr><a:r><a:rPr lang="fr-FR" /><a:t>TITLE</a:t></a:r></a:p></c:rich></c:tx><c:layout /></c:title><c:plotArea><c:layout><c:manualLayout><c:layoutTarget val="inner" /><c:xMode val="edge" /><c:yMode val="edge" /><c:x val="1.28571428571" /><c:y val="0.2125" /><c:w val="0.6" /><c:h val="0.6" /></c:manualLayout></c:layout><c:barChart><c:barDir val="col" /><c:grouping val="clustered" /><c:ser><c:idx val="0" /><c:order val="0" /><c:spPr><a:solidFill><a:srgbClr val="00FF00" /></a:solidFill><a:ln><a:solidFill><a:srgbClr val="00FF00" /></a:solidFill></a:ln></c:spPr><c:marker><c:symbol val="none" /></c:marker><c:val><c:numRef><c:f>data!$A$1:$A$11</c:f><c:numCache><c:formatCode>General</c:formatCode><c:ptCount val="11" /><c:pt idx="0"><c:v>0</c:v></c:pt><c:pt idx="1"><c:v>1</c:v></c:pt><c:pt idx="2"><c:v>2</c:v></c:pt><c:pt idx="3"><c:v>3</c:v></c:pt><c:pt idx="4"><c:v>4</c:v></c:pt><c:pt idx="5"><c:v>5</c:v></c:pt><c:pt idx="6"><c:v>6</c:v></c:pt><c:pt idx="7"><c:v>7</c:v></c:pt><c:pt idx="8"><c:v>8</c:v></c:pt><c:pt idx="9"><c:v>9</c:v></c:pt><c:pt idx="10"><c:v>None</c:v></c:pt></c:numCache></c:numRef></c:val></c:ser><c:marker val="1" /><c:axId val="60871424" /><c:axId val="60873344" /></c:barChart><c:catAx><c:axId val="60871424" /><c:scaling><c:orientation val="minMax" /></c:scaling><c:axPos val="b" /><c:tickLblPos val="nextTo" /><c:crossAx val="60873344" /><c:crosses val="autoZero" /><c:auto val="1" /><c:lblAlgn val="ctr" /><c:lblOffset val="100" /></c:catAx><c:valAx><c:axId val="60873344" /><c:scaling><c:orientation val="minMax" /><c:max val="10.0" /><c:min val="0" /></c:scaling><c:axPos val="l" /><c:majorGridlines /><c:numFmt formatCode="General" sourceLinked="1" /><c:tickLblPos val="nextTo" /><c:crossAx val="60871424" /><c:crosses val="autoZero" /><c:crossBetween val="between" /><c:majorUnit val="2.0" /></c:valAx></c:plotArea><c:legend><c:legendPos val="r" /><c:layout /></c:legend><c:plotVisOnly val="1" /></c:chart></test>')
开发者ID:wangzhengbo1204,项目名称:Python,代码行数:51,代码来源:test_chart.py

示例8: Workbook

# 需要导入模块: from openpyxl.chart import BarChart [as 别名]
# 或者: from openpyxl.chart.BarChart import add_serie [as 别名]
"""Simple test charts"""
from datetime import date
import os
from openpyxl import Workbook
from openpyxl.chart import Chart, Serie, Reference, BarChart, PieChart, LineChart, ScatterChart

wb = Workbook()
ws = wb.get_active_sheet()
ws.title = "Numbers"
for i in range(10):
    ws.append([i])
chart = BarChart()
values = Reference(ws, (0, 0), (9, 0))
series = Serie(values)
chart.add_serie(series)
ws.add_chart(chart)

ws = wb.create_sheet(1, "Negative")
for i in range(-5, 5):
    ws.append([i])
chart = BarChart()
values = Reference(ws, (0, 0), (9, 0))
series = Serie(values)
chart.add_serie(series)
ws.add_chart(chart)

ws = wb.create_sheet(2, "Letters")
for idx, l in enumerate("ABCDEFGHIJ"):
    ws.append([l, idx, idx])
chart = BarChart()
labels = Reference(ws, (0, 0), (9, 0))
开发者ID:vidyacraghav,项目名称:openpyxl,代码行数:33,代码来源:chart_gen.py


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