use javascript chart instead of svg
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-02-06 16:42:48 +11:00
parent 9677d083a8
commit a993aedf79
13 changed files with 1152 additions and 1290 deletions

View File

@@ -0,0 +1,41 @@
package handler
import "encoding/json"
type lineChartConfig struct {
Height int `json:"height,omitempty"`
XTicks int `json:"xTicks,omitempty"`
YTicks int `json:"yTicks,omitempty"`
YLabel string `json:"yLabel,omitempty"`
XLabel string `json:"xLabel,omitempty"`
Labels []string `json:"labels"`
TickLabels []string `json:"tickLabels,omitempty"`
Series []lineChartSeries `json:"series"`
HoverRows []lineChartHoverRow `json:"hoverRows,omitempty"`
}
type lineChartSeries struct {
Name string `json:"name"`
Color string `json:"color"`
Values []float64 `json:"values"`
Dash []float64 `json:"dash,omitempty"`
LineWidth float64 `json:"lineWidth,omitempty"`
TooltipFormat string `json:"tooltipFormat,omitempty"`
TooltipHidden bool `json:"tooltipHidden,omitempty"`
}
type lineChartHoverRow struct {
Name string `json:"name"`
Values []string `json:"values"`
}
func encodeLineChartConfig(cfg lineChartConfig) string {
if len(cfg.Labels) == 0 || len(cfg.Series) == 0 {
return ""
}
out, err := json.Marshal(cfg)
if err != nil {
return ""
}
return string(out)
}