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


Python charts.BarChartWriter类代码示例

本文整理汇总了Python中openpyxl.writer.charts.BarChartWriter的典型用法代码示例。如果您正苦于以下问题:Python BarChartWriter类的具体用法?Python BarChartWriter怎么用?Python BarChartWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_write_xaxis

 def test_write_xaxis(self, bar_chart, root_xml):
     cw = BarChartWriter(bar_chart)
     cw._write_axis(root_xml, bar_chart.x_axis, '{%s}catAx' % CHART_NS)
     expected = """<?xml version='1.0' ?><test xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart"><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>"""
     xml = get_xml(root_xml)
     diff = compare_xml(xml, expected)
     assert diff is None, diff
开发者ID:adammorris,项目名称:openpyxl,代码行数:7,代码来源:test_chart_writer.py

示例2: test_write_series

 def test_write_series(self, bar_chart, root_xml):
     cw = BarChartWriter(bar_chart)
     cw._write_series(root_xml)
     expected = """<?xml version='1.0' ?><test xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart"><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: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>"""
     xml = get_xml(root_xml)
     diff = compare_xml(xml, expected)
     assert diff is None, diff
开发者ID:adammorris,项目名称:openpyxl,代码行数:7,代码来源:test_chart_writer.py

示例3: test_write_yaxis

 def test_write_yaxis(self, bar_chart, root_xml):
     cw = BarChartWriter(bar_chart)
     cw._write_axis(root_xml, bar_chart.y_axis, '{%s}valAx' % CHART_NS)
     expected = """<?xml version='1.0' ?><test xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart"><c:valAx><c:axId val="60873344" /><c:scaling><c:orientation val="minMax" /><c:max val="10.0" /><c:min val="0.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>"""
     xml = get_xml(root_xml)
     diff = compare_xml(xml, expected)
     assert diff is None, diff
开发者ID:adammorris,项目名称:openpyxl,代码行数:7,代码来源:test_chart_writer.py

示例4: test_write_legend

 def test_write_legend(self, bar_chart, root_xml):
     cw = BarChartWriter(bar_chart)
     cw._write_legend(root_xml)
     expected = """<?xml version='1.0' ?><test xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart"><c:legend><c:legendPos val="r" /><c:layout /></c:legend></test>"""
     xml = get_xml(root_xml)
     diff = compare_xml(xml, expected)
     assert diff is None, diff
开发者ID:adammorris,项目名称:openpyxl,代码行数:7,代码来源:test_chart_writer.py

示例5: test_write_title

 def test_write_title(self, bar_chart, root_xml):
     cw = BarChartWriter(bar_chart)
     cw._write_title(root_xml)
     expected = """<?xml version='1.0' ?><test xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart"><c:title><c:tx><c:rich><a:bodyPr /><a:lstStyle /><a:p><a:pPr><a:defRPr /></a:pPr><a:r><a:rPr lang="en-GB" /><a:t>TITLE</a:t></a:r></a:p></c:rich></c:tx><c:layout /></c:title></test>"""
     xml = get_xml(root_xml)
     diff = compare_xml(xml, expected)
     assert diff is None, diff
开发者ID:adammorris,项目名称:openpyxl,代码行数:7,代码来源:test_chart_writer.py

示例6: test_serialised

 def test_serialised(self, bar_chart_2):
     """Check the serialised file against sample"""
     cw = BarChartWriter(bar_chart_2)
     xml = cw.write()
     tree = fromstring(xml)
     chart_schema.assertValid(tree)
     expected_file = os.path.join(DATADIR, "writer", "expected", "BarChart.xml")
     with open(expected_file) as expected:
         diff = compare_xml(xml, expected.read())
         assert diff is None, diff
开发者ID:adammorris,项目名称:openpyxl,代码行数:10,代码来源:test_chart_writer.py

示例7: test_write_chart

    def test_write_chart(self, bar_chart):
        cw = BarChartWriter(bar_chart)
        cw._write_chart()
        assert chart_schema.validate(cw.root)

        expected = """<c:chartSpace xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart"><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="en-GB" /><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="0.03375" /><c:y val="0.31" /><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: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: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.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></c:chartSpace>"""

        xml = get_xml(cw.root)
        diff = compare_xml(xml, expected)
        assert diff is None, diff
开发者ID:adammorris,项目名称:openpyxl,代码行数:10,代码来源:test_chart_writer.py

示例8: test_serialised

 def test_serialised(self, bar_chart, datadir):
     """Check the serialised file against sample"""
     cw = BarChartWriter(bar_chart)
     xml = cw.write()
     tree = fromstring(xml)
     chart_schema.assertValid(tree)
     datadir.chdir()
     with open("BarChart.xml") as expected:
         diff = compare_xml(xml, expected.read())
         assert diff is None, diff
开发者ID:Hitachi-Data-Systems,项目名称:org-chart-builder,代码行数:10,代码来源:test_bar.py

示例9: test_label_no_number_format

 def test_label_no_number_format(self, ten_column_sheet, Reference, Series, BarChart, root_xml):
     ws = ten_column_sheet
     for i in range(10):
         ws.append([i, i])
     labels = Reference(ws, (0,0), (0,9))
     values = Reference(ws, (0,0), (0,9))
     serie = Series(values=values, labels=labels)
     c = BarChart()
     c.add_serie(serie)
     cw = BarChartWriter(c)
     cw._write_serial(root_xml, c.series[0].labels)
     expected = """<test xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart"><c:numRef><c:f>'data'!$A$1:$J$1</c:f><c:numCache><c:formatCode>General</c:formatCode><c:ptCount val="10" /><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:numCache></c:numRef></test>"""
     xml = get_xml(root_xml)
     diff = compare_xml(xml, expected)
     assert diff is None, diff
开发者ID:adammorris,项目名称:openpyxl,代码行数:15,代码来源:test_chart_writer.py

示例10: test_label_number_format

    def test_label_number_format(self, ten_column_sheet, Reference, Series, BarChart):
        ws = ten_column_sheet
        labels = Reference(ws, (1,1), (1,10))
        labels.number_format = 'd-mmm'
        values = Reference(ws, (1,1), (1,10))
        serie = Series(values=values, labels=labels)
        c = BarChart()
        c.add_serie(serie)
        cw = BarChartWriter(c)
        root = Element('test')
        cw._write_serial(root, c.series[0].labels)

        expected = """<test xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart"><c:numRef><c:f>'data'!$A$1:$J$1</c:f><c:numCache><c:formatCode>d-mmm</c:formatCode><c:ptCount val="10" /><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:numCache></c:numRef></test>"""

        xml = get_xml(root)
        diff = compare_xml(xml, expected)
        assert diff is None, diff
开发者ID:LKI,项目名称:PythonScripts,代码行数:17,代码来源:test_chart.py

示例11: test_write_print_settings

 def test_write_print_settings(self, bar_chart):
     cw = BarChartWriter(bar_chart)
     cw._write_print_settings()
     tagnames = ['test',
                 '{%s}printSettings' % CHART_NS,
                 '{%s}headerFooter' % CHART_NS,
                 '{%s}pageMargins' % CHART_NS,
                 '{%s}pageSetup' % CHART_NS]
     for e in cw.root:
         assert e.tag in tagnames
         if e.tag == "{%s}pageMargins" % CHART_NS:
             assert e.keys() == list(bar_chart.print_margins.keys())
             for k, v in e.items():
                 assert float(v) == bar_chart.print_margins[k]
         else:
             assert e.text == None
             assert e.attrib == {}
开发者ID:adammorris,项目名称:openpyxl,代码行数:17,代码来源:test_chart_writer.py

示例12: test_no_write_legend

 def test_no_write_legend(self, bar_chart, root_xml):
     cw = BarChartWriter(bar_chart)
     bar_chart.show_legend = False
     cw._write_legend(root_xml)
     children = [e for e in root_xml]
     assert len(children) == 0
开发者ID:adammorris,项目名称:openpyxl,代码行数:6,代码来源:test_chart_writer.py

示例13: test_write_rels

 def test_write_rels(self, bar_chart):
     cw = BarChartWriter(bar_chart)
     xml = cw.write_rels(1)
     expected = """<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartUserShapes" Target="../drawings/drawing1.xml"/></Relationships>"""
     diff = compare_xml(xml, expected)
     assert diff is None, diff
开发者ID:adammorris,项目名称:openpyxl,代码行数:6,代码来源:test_chart_writer.py


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