[add] tests, [add] refactor epub feat

This commit is contained in:
2023-10-23 20:18:16 -04:00
parent bf6ac96376
commit b5d5e4bd64
17 changed files with 429 additions and 353 deletions

View File

@@ -3,8 +3,6 @@ package graph
import (
"fmt"
"math"
"reichard.io/bbank/database"
)
type SVGGraphPoint struct {
@@ -28,12 +26,12 @@ type SVGBezierOpposedLine struct {
Angle int
}
func GetSVGGraphData(inputData []database.GetDailyReadStatsRow, svgWidth int, svgHeight int) SVGGraphData {
func GetSVGGraphData(inputData []int64, svgWidth int, svgHeight int) SVGGraphData {
// Derive Height
var maxHeight int = 0
for _, item := range inputData {
if int(item.MinutesRead) > maxHeight {
maxHeight = int(item.MinutesRead)
if int(item) > maxHeight {
maxHeight = int(item)
}
}
@@ -55,7 +53,7 @@ func GetSVGGraphData(inputData []database.GetDailyReadStatsRow, svgWidth int, sv
var maxBY int = 0
var minBX int = 0
for idx, item := range inputData {
itemSize := int(float32(item.MinutesRead) * sizeRatio)
itemSize := int(float32(item) * sizeRatio)
itemY := svgHeight - itemSize
lineX := (idx + 1) * blockOffset
barPoints = append(barPoints, SVGGraphPoint{