Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xuri
excelize
提交
bba155e0
excelize
项目概览
xuri
/
excelize
通知
13
Star
2
Fork
4
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
excelize
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
bba155e0
编写于
2月 04, 2024
作者:
C
coolbit
提交者:
GitHub
2月 04, 2024
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
This closes #1805, support set chart axis font family, size and strike style (#1809)
- Update unit test workflow dependencies package version
上级
a258e3d8
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
32 addition
and
20 deletion
+32
-20
.github/workflows/go.yml
.github/workflows/go.yml
+1
-1
chart_test.go
chart_test.go
+1
-1
drawing.go
drawing.go
+30
-18
未找到文件。
.github/workflows/go.yml
浏览文件 @
bba155e0
...
...
@@ -31,7 +31,7 @@ jobs:
run
:
env GO111MODULE=on go test -v -timeout 30m -race ./... -coverprofile=coverage.txt -covermode=atomic
-
name
:
Codecov
uses
:
codecov/codecov-action@v
3
uses
:
codecov/codecov-action@v
4
with
:
file
:
coverage.txt
flags
:
unittests
...
...
chart_test.go
浏览文件 @
bba155e0
...
...
@@ -214,7 +214,7 @@ func TestAddChart(t *testing.T) {
sheetName
,
cell
string
opts
*
Chart
}{
{
sheetName
:
"Sheet1"
,
cell
:
"P1"
,
opts
:
&
Chart
{
Type
:
Col
,
Series
:
series
,
Format
:
format
,
Legend
:
ChartLegend
{
Position
:
"none"
,
ShowLegendKey
:
true
},
Title
:
[]
RichTextRun
{{
Text
:
"2D Column Chart"
}},
PlotArea
:
plotArea
,
Border
:
ChartLine
{
Type
:
ChartLineNone
},
ShowBlanksAs
:
"zero"
,
XAxis
:
ChartAxis
{
Font
:
Font
{
Bold
:
true
,
Italic
:
true
,
Underline
:
"dbl"
,
Color
:
"000000"
},
Title
:
[]
RichTextRun
{{
Text
:
"Primary Horizontal Axis Title"
}}},
YAxis
:
ChartAxis
{
Font
:
Font
{
Bold
:
false
,
Italic
:
false
,
Underline
:
"sng"
,
Color
:
"777777"
},
Title
:
[]
RichTextRun
{{
Text
:
"Primary Vertical Axis Title"
,
Font
:
&
Font
{
Color
:
"777777"
,
Bold
:
true
,
Italic
:
true
,
Size
:
12
}}}}}},
{
sheetName
:
"Sheet1"
,
cell
:
"P1"
,
opts
:
&
Chart
{
Type
:
Col
,
Series
:
series
,
Format
:
format
,
Legend
:
ChartLegend
{
Position
:
"none"
,
ShowLegendKey
:
true
},
Title
:
[]
RichTextRun
{{
Text
:
"2D Column Chart"
}},
PlotArea
:
plotArea
,
Border
:
ChartLine
{
Type
:
ChartLineNone
},
ShowBlanksAs
:
"zero"
,
XAxis
:
ChartAxis
{
Font
:
Font
{
Bold
:
true
,
Italic
:
true
,
Underline
:
"dbl"
,
Family
:
"Times New Roman"
,
Size
:
15
,
Strike
:
true
,
Color
:
"000000"
},
Title
:
[]
RichTextRun
{{
Text
:
"Primary Horizontal Axis Title"
}}},
YAxis
:
ChartAxis
{
Font
:
Font
{
Bold
:
false
,
Italic
:
false
,
Underline
:
"sng"
,
Color
:
"777777"
},
Title
:
[]
RichTextRun
{{
Text
:
"Primary Vertical Axis Title"
,
Font
:
&
Font
{
Color
:
"777777"
,
Bold
:
true
,
Italic
:
true
,
Size
:
12
}}}}}},
{
sheetName
:
"Sheet1"
,
cell
:
"X1"
,
opts
:
&
Chart
{
Type
:
ColStacked
,
Series
:
series
,
Format
:
format
,
Legend
:
legend
,
Title
:
[]
RichTextRun
{{
Text
:
"2D Stacked Column Chart"
}},
PlotArea
:
plotArea
,
Fill
:
Fill
{
Type
:
"pattern"
,
Pattern
:
1
},
Border
:
ChartLine
{
Type
:
ChartLineAutomatic
},
ShowBlanksAs
:
"zero"
}},
{
sheetName
:
"Sheet1"
,
cell
:
"P16"
,
opts
:
&
Chart
{
Type
:
ColPercentStacked
,
Series
:
series
,
Format
:
format
,
Legend
:
legend
,
Title
:
[]
RichTextRun
{{
Text
:
"100% Stacked Column Chart"
}},
PlotArea
:
plotArea
,
Fill
:
Fill
{
Type
:
"pattern"
,
Color
:
[]
string
{
"EEEEEE"
},
Pattern
:
1
},
Border
:
ChartLine
{
Type
:
ChartLineSolid
,
Width
:
2
},
ShowBlanksAs
:
"zero"
}},
{
sheetName
:
"Sheet1"
,
cell
:
"X16"
,
opts
:
&
Chart
{
Type
:
Col3DClustered
,
Series
:
series
,
Format
:
format
,
Legend
:
ChartLegend
{
Position
:
"bottom"
,
ShowLegendKey
:
false
},
Title
:
[]
RichTextRun
{{
Text
:
"3D Clustered Column Chart"
}},
PlotArea
:
plotArea
,
ShowBlanksAs
:
"zero"
}},
...
...
drawing.go
浏览文件 @
bba155e0
...
...
@@ -1155,6 +1155,34 @@ func (f *File) drawPlotAreaSerAx(opts *Chart) []*cAxs {
}
}
// drawChartFont provides a function to draw the a:rPr element.
func
drawChartFont
(
fnt
*
Font
,
r
*
aRPr
)
{
if
fnt
==
nil
{
return
}
r
.
B
=
fnt
.
Bold
r
.
I
=
fnt
.
Italic
if
idx
:=
inStrSlice
(
supportedDrawingUnderlineTypes
,
fnt
.
Underline
,
true
);
idx
!=
-
1
{
r
.
U
=
supportedDrawingUnderlineTypes
[
idx
]
}
if
fnt
.
Color
!=
""
{
if
r
.
SolidFill
==
nil
{
r
.
SolidFill
=
&
aSolidFill
{}
}
r
.
SolidFill
.
SchemeClr
=
nil
r
.
SolidFill
.
SrgbClr
=
&
attrValString
{
Val
:
stringPtr
(
strings
.
ReplaceAll
(
strings
.
ToUpper
(
fnt
.
Color
),
"#"
,
""
))}
}
if
fnt
.
Family
!=
""
{
r
.
Latin
.
Typeface
=
fnt
.
Family
}
if
fnt
.
Size
>
0
{
r
.
Sz
=
fnt
.
Size
*
100
}
if
fnt
.
Strike
{
r
.
Strike
=
"sngStrike"
}
}
// drawPlotAreaTitles provides a function to draw the c:title element.
func
(
f
*
File
)
drawPlotAreaTitles
(
runs
[]
RichTextRun
,
vert
string
)
*
cTitle
{
if
len
(
runs
)
==
0
{
...
...
@@ -1163,15 +1191,7 @@ func (f *File) drawPlotAreaTitles(runs []RichTextRun, vert string) *cTitle {
title
:=
&
cTitle
{
Tx
:
cTx
{
Rich
:
&
cRich
{}},
Overlay
:
&
attrValBool
{
Val
:
boolPtr
(
false
)}}
for
_
,
run
:=
range
runs
{
r
:=
&
aR
{
T
:
run
.
Text
}
if
run
.
Font
!=
nil
{
r
.
RPr
.
B
,
r
.
RPr
.
I
=
run
.
Font
.
Bold
,
run
.
Font
.
Italic
if
run
.
Font
.
Color
!=
""
{
r
.
RPr
.
SolidFill
=
&
aSolidFill
{
SrgbClr
:
&
attrValString
{
Val
:
stringPtr
(
run
.
Font
.
Color
)}}
}
if
run
.
Font
.
Size
>
0
{
r
.
RPr
.
Sz
=
run
.
Font
.
Size
*
100
}
}
drawChartFont
(
run
.
Font
,
&
r
.
RPr
)
title
.
Tx
.
Rich
.
P
=
append
(
title
.
Tx
.
Rich
.
P
,
aP
{
PPr
:
&
aPPr
{
DefRPr
:
aRPr
{}},
R
:
r
,
...
...
@@ -1241,15 +1261,7 @@ func (f *File) drawPlotAreaTxPr(opts *ChartAxis) *cTxPr {
},
}
if
opts
!=
nil
{
cTxPr
.
P
.
PPr
.
DefRPr
.
B
=
opts
.
Font
.
Bold
cTxPr
.
P
.
PPr
.
DefRPr
.
I
=
opts
.
Font
.
Italic
if
idx
:=
inStrSlice
(
supportedDrawingUnderlineTypes
,
opts
.
Font
.
Underline
,
true
);
idx
!=
-
1
{
cTxPr
.
P
.
PPr
.
DefRPr
.
U
=
supportedDrawingUnderlineTypes
[
idx
]
}
if
opts
.
Font
.
Color
!=
""
{
cTxPr
.
P
.
PPr
.
DefRPr
.
SolidFill
.
SchemeClr
=
nil
cTxPr
.
P
.
PPr
.
DefRPr
.
SolidFill
.
SrgbClr
=
&
attrValString
{
Val
:
stringPtr
(
strings
.
ReplaceAll
(
strings
.
ToUpper
(
opts
.
Font
.
Color
),
"#"
,
""
))}
}
drawChartFont
(
&
opts
.
Font
,
&
cTxPr
.
P
.
PPr
.
DefRPr
)
}
return
cTxPr
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录