From 02d5f2e39eea9e5beaf6d9e32114db1dbcd8c605 Mon Sep 17 00:00:00 2001 From: adibwp Date: Wed, 7 Aug 2024 16:56:25 +0700 Subject: [PATCH] add label data tidak ditemukan --- models/chart.models.go | 20 +++++++ .../mcudetail/tabkelainanfisik.services.go | 34 ++++++++++- .../mcudetail/tabkelainanglobal.services.go | 28 +++++++++ .../mcudetail/tabkelainanlab.services.go | 58 ++++++++++++++++++- .../mcudetail/tabkelainannonlab.services.go | 56 ++++++++++++++++++ 5 files changed, 191 insertions(+), 5 deletions(-) diff --git a/models/chart.models.go b/models/chart.models.go index 8c7cc87..c29eb1c 100644 --- a/models/chart.models.go +++ b/models/chart.models.go @@ -91,6 +91,16 @@ type Barchart struct { Type string `json:"type"` } `json:"axisPointer"` } `json:"tooltip"` + Graphic struct { + Type string `json:"type"` + Left string `json:"left"` + Top string `json:"top"` + Style struct { + Text string `json:"text"` + FontSize string `json:"fontSize"` + FontWeight string `json:"fontWeight"` + } `json:"style"` + } `json:"graphic"` } type BarDataset struct { @@ -152,4 +162,14 @@ type BarchartV2 struct { Type string `json:"type"` } `json:"axisPointer"` } `json:"tooltip"` + Graphic struct { + Type string `json:"type"` + Left string `json:"left"` + Top string `json:"top"` + Style struct { + Text string `json:"text"` + FontSize string `json:"fontSize"` + FontWeight string `json:"fontWeight"` + } `json:"style"` + } `json:"graphic"` } diff --git a/services/corporate/mcudetail/tabkelainanfisik.services.go b/services/corporate/mcudetail/tabkelainanfisik.services.go index 2740dd9..bf7bf3c 100644 --- a/services/corporate/mcudetail/tabkelainanfisik.services.go +++ b/services/corporate/mcudetail/tabkelainanfisik.services.go @@ -95,6 +95,11 @@ func (tkf *TabKelainanFisikServices) GetPieChartConf(title string, subtext strin } func (tkf *TabKelainanFisikServices) GetBarChartConf(title string, data models.BarDataset) (models.Barchart, error) { + isEmpty := "" + if len(data.Source) <= 1 { + isEmpty = "Data tidak ditemukan" + } + option := models.Barchart{} option.Title = struct { Text string "json:\"text\"" @@ -155,6 +160,29 @@ func (tkf *TabKelainanFisikServices) GetBarChartConf(title string, data models.B Type: "shadow", }, } + option.Graphic = struct { + Type string "json:\"type\"" + Left string "json:\"left\"" + Top string "json:\"top\"" + Style struct { + Text string "json:\"text\"" + FontSize string "json:\"fontSize\"" + FontWeight string "json:\"fontWeight\"" + } "json:\"style\"" + }{ + Type: "text", + Left: "center", + Top: "middle", + Style: struct { + Text string "json:\"text\"" + FontSize string "json:\"fontSize\"" + FontWeight string "json:\"fontWeight\"" + }{ + Text: isEmpty, + FontSize: "15", + FontWeight: "bold", + }, + } return option, nil } @@ -242,7 +270,7 @@ func (tkf *TabKelainanFisikServices) GetKelainanFisikBMI(mcuID string) (models.P UNION SELECT 'Normal' as test, 'asia_pacific' as Mcu_KelainanClasification, - count(distinct T_OrderHeaderID) - summary_total_kelainan_bmi(?) as total + ifnull(count(distinct T_OrderHeaderID) - summary_total_kelainan_bmi(?), 0) as total FROM t_orderheader WHERE T_OrderHeaderMgm_McuID = ? AND T_OrderHeaderIsActive = 'Y' @@ -300,7 +328,7 @@ func (tkf *TabKelainanFisikServices) GetKelainanFisikHipertensi(mcuID string) (m UNION SELECT 'Normal' as test, 'JNC-VII' as Mcu_KelainanClasification, - COUNT(T_OrderHeaderID) - summary_total_kelainan_hipertensi(?) as total + IFNULL(COUNT(T_OrderHeaderID) - summary_total_kelainan_hipertensi(?), 0) as total FROM t_orderheader WHERE T_OrderHeaderMgm_McuID = ? AND T_OrderHeaderIsActive = 'Y' @@ -355,7 +383,7 @@ func (tkf *TabKelainanFisikServices) GetKelainanFisikRefraksi(mcuID string) (mod group by Mcu_KelainanID UNION SELECT 'Normal' as test, - count(distinct T_OrderHeaderID) - summary_total_kelainan_visus(?) as total + IFNULL(count(distinct T_OrderHeaderID) - summary_total_kelainan_visus(?), 0) as total FROM t_orderheader WHERE T_OrderHeaderMgm_McuID = ? AND T_OrderHeaderIsActive = 'Y' diff --git a/services/corporate/mcudetail/tabkelainanglobal.services.go b/services/corporate/mcudetail/tabkelainanglobal.services.go index a42a69b..67cea8d 100644 --- a/services/corporate/mcudetail/tabkelainanglobal.services.go +++ b/services/corporate/mcudetail/tabkelainanglobal.services.go @@ -22,6 +22,11 @@ func NewTabKelainanGlobalServices(store db.AppStore) *TabKelainanGlobalServices } func (tkg *TabKelainanGlobalServices) GetBarChartConf(title string, data models.BarDataset) (models.Barchart, error) { + isEmpty := "" + if len(data.Source) <= 1 { + isEmpty = "Data tidak ditemukan" + } + option := models.Barchart{} option.Title = struct { Text string "json:\"text\"" @@ -82,6 +87,29 @@ func (tkg *TabKelainanGlobalServices) GetBarChartConf(title string, data models. Type: "shadow", }, } + option.Graphic = struct { + Type string "json:\"type\"" + Left string "json:\"left\"" + Top string "json:\"top\"" + Style struct { + Text string "json:\"text\"" + FontSize string "json:\"fontSize\"" + FontWeight string "json:\"fontWeight\"" + } "json:\"style\"" + }{ + Type: "text", + Left: "center", + Top: "middle", + Style: struct { + Text string "json:\"text\"" + FontSize string "json:\"fontSize\"" + FontWeight string "json:\"fontWeight\"" + }{ + Text: isEmpty, + FontSize: "15", + FontWeight: "bold", + }, + } return option, nil } diff --git a/services/corporate/mcudetail/tabkelainanlab.services.go b/services/corporate/mcudetail/tabkelainanlab.services.go index 34ea5ba..3ea8a93 100644 --- a/services/corporate/mcudetail/tabkelainanlab.services.go +++ b/services/corporate/mcudetail/tabkelainanlab.services.go @@ -22,8 +22,12 @@ func NewTabKelainanLabServices(store db.AppStore) *TabKelainanLabServices { } func (tkl *TabKelainanLabServices) ConfBarchart(title string, data models.BarDataset) (models.Barchart, error) { - option := models.Barchart{} + isEmpty := "" + if len(data.Source) <= 1 { + isEmpty = "Data tidak ditemukan" + } + option := models.Barchart{} option.Title = struct { Text string "json:\"text\"" }{title} @@ -83,18 +87,45 @@ func (tkl *TabKelainanLabServices) ConfBarchart(title string, data models.BarDat Type: "shadow", }, } + option.Graphic = struct { + Type string "json:\"type\"" + Left string "json:\"left\"" + Top string "json:\"top\"" + Style struct { + Text string "json:\"text\"" + FontSize string "json:\"fontSize\"" + FontWeight string "json:\"fontWeight\"" + } "json:\"style\"" + }{ + Type: "text", + Left: "center", + Top: "middle", + Style: struct { + Text string "json:\"text\"" + FontSize string "json:\"fontSize\"" + FontWeight string "json:\"fontWeight\"" + }{ + Text: isEmpty, + FontSize: "15", + FontWeight: "bold", + }, + } return option, nil } func (tkl *TabKelainanLabServices) ConfBarchartVertical(title string, data []models.KelainanLabModel) (models.BarchartV2, error) { - chartData := models.BarDataset{ Source: [][]interface{}{ {"score", "amount", "product"}, }, } + isEmpty := "" + if len(data) == 0 { + isEmpty = "Data tidak ditemukan" + } + cnt := len(data) for idx, d := range data { chartData.Source = append(chartData.Source, []interface{}{ @@ -215,6 +246,29 @@ func (tkl *TabKelainanLabServices) ConfBarchartVertical(title string, data []mod Type: "shadow", }, }, + Graphic: struct { + Type string "json:\"type\"" + Left string "json:\"left\"" + Top string "json:\"top\"" + Style struct { + Text string "json:\"text\"" + FontSize string "json:\"fontSize\"" + FontWeight string "json:\"fontWeight\"" + } "json:\"style\"" + }{ + Type: "text", + Left: "center", + Top: "middle", + Style: struct { + Text string "json:\"text\"" + FontSize string "json:\"fontSize\"" + FontWeight string "json:\"fontWeight\"" + }{ + Text: isEmpty, + FontSize: "15", + FontWeight: "bold", + }, + }, } return option, nil diff --git a/services/corporate/mcudetail/tabkelainannonlab.services.go b/services/corporate/mcudetail/tabkelainannonlab.services.go index 6bbff62..34f739c 100644 --- a/services/corporate/mcudetail/tabkelainannonlab.services.go +++ b/services/corporate/mcudetail/tabkelainannonlab.services.go @@ -22,6 +22,11 @@ func NewTabKelainanNonLabServices(store db.AppStore) *TabKelainanNonLabServices } func (tknl *TabKelainanNonLabServices) GetBarChartConf(title string, data models.BarDataset) (models.Barchart, error) { + isEmpty := "" + if len(data.Source) <= 1 { + isEmpty = "Data tidak ditemukan" + } + option := models.Barchart{} option.Title = struct { Text string "json:\"text\"" @@ -82,6 +87,29 @@ func (tknl *TabKelainanNonLabServices) GetBarChartConf(title string, data models Type: "shadow", }, } + option.Graphic = struct { + Type string "json:\"type\"" + Left string "json:\"left\"" + Top string "json:\"top\"" + Style struct { + Text string "json:\"text\"" + FontSize string "json:\"fontSize\"" + FontWeight string "json:\"fontWeight\"" + } "json:\"style\"" + }{ + Type: "text", + Left: "center", + Top: "middle", + Style: struct { + Text string "json:\"text\"" + FontSize string "json:\"fontSize\"" + FontWeight string "json:\"fontWeight\"" + }{ + Text: isEmpty, + FontSize: "15", + FontWeight: "bold", + }, + } return option, nil } @@ -93,6 +121,11 @@ func (tknl *TabKelainanNonLabServices) ConfBarchartVertical(title string, data [ }, } + isEmpty := "" + if len(data) == 0 { + isEmpty = "Data tidak ditemukan" + } + cnt := len(data) for idx, d := range data { if len(d.Test) > 30 { @@ -220,6 +253,29 @@ func (tknl *TabKelainanNonLabServices) ConfBarchartVertical(title string, data [ Type: "shadow", }, }, + Graphic: struct { + Type string "json:\"type\"" + Left string "json:\"left\"" + Top string "json:\"top\"" + Style struct { + Text string "json:\"text\"" + FontSize string "json:\"fontSize\"" + FontWeight string "json:\"fontWeight\"" + } "json:\"style\"" + }{ + Type: "text", + Left: "center", + Top: "middle", + Style: struct { + Text string "json:\"text\"" + FontSize string "json:\"fontSize\"" + FontWeight string "json:\"fontWeight\"" + }{ + Text: isEmpty, + FontSize: "15", + FontWeight: "bold", + }, + }, } return option, nil