Skip to content

Commit

Permalink
(feat) fix graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
kevincobain2000 committed Dec 27, 2023
1 parent 0f114db commit 7986199
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 23 deletions.
18 changes: 5 additions & 13 deletions pkg/bar_chart_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ func (h *BarChartHandler) Get(c echo.Context) ([]byte, error) {
if len(data.XData) == 0 || len(data.XData) != len(data.YData[0]) {
return nil, echo.NewHTTPError(http.StatusUnprocessableEntity, "data provided is invalid")
}
if len(data.YData) == 1 && !req.Horizontal {
// append [0,0,...0] to data.YData
data.YData = append(data.YData, make([]float64, len(data.YData[0])))
}

if !req.Horizontal {
p, err := charts.BarRender(
Expand Down Expand Up @@ -82,16 +78,12 @@ func (h *BarChartHandler) Get(c echo.Context) ([]byte, error) {
}
idx := len(opt.SeriesList) - 1
if len(opt.SeriesList) > 1 {
opt.SeriesList[idx].MarkPoint = charts.NewMarkPoint(
charts.SeriesMarkDataTypeMax,
charts.SeriesMarkDataTypeMin,
)
} else {
opt.SeriesList[idx].MarkPoint = charts.NewMarkPoint(
charts.SeriesMarkDataTypeMax,
charts.SeriesMarkDataTypeMax,
)
idx = 1
}
opt.SeriesList[idx].MarkPoint = charts.NewMarkPoint(
charts.SeriesMarkDataTypeMax,
charts.SeriesMarkDataTypeMin,
)
opt.SeriesList[idx].MarkLine = charts.NewMarkLine(
charts.SeriesMarkDataTypeAverage,
)
Expand Down
15 changes: 5 additions & 10 deletions pkg/line_chart_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,12 @@ func (h *LineChartHandler) Get(c echo.Context) ([]byte, error) {

idx := len(opt.SeriesList) - 1
if len(opt.SeriesList) > 1 {
opt.SeriesList[idx].MarkPoint = charts.NewMarkPoint(
charts.SeriesMarkDataTypeMax,
charts.SeriesMarkDataTypeMin,
)
} else {
opt.SeriesList[idx].MarkPoint = charts.NewMarkPoint(
charts.SeriesMarkDataTypeMax,
charts.SeriesMarkDataTypeMax,
)
idx = 1
}

opt.SeriesList[idx].MarkPoint = charts.NewMarkPoint(
charts.SeriesMarkDataTypeMax,
charts.SeriesMarkDataTypeMin,
)
opt.SeriesList[idx].MarkLine = charts.NewMarkLine(
charts.SeriesMarkDataTypeAverage,
)
Expand Down

0 comments on commit 7986199

Please sign in to comment.