def __init__(self, _type, grouping): self._series = [] # public api self.type = _type self.grouping = grouping self.x_axis = Axis.default_category() self.y_axis = Axis.default_value() self.legend = Legend() self.lang = 'fr-FR' self.title = '' self.print_margins = dict(b=.75, l=.7, r=.7, t=.75, header=0.3, footer=.3) # the containing drawing self.drawing = Drawing() # the offset for the plot part in percentage of the drawing size self.width = .6 self.height = .6 self.margin_top = self._get_max_margin_top() self.margin_left = 0 # the user defined shapes self._shapes = []
def test_write_chart(self): from openpyxl.drawing import Drawing root = Element("{%s}wsDr" % SHEET_DRAWING_NS) chart = DummyChart() drawing = Drawing() chart.drawing = drawing self.dw._write_chart(root, chart, 1) drawing_schema.assertValid(root) xml = tostring(root) expected = """<xdr:wsDr xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart"> <xdr:absoluteAnchor> <xdr:pos x="0" y="0"/> <xdr:ext cx="200025" cy="1828800"/> <xdr:graphicFrame macro=""> <xdr:nvGraphicFramePr> <xdr:cNvPr id="2" name="Chart 1"/> <xdr:cNvGraphicFramePr/> </xdr:nvGraphicFramePr> <xdr:xfrm> <a:off x="0" y="0"/> <a:ext cx="0" cy="0"/> </xdr:xfrm> <a:graphic> <a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/chart"> <c:chart xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" r:id="rId1"/> </a:graphicData> </a:graphic> </xdr:graphicFrame> <xdr:clientData/> </xdr:absoluteAnchor> </xdr:wsDr>""" diff = compare_xml(xml, expected) assert diff is None, diff
def __init__(self): self.series = [] self._series = self.series # backwards compatible # public api self.legend = Legend() self.show_legend = True self.lang = 'en-GB' self.title = '' self.print_margins = dict(b=.75, l=.7, r=.7, t=.75, header=0.3, footer=.3) # the containing drawing self.drawing = Drawing() self.drawing.left = 10 self.drawing.top = 400 self.drawing.height = 400 self.drawing.width = 800 # the offset for the plot part in percentage of the drawing size self.width = .6 self.height = .6 self._margin_top = 1 self._margin_top = self.margin_top self._margin_left = 0 # the user defined shapes self.shapes = [] self._shapes = self.shapes # backwards compatible
def setup(self): from openpyxl.drawing import Drawing self.drawing = Drawing()