Skip to content

Commit

Permalink
This closes qax-os#279, refs qax-os#1536, change the default point to…
Browse files Browse the repository at this point in the history
… pixels conversion factor
  • Loading branch information
xuri committed Jul 11, 2023
1 parent 7f1e76c commit 002508b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion chart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func TestChartSize(t *testing.T) {
}

if !assert.Equal(t, 14, anchor.To.Col, "Expected 'to' column 14") ||
!assert.Equal(t, 27, anchor.To.Row, "Expected 'to' row 27") {
!assert.Equal(t, 29, anchor.To.Row, "Expected 'to' row 29") {

t.FailNow()
}
Expand Down
11 changes: 6 additions & 5 deletions rows.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,9 @@ func (f *File) getRowHeight(sheet string, row int) int {
return int(convertRowHeightToPixels(*v.Ht))
}
}
if ws.SheetFormatPr != nil && ws.SheetFormatPr.DefaultRowHeight > 0 {
return int(convertRowHeightToPixels(ws.SheetFormatPr.DefaultRowHeight))
}
// Optimization for when the row heights haven't changed.
return int(defaultRowHeightPixels)
}
Expand All @@ -390,7 +393,7 @@ func (f *File) getRowHeight(sheet string, row int) int {
// height, err := f.GetRowHeight("Sheet1", 1)
func (f *File) GetRowHeight(sheet string, row int) (float64, error) {
if row < 1 {
return defaultRowHeightPixels, newInvalidRowNumberError(row)
return defaultRowHeight, newInvalidRowNumberError(row)
}
ht := defaultRowHeight
ws, err := f.workSheetReader(sheet)
Expand Down Expand Up @@ -840,10 +843,8 @@ func (f *File) SetRowStyle(sheet string, start, end, styleID int) error {
// cell from user's units to pixels. If the height hasn't been set by the user
// we use the default value. If the row is hidden it has a value of zero.
func convertRowHeightToPixels(height float64) float64 {
var pixels float64
if height == 0 {
return pixels
return 0
}
pixels = math.Ceil(4.0 / 3.0 * height)
return pixels
return math.Ceil(4.0 / 3.4 * height)
}
2 changes: 1 addition & 1 deletion xmlDrawing.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ const (
pivotTableVersion = 3
defaultPictureScale = 1.0
defaultChartDimensionWidth = 480
defaultChartDimensionHeight = 290
defaultChartDimensionHeight = 260
defaultChartLegendPosition = "bottom"
defaultChartShowBlanksAs = "gap"
defaultShapeSize = 160
Expand Down

0 comments on commit 002508b

Please sign in to comment.