tabledata
This commit is contained in:
parent
35e9c33cf3
commit
724ee2c90b
6
table.go
6
table.go
|
@ -118,7 +118,7 @@ func (g *TableGenerator) scaled(value float64) float64 {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算每列的最大宽度(考虑缩放)
|
// 计算每列的最大宽度(考虑缩放)
|
||||||
func (g *TableGenerator) calculateColumnWidths(data TableData) []float64 {
|
func (g *TableGenerator) calculateColumnWidths(data *TableData) []float64 {
|
||||||
colCount := len(data.Headers)
|
colCount := len(data.Headers)
|
||||||
colWidths := make([]float64, colCount)
|
colWidths := make([]float64, colCount)
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ func (g *TableGenerator) calculateColumnWidths(data TableData) []float64 {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算每行的最大高度(考虑缩放)
|
// 计算每行的最大高度(考虑缩放)
|
||||||
func (g *TableGenerator) calculateRowHeights(data TableData, colWidths []float64) []float64 {
|
func (g *TableGenerator) calculateRowHeights(data *TableData, colWidths []float64) []float64 {
|
||||||
rowCount := len(data.Rows) + 1 // 包括表头
|
rowCount := len(data.Rows) + 1 // 包括表头
|
||||||
rowHeights := make([]float64, rowCount)
|
rowHeights := make([]float64, rowCount)
|
||||||
|
|
||||||
|
@ -278,7 +278,7 @@ func (g *TableGenerator) drawTitle(dc *gg.Context, margin, tableWidth float64, t
|
||||||
}
|
}
|
||||||
|
|
||||||
// 生成自适应表格(高清版本)
|
// 生成自适应表格(高清版本)
|
||||||
func (g *TableGenerator) Generate(data TableData, filename string) error {
|
func (g *TableGenerator) Generate(data *TableData, filename string) error {
|
||||||
// 先创建一个临时上下文来测量文本
|
// 先创建一个临时上下文来测量文本
|
||||||
tempDC := gg.NewContext(1, 1)
|
tempDC := gg.NewContext(1, 1)
|
||||||
if err := g.loadHDFont(tempDC, g.config.FontSize); err != nil {
|
if err := g.loadHDFont(tempDC, g.config.FontSize); err != nil {
|
||||||
|
|
Loading…
Reference in New Issue