diff --git a/handlers/corporate/mcudetail/tabkepesertaan.handlers.go b/handlers/corporate/mcudetail/tabkepesertaan.handlers.go index 28dbe4c..514312d 100644 --- a/handlers/corporate/mcudetail/tabkepesertaan.handlers.go +++ b/handlers/corporate/mcudetail/tabkepesertaan.handlers.go @@ -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) } diff --git a/models/chart.models.go b/models/chart.models.go new file mode 100644 index 0000000..4917550 --- /dev/null +++ b/models/chart.models.go @@ -0,0 +1,87 @@ +package models + +type SeriesData struct { + Value int `json:"value"` + Name string `json:"name"` +} + +type Series struct { + Label struct { + Position string `json:"position"` + Formatter string `json:"formatter"` + } `json:"label"` + Name string `json:"name"` + Type string `json:"type"` + Radius []string `json:"radius"` + ItemStyle struct { + BorderRadius int `json:"borderRadius"` + BorderColor string `json:"borderColor"` + BorderWidth int `json:"borderWidth"` + } `json:"itemStyle"` + Data []SeriesData `json:"data"` + Emphasis struct { + ItemStyle struct { + ShadowBlur int `json:"shadowBlur"` + ShadowOffsetX int `json:"shadowOffsetX"` + ShadowColor string `json:"shadowColor"` + } `json:"itemStyle"` + } `json:"emphasis"` +} + +type Piechart struct { + Title struct { + Text string `json:"text"` + SubText string `json:"subtext"` + Left string `json:"left"` + } `json:"title"` + Tooltip struct { + Trigger string `json:"trigger"` + } `json:"tooltip"` + Legend struct { + Top string `json:"top"` + Left string `json:"left"` + Orient string `json:"orient"` + } `json:"legend"` + Series []Series `json:"series"` +} + +type Barchart struct { + Title struct { + Text string `json:"text"` + } `json:"title"` + Dataset struct { + Source [][]interface{} `json:"source"` + } `json:"dataset"` + Grid struct { + ContainLabel bool `json:"containLabel"` + } `json:"grid"` + XAxis struct { + Name string `json:"name"` + } `json:"xAxis"` + YAxis struct { + Type string `json:"type"` + } `json:"yAxis"` + VisualMap struct { + Orient string `json:"orient"` + Left string `json:"left"` + Min int `json:"min"` + Max int `json:"max"` + Show bool `json:"show"` + Dimension int `json:"dimension"` + InRange struct { + Color []string `json:"color"` + } `json:"inRange"` + } `json:"visualMap"` + Series []struct { + Label struct { + Position string `json:"position"` + Show bool `json:"show"` + Formatter string `json:"formatter"` + } `json:"label"` + Type string `json:"type"` + Encode struct { + X string `json:"x"` + Y string `json:"y"` + } `json:"encode"` + } `json:"series"` +} diff --git a/views/corporate/mcu/mcutabview.templ b/views/corporate/mcu/mcutabview.templ index e540979..9bd85c0 100644 --- a/views/corporate/mcu/mcutabview.templ +++ b/views/corporate/mcu/mcutabview.templ @@ -6,7 +6,7 @@ templ TabViewMcuDetail(
- + // +
@@ -51,19 +52,16 @@ templ TabViewMcuDetail(
-
-
+
-
-
+
-
-
+
} \ No newline at end of file diff --git a/views/corporate/mcu/mcutabview_templ.go b/views/corporate/mcu/mcutabview_templ.go index f649d2b..aa9327d 100644 --- a/views/corporate/mcu/mcutabview_templ.go +++ b/views/corporate/mcu/mcutabview_templ.go @@ -25,16 +25,29 @@ func TabViewMcuDetail( templ_7745c5c3_Var1 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
Keuangan