add tabview kepersetaan

This commit is contained in:
2024-06-26 14:19:57 +07:00
parent 91a157b023
commit 9008cac97d
4 changed files with 210 additions and 37 deletions

View File

@@ -1,9 +1,14 @@
package mcu_corporate_handlers
import (
"net/http"
"cpone/component/chart"
"cpone/models"
"cpone/utils"
corporate_mcudetail "cpone/views/corporate/mcu/mcutab"
"encoding/json"
"github.com/labstack/echo/v4"
"go.uber.org/zap"
)
type TabKepersertaanServices interface {
@@ -20,5 +25,88 @@ func NewTabKepersertaanHandler(tkh TabKepersertaanServices) *TabKepersertaanHand
}
func (tkh *TabKepersertaanHandler) HandleShowTabKepesertaan(c echo.Context) error {
return c.String(http.StatusOK, "test")
logger, _ := zap.NewProduction()
logger.Info("Tab Kepesertaan")
id := c.Param("id")
logger.Info("Params", zap.Any("id", id))
option := models.Piechart{
Title: struct {
Text string `json:"text"`
SubText string `json:"subtext"`
Left string `json:"left"`
}{
Text: "Testing",
SubText: "Total Peserta 506",
Left: "center",
},
Tooltip: struct {
Trigger string `json:"trigger"`
}{
Trigger: "item",
},
Legend: struct {
Top string `json:"top"`
Left string `json:"left"`
Orient string `json:"orient"`
}{
Top: "bottom",
Left: "center",
Orient: "vertical",
},
Series: []models.Series{
{
Label: struct {
Position string `json:"position"`
Formatter string `json:"formatter"`
}{
Position: "inner",
Formatter: "{d}%",
},
Name: "Access From",
Type: "pie",
Radius: []string{"20%", "50%"},
ItemStyle: struct {
BorderRadius int `json:"borderRadius"`
BorderColor string `json:"borderColor"`
BorderWidth int `json:"borderWidth"`
}{
BorderRadius: 10,
BorderColor: "#fff",
BorderWidth: 2,
},
Data: []models.SeriesData{
{Value: 506, Name: "Sudah MCU : 506 Peserta"},
{Value: 54, Name: "Belum MCU : 54 Peserta"},
},
Emphasis: struct {
ItemStyle struct {
ShadowBlur int `json:"shadowBlur"`
ShadowOffsetX int `json:"shadowOffsetX"`
ShadowColor string `json:"shadowColor"`
} `json:"itemStyle"`
}{
ItemStyle: struct {
ShadowBlur int `json:"shadowBlur"`
ShadowOffsetX int `json:"shadowOffsetX"`
ShadowColor string `json:"shadowColor"`
}{
ShadowBlur: 10,
ShadowOffsetX: 0,
ShadowColor: "rgba(0, 0, 0, 0.5)",
},
},
},
},
}
json, err := json.MarshalIndent(option, "", " ")
if err != nil {
return err
}
content := corporate_mcudetail.TabKepesertaan(chart.ShowChart("1", string(json)))
return utils.View(c, content)
}