Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
openpyxl
openpyxl
Commits
9885fa7239d5
Commit
af28e7a0
authored
May 08, 2017
by
CharlieC
Browse files
Adjust implementation to rely on being passed in a chartspace object.
--HG-- branch : 2.5
parent
7ab12ce94c1b
Changes
2
Show whitespace changes
Inline
Side-by-side
openpyxl/chart/reader.py
View file @
9885fa72
...
...
@@ -19,9 +19,8 @@ _types = ('areaChart', 'area3DChart', 'lineChart', 'line3DChart',
_axes
=
(
'valAx'
,
'catAx'
,
'dateAx'
,
'serAx'
,)
def
read_chart
(
src
):
node
=
fromstring
(
src
)
cs
=
ChartSpace
.
from_tree
(
node
)
def
read_chart
(
chartspace
):
cs
=
chartspace
plot
=
cs
.
chart
.
plotArea
for
t
in
_types
:
chart
=
getattr
(
plot
,
t
,
None
)
...
...
@@ -58,7 +57,8 @@ def find_charts(archive, path):
charts
=
[]
for
rel
in
drawing
.
_chart_rels
:
chart
=
get_rel
(
archive
,
deps
,
rel
.
id
,
ChartSpace
)
cs
=
get_rel
(
archive
,
deps
,
rel
.
id
,
ChartSpace
)
chart
=
read_chart
(
cs
)
chart
.
anchor
=
rel
.
anchor
charts
.
append
(
chart
)
...
...
openpyxl/chart/tests/test_reader.py
View file @
9885fa72
...
...
@@ -3,8 +3,11 @@ from __future__ import absolute_import
from
zipfile
import
ZipFile
from
openpyxl.xml.functions
import
fromstring
from
..
line_chart
import
LineChart
from
..
axis
import
NumericAxis
,
DateAxis
from
..
chartspace
import
ChartSpace
def
test_read
(
datadir
):
...
...
@@ -13,8 +16,10 @@ def test_read(datadir):
with
open
(
"chart1.xml"
)
as
src
:
xml
=
src
.
read
()
tree
=
fromstring
(
xml
)
cs
=
ChartSpace
.
from_tree
(
tree
)
chart
=
read_chart
(
cs
)
chart
=
read_chart
(
xml
)
assert
isinstance
(
chart
,
LineChart
)
assert
chart
.
title
.
tx
.
rich
.
p
[
0
].
r
.
t
==
"Website Performance"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment