Toggle navigation
Toggle navigation
This project
Loading...
Sign in
万朱浩
/
Venue-Ops
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
马一丁
2025-11-19 16:12:43 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
cafde0723353715daa76eab6596ee5eb75f9993c
cafde072
1 parent
bd0aa987
Resolves Display Issues with Pie Charts and Line Charts When Exporting to PDF
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
1 deletions
ReportEngine/renderers/chart_to_svg.py
ReportEngine/renderers/chart_to_svg.py
View file @
cafde07
...
...
@@ -155,7 +155,7 @@ class ChartToSVGConverter:
解析颜色值,将CSS格式转换为matplotlib支持的格式
参数:
color: 颜色值(可能是CSS格式如rgba()或十六进制)
color: 颜色值(可能是CSS格式如rgba()或十六进制
或CSS变量
)
返回:
str: matplotlib支持的颜色格式
...
...
@@ -165,6 +165,12 @@ class ChartToSVGConverter:
color
=
color
.
strip
()
# 【修复】处理CSS变量,例如 var(--color-accent)
# 使用默认颜色替代CSS变量
if
color
.
startswith
(
'var('
):
# 返回默认的蓝色
return
'#36A2EB'
# 处理rgba(r, g, b, a)格式
rgba_pattern
=
r'rgba
\
((
\
d+),
\
s*(
\
d+),
\
s*(
\
d+),
\
s*([
\
d.]+)
\
)'
match
=
re
.
match
(
rgba_pattern
,
color
)
...
...
@@ -367,6 +373,9 @@ class ChartToSVGConverter:
if
not
isinstance
(
colors
,
list
):
colors
=
self
.
DEFAULT_COLORS
[:
len
(
labels
)]
# 【修复】解析每个颜色,将CSS格式转换为matplotlib格式
colors
=
[
self
.
_parse_color
(
c
)
for
c
in
colors
]
# 绘制饼图
wedges
,
texts
,
autotexts
=
ax
.
pie
(
dataset_data
,
...
...
@@ -418,6 +427,9 @@ class ChartToSVGConverter:
if
not
isinstance
(
colors
,
list
):
colors
=
self
.
DEFAULT_COLORS
[:
len
(
labels
)]
# 【修复】解析每个颜色,将CSS格式转换为matplotlib格式
colors
=
[
self
.
_parse_color
(
c
)
for
c
in
colors
]
# 绘制圆环图(通过设置wedgeprops实现中空效果)
wedges
,
texts
,
autotexts
=
ax
.
pie
(
dataset_data
,
...
...
Please
register
or
login
to post a comment