Skip to content
This repository has been archived by the owner on Sep 27, 2022. It is now read-only.

Commit

Permalink
Merge pull request #4 from spiegel-im-spiegel/update-chart-subpackage
Browse files Browse the repository at this point in the history
Update chart subpackage
  • Loading branch information
spiegel-im-spiegel authored May 29, 2021
2 parents 031cb23 + 81f8480 commit e0f6677
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 22 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@

# Other files and directories
work/
dist/
.task/
*.bak
50 changes: 50 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
version: '3'

tasks:
default:
cmds:
- task: clean
- task: test
- task: nancy
- task: graph

build-all:
desc: Build executable binary with GoReleaser.
cmds:
- goreleaser --snapshot --skip-publish --rm-dist

test:
desc: Test and lint.
cmds:
- go mod verify
- go test ./...
- docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.40.1 golangci-lint run --enable gosec --timeout 3m0s ./...
sources:
- ./go.mod
- '**/*.go'

nancy:
desc: Check vulnerability of external packages with Nancy.
cmds:
- depm list -j | docker run --rm -i sonatypecommunity/nancy:latest sleuth -n
sources:
- ./go.mod
- '**/*.go'

clean:
desc: Initialize module and build cache, and remake go.sum file.
cmds:
- rm -f ./go.sum
- go clean -cache
- go clean -modcache
- go mod tidy -v

graph:
desc: Make grapth of dependency modules.
cmds:
- depm m --dot --dot-config dot-config.toml | dot -Tpng -o ./dependency.png
sources:
- ./go.mod
- '**/*.go'
generates:
- ./dependency.png
22 changes: 11 additions & 11 deletions chart/bar-chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func MakeHistChart(list *HistList, title, outPath string) error {
labelX := []string{}
dataY1 := plotter.Values{}
dataY2 := plotter.Values{}
// dataY3 := plotter.XYs{}
dataY3 := plotter.XYs{}
maxCases := 0.0
for i := 0; i < list.Size(); i++ {
d := list.Data(i)
Expand All @@ -25,8 +25,8 @@ func MakeHistChart(list *HistList, title, outPath string) error {
maxCases = max(maxCases, d.Cases)
dataY2 = append(dataY2, math.Floor(d.Deaths))
maxCases = max(maxCases, d.Deaths)
// dataY3 = append(dataY3, plotter.XY{X: (float64)(i), Y: math.Floor(d.Hospitalized)})
// maxCases = max(maxCases, d.Hospitalized)
dataY3 = append(dataY3, plotter.XY{X: (float64)(i), Y: math.Floor(d.Hospitalized)})
maxCases = max(maxCases, d.Hospitalized)
}
maxCases = maxCases * 5 / 3
maxCases = (float64)((((int)(maxCases) / 50) + 1) * 50)
Expand Down Expand Up @@ -63,14 +63,14 @@ func MakeHistChart(list *HistList, title, outPath string) error {
bar2.Horizontal = false
p.Add(bar2)

// //new line chart
// line1, err := plotter.NewLine(dataY3)
// if err != nil {
// return errs.Wrap(err, errs.WithContext("outPath", outPath))
// }
//new line chart
line1, err := plotter.NewLine(dataY3)
if err != nil {
return errs.Wrap(err, errs.WithContext("outPath", outPath))
}

// line1.Color = plotutil.Color(4)
// p.Add(line1)
line1.Color = plotutil.Color(4)
p.Add(line1)

//labels of X
p.NominalX(labelX...)
Expand All @@ -89,7 +89,7 @@ func MakeHistChart(list *HistList, title, outPath string) error {
//legend
p.Legend.Add("New Cases", bar1)
p.Legend.Add("New Deaths", bar2)
// p.Legend.Add("Hospitalized", line1)
p.Legend.Add("Hospitalized", line1)
p.Legend.Top = true //top
p.Legend.Left = true //left
p.Legend.XOffs = 0
Expand Down
4 changes: 0 additions & 4 deletions clean-all.sh

This file was deleted.

7 changes: 0 additions & 7 deletions test-all.sh

This file was deleted.

0 comments on commit e0f6677

Please sign in to comment.