use javascript chart instead of svg
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
41
server/handler/chart_config.go
Normal file
41
server/handler/chart_config.go
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user