step 1 : komponen mcu peserta

This commit is contained in:
sindhu
2024-05-01 10:28:57 +07:00
parent 0219959594
commit 6260d3bc25
5 changed files with 759 additions and 16 deletions

View File

@@ -106,8 +106,9 @@ type Piechart struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
Title struct {
Text string `json:"text"`
Left string `json:"left"`
Text string `json:"text"`
SubText string `json:"subtext"`
Left string `json:"left"`
} `json:"title"`
Tooltip struct {
Trigger string `json:"trigger"`
@@ -180,14 +181,16 @@ type ServicesPiechart struct {
// Peserta MCU -- MCU001
func GetPieChartMcu001(code string, id int) (string, Piechart, error) {
var title = "Status Index Masa Tubuh (BMI)"
var title = "Peserta MCU"
option := Piechart{
Title: struct {
Text string `json:"text"`
Left string `json:"left"`
Text string `json:"text"`
SubText string `json:"subtext"`
Left string `json:"left"`
}{
Text: title,
Left: "center",
Text: title,
SubText: "Total Peserta 506",
Left: "center",
},
Tooltip: struct {
Trigger string `json:"trigger"`
@@ -202,6 +205,11 @@ func GetPieChartMcu001(code string, id int) (string, Piechart, error) {
Top: "bottom",
Left: "center",
Orient: "vertical",
// KALAU BERTABRAKAN DGN ATASNYA SETTING PAKE DIBAWAH INI
// Top: "bottom",
// Left: "center",
// Orient: "horizontal",
},
Series: []Series{
{
@@ -252,17 +260,17 @@ func GetPieChartMcu001(code string, id int) (string, Piechart, error) {
}
// Kepersertaan MCU Berdasarkan Jenis Kelamin -- MCU002
// Status Index Masa Tubuh (BMI) -- MCU006
func GetPieChartMcu006(code string, id int) (string, Piechart, error) {
var title = "Status Index Masa Tubuh (BMI)"
func GetPieChartMcu002(code string, id int) (string, Piechart, error) {
var title = "Kepesertaan MCU"
option := Piechart{
Title: struct {
Text string `json:"text"`
Left string `json:"left"`
Text string `json:"text"`
SubText string `json:"subtext"`
Left string `json:"left"`
}{
Text: title,
Left: "center",
Text: title,
SubText: "Berdasarkan Jenis Kelamin",
Left: "center",
},
Tooltip: struct {
Trigger string `json:"trigger"`
@@ -277,6 +285,173 @@ func GetPieChartMcu006(code string, id int) (string, Piechart, error) {
Top: "bottom",
Left: "center",
Orient: "vertical",
// KALAU BERTABRAKAN DGN ATASNYA SETTING PAKE DIBAWAH INI
// Top: "bottom",
// Left: "center",
// Orient: "horizontal",
},
Series: []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: []SeriesData{
{Value: 143, Name: "Laki-laki : 143 Peserta"},
{Value: 114, Name: "Perempuan : 114 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)",
},
},
},
},
}
return title, option, nil
}
// Peserta MCU berdasarkan umur
func GetPieChartMcu003(code string, id int) (string, Piechart, error) {
var title = "Peserta MCU"
option := Piechart{
Title: struct {
Text string `json:"text"`
SubText string `json:"subtext"`
Left string `json:"left"`
}{
Text: title,
SubText: "Berdasarkan Umur",
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",
// KALAU BERTABRAKAN DGN ATASNYA SETTING PAKE DIBAWAH INI
// Top: "bottom",
// Left: "center",
// Orient: "horizontal",
},
Series: []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: []SeriesData{
{Value: 188, Name: "< 30 Tahun : 188 Peserta"},
{Value: 194, Name: "30 - < 40 Tahun : 194 Peserta"},
{Value: 123, Name: "40 - < 50 Tahun : 123 Peserta"},
{Value: 55, Name: "≥ 50 Tahun : 55 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)",
},
},
},
},
}
return title, option, nil
}
// Status Index Masa Tubuh (BMI) -- MCU006
func GetPieChartMcu006(code string, id int) (string, Piechart, error) {
var title = "Status Index Masa Tubuh (BMI)"
option := Piechart{
Title: struct {
Text string `json:"text"`
SubText string `json:"subtext"`
Left string `json:"left"`
}{
Text: title,
SubText: "",
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",
// KALAU BERTABRAKAN DGN ATASNYA SETTING PAKE DIBAWAH INI
// Top: "bottom",
// Left: "center",
// Orient: "horizontal",
},
Series: []Series{
{
@@ -329,14 +504,196 @@ func GetPieChartMcu006(code string, id int) (string, Piechart, error) {
return title, option, nil
}
// Kriteria Hipertensi -- MCU007
func GetPieChartMcu007(code string, id int) (string, Piechart, error) {
var title = "Kriteria Hipertensi"
option := Piechart{
Title: struct {
Text string `json:"text"`
SubText string `json:"subtext"`
Left string `json:"left"`
}{
Text: title,
SubText: "",
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",
// KALAU BERTABRAKAN DGN ATASNYA SETTING PAKE DIBAWAH INI
// Top: "bottom",
// Left: "center",
// Orient: "horizontal",
},
Series: []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: []SeriesData{
{Value: 237, Name: "Normal : 237 Peserta"},
{Value: 215, Name: "Prehipertensi : 215 Peserta"},
{Value: 66, Name: "Hipertensi Grade I : 66 Peserta"},
{Value: 33, Name: "Hipertensi Grade II : 33 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)",
},
},
},
},
}
return title, option, nil
}
// Visus Jauh -- MCU008
func GetPieChartMcu008(code string, id int) (string, Piechart, error) {
var title = "Visus Jauh"
option := Piechart{
Title: struct {
Text string `json:"text"`
SubText string `json:"subtext"`
Left string `json:"left"`
}{
Text: title,
SubText: "",
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",
// KALAU BERTABRAKAN DGN ATASNYA SETTING PAKE DIBAWAH INI
// Top: "bottom",
// Left: "center",
// Orient: "horizontal",
},
Series: []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: []SeriesData{
{Value: 237, Name: "Normal : 237 Peserta"},
{Value: 194, Name: "Kelainan Refraksi : 194 Peserta"},
{Value: 64, Name: "Kelainan Refraksi terkoreksi : 64 Peserta"},
{Value: 56, Name: "Kelainan Refraksi tidak terkoreksi : 56 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)",
},
},
},
},
}
return title, option, nil
}
func (su *ServicesPiechart) GetPieChart(code string, id int) (string, Piechart, error) {
if code == "mcu001" {
return GetPieChartMcu001(code, id)
}
if code == "mcu002" {
return GetPieChartMcu002(code, id)
}
if code == "mcu003" {
return GetPieChartMcu003(code, id)
}
if code == "mcu006" {
return GetPieChartMcu006(code, id)
}
if code == "mcu007" {
return GetPieChartMcu007(code, id)
}
if code == "mcu008" {
return GetPieChartMcu008(code, id)
}
return "", Piechart{}, fmt.Errorf("code " + code + " not found")
}