edit graphic bar title, order, color
This commit is contained in:
@@ -103,18 +103,22 @@ func (tkf *TabKelainanFisikServices) GetBarChartConf(title string, data models.B
|
||||
option := models.Barchart{}
|
||||
option.Title = struct {
|
||||
Text string "json:\"text\""
|
||||
}{title}
|
||||
Left string `json:"left"`
|
||||
}{
|
||||
Text: title,
|
||||
Left: "center",
|
||||
}
|
||||
option.Dataset = data
|
||||
option.Grid.ContainLabel = true
|
||||
option.XAxis.Name = "amount"
|
||||
option.XAxis.Name = "person"
|
||||
option.YAxis.Type = "category"
|
||||
option.VisualMap.Orient = "horizontal"
|
||||
option.VisualMap.Left = "center"
|
||||
option.VisualMap.Min = 10
|
||||
option.VisualMap.Max = 100
|
||||
option.VisualMap.Min = 0
|
||||
option.VisualMap.Max = 10
|
||||
option.VisualMap.Show = false
|
||||
option.VisualMap.Dimension = 0
|
||||
option.VisualMap.InRange.Color = []string{"#42aaf5", "#00eaf2", "#035bff"}
|
||||
option.VisualMap.InRange.Color = []string{"#035bff", "#42aaf5", "#00eaf2"}
|
||||
option.Series = []struct {
|
||||
Label struct {
|
||||
Position string "json:\"position\""
|
||||
|
||||
@@ -30,18 +30,22 @@ func (tkg *TabKelainanGlobalServices) GetBarChartConf(title string, data models.
|
||||
option := models.Barchart{}
|
||||
option.Title = struct {
|
||||
Text string "json:\"text\""
|
||||
}{title}
|
||||
Left string `json:"left"`
|
||||
}{
|
||||
Text: title,
|
||||
Left: "center",
|
||||
}
|
||||
option.Dataset = data
|
||||
option.Grid.ContainLabel = true
|
||||
option.XAxis.Name = "amount"
|
||||
option.XAxis.Name = "person"
|
||||
option.YAxis.Type = "category"
|
||||
option.VisualMap.Orient = "horizontal"
|
||||
option.VisualMap.Left = "center"
|
||||
option.VisualMap.Min = 10
|
||||
option.VisualMap.Max = 100
|
||||
option.VisualMap.Min = 0
|
||||
option.VisualMap.Max = 10
|
||||
option.VisualMap.Show = false
|
||||
option.VisualMap.Dimension = 0
|
||||
option.VisualMap.InRange.Color = []string{"#42aaf5", "#00eaf2", "#035bff"}
|
||||
option.VisualMap.InRange.Color = []string{"#035bff", "#42aaf5", "#00eaf2"}
|
||||
option.Series = []struct {
|
||||
Label struct {
|
||||
Position string "json:\"position\""
|
||||
@@ -154,12 +158,12 @@ func (tkg *TabKelainanGlobalServices) GetKelainanGlobalMCU(mcuID string) (models
|
||||
}
|
||||
}
|
||||
|
||||
for _, d := range data {
|
||||
for i, d := range data {
|
||||
percentage := float64(d.Total) / float64(max) * 100
|
||||
roundedPercentage := math.Round(percentage*100) / 100
|
||||
percentStr := strconv.FormatFloat(roundedPercentage, 'f', -1, 64)
|
||||
chartData.Source = append(chartData.Source, []interface{}{
|
||||
d.Total, d.Total, d.Test, percentStr,
|
||||
i, d.Total, d.Test, percentStr,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -302,12 +306,12 @@ func (tkg *TabKelainanGlobalServices) GetKelainanGlobalV2(mcuID string) (models.
|
||||
},
|
||||
}
|
||||
|
||||
for _, d := range data {
|
||||
for i, d := range data {
|
||||
percentage := float64(d.Total) / float64(jumlahPeserta.Peserta) * 100
|
||||
roundedPercentage := math.Round(percentage*100) / 100
|
||||
percentStr := strconv.FormatFloat(roundedPercentage, 'f', -1, 64)
|
||||
chartData.Source = append(chartData.Source, []interface{}{
|
||||
d.Mcu_KelainanID, d.Total, d.Test, percentStr,
|
||||
i, d.Total, d.Test, percentStr,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -30,18 +30,22 @@ func (tkl *TabKelainanLabServices) ConfBarchart(title string, data models.BarDat
|
||||
option := models.Barchart{}
|
||||
option.Title = struct {
|
||||
Text string "json:\"text\""
|
||||
}{title}
|
||||
Left string `json:"left"`
|
||||
}{
|
||||
Text: title,
|
||||
Left: "center",
|
||||
}
|
||||
option.Dataset = data
|
||||
option.Grid.ContainLabel = true
|
||||
option.XAxis.Name = "amount"
|
||||
option.XAxis.Name = "person"
|
||||
option.YAxis.Type = "category"
|
||||
option.VisualMap.Orient = "horizontal"
|
||||
option.VisualMap.Left = "center"
|
||||
option.VisualMap.Min = 1
|
||||
option.VisualMap.Max = 100
|
||||
option.VisualMap.Min = 0
|
||||
option.VisualMap.Max = 10
|
||||
option.VisualMap.Show = false
|
||||
option.VisualMap.Dimension = 0
|
||||
option.VisualMap.InRange.Color = []string{"#42aaf5", "#00eaf2", "#035bff"}
|
||||
option.VisualMap.InRange.Color = []string{"#035bff", "#42aaf5", "#00eaf2"}
|
||||
option.Series = []struct {
|
||||
Label struct {
|
||||
Position string "json:\"position\""
|
||||
@@ -136,7 +140,11 @@ func (tkl *TabKelainanLabServices) ConfBarchartVertical(title string, data []mod
|
||||
option := models.BarchartV2{
|
||||
Title: struct {
|
||||
Text string "json:\"text\""
|
||||
}{title},
|
||||
Left string `json:"left"`
|
||||
}{
|
||||
Text: title,
|
||||
Left: "center",
|
||||
},
|
||||
Dataset: struct {
|
||||
Source [][]interface{} "json:\"source\""
|
||||
}{chartData.Source},
|
||||
@@ -198,7 +206,7 @@ func (tkl *TabKelainanLabServices) ConfBarchartVertical(title string, data []mod
|
||||
InRange: struct {
|
||||
Color []string "json:\"color\""
|
||||
}{
|
||||
Color: []string{"#42aaf5", "#00eaf2", "#035bff"},
|
||||
Color: []string{"#035bff", "#42aaf5", "#00eaf2"},
|
||||
},
|
||||
},
|
||||
Series: []struct {
|
||||
@@ -324,12 +332,12 @@ func (tkl *TabKelainanLabServices) GetDataPresentaseKelainanLab(mcuID string) (m
|
||||
return option, fmt.Errorf("error get jumlah peserta %v", err)
|
||||
}
|
||||
|
||||
for _, d := range data {
|
||||
for i, d := range data {
|
||||
percentage := float64(d.Total) / float64(jumlahPeserta.Peserta) * 100
|
||||
roundedPercentage := math.Round(percentage*100) / 100
|
||||
percentStr := strconv.FormatFloat(roundedPercentage, 'f', -1, 64)
|
||||
chartData.Source = append(chartData.Source, []interface{}{
|
||||
d.Mcu_KelainanID, d.Total, d.Mcu_KelainanName, percentStr,
|
||||
i, d.Total, d.Mcu_KelainanName, percentStr,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -30,18 +30,22 @@ func (tknl *TabKelainanNonLabServices) GetBarChartConf(title string, data models
|
||||
option := models.Barchart{}
|
||||
option.Title = struct {
|
||||
Text string "json:\"text\""
|
||||
}{title}
|
||||
Left string `json:"left"`
|
||||
}{
|
||||
Text: title,
|
||||
Left: "center",
|
||||
}
|
||||
option.Dataset = data
|
||||
option.Grid.ContainLabel = true
|
||||
option.XAxis.Name = "amount"
|
||||
option.XAxis.Name = "person"
|
||||
option.YAxis.Type = "category"
|
||||
option.VisualMap.Orient = "horizontal"
|
||||
option.VisualMap.Left = "center"
|
||||
option.VisualMap.Min = 1
|
||||
option.VisualMap.Max = 100
|
||||
option.VisualMap.Min = 0
|
||||
option.VisualMap.Max = 4
|
||||
option.VisualMap.Show = false
|
||||
option.VisualMap.Dimension = 0
|
||||
option.VisualMap.InRange.Color = []string{"#42aaf5", "#00eaf2", "#035bff"}
|
||||
option.VisualMap.InRange.Color = []string{"#035bff", "#42aaf5", "#00eaf2"}
|
||||
option.Series = []struct {
|
||||
Label struct {
|
||||
Position string "json:\"position\""
|
||||
@@ -143,7 +147,11 @@ func (tknl *TabKelainanNonLabServices) ConfBarchartVertical(title string, data [
|
||||
option := models.BarchartV2{
|
||||
Title: struct {
|
||||
Text string "json:\"text\""
|
||||
}{title},
|
||||
Left string `json:"left"`
|
||||
}{
|
||||
Text: title,
|
||||
Left: "center",
|
||||
},
|
||||
Dataset: struct {
|
||||
Source [][]interface{} "json:\"source\""
|
||||
}{chartData.Source},
|
||||
@@ -205,7 +213,7 @@ func (tknl *TabKelainanNonLabServices) ConfBarchartVertical(title string, data [
|
||||
InRange: struct {
|
||||
Color []string "json:\"color\""
|
||||
}{
|
||||
Color: []string{"#42aaf5", "#00eaf2", "#035bff"},
|
||||
Color: []string{"#035bff", "#42aaf5", "#00eaf2"},
|
||||
},
|
||||
},
|
||||
Series: []struct {
|
||||
@@ -331,12 +339,12 @@ func (tknl *TabKelainanNonLabServices) GetDataKelNonLab(mcuID string) (models.Ba
|
||||
return option, fmt.Errorf("error get jumlah peserta %v", err)
|
||||
}
|
||||
|
||||
for _, d := range data {
|
||||
for i, d := range data {
|
||||
percentage := float64(d.Total) / float64(jumlahPeserta.Peserta) * 100
|
||||
roundedPercentage := math.Round(percentage*100) / 100
|
||||
percentStr := strconv.FormatFloat(roundedPercentage, 'f', -1, 64)
|
||||
chartData.Source = append(chartData.Source, []interface{}{
|
||||
d.Mcu_KelainanID, d.Total, d.Test, percentStr,
|
||||
i, d.Total, d.Test, percentStr,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user