Skip to content

Commit

Permalink
update fill
Browse files Browse the repository at this point in the history
  • Loading branch information
kevincobain2000 committed Jan 14, 2024
1 parent d1bfd77 commit 00525a7
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@

## `GET /line`

| Query | Required | Type | Default |
| :----- | :------- | :------ | :------ |
| `fill` | | boolean | `false` |
| Query | Required | Type | Default | Description |
| :----- | :------- | :----- | :------ | :----------------- |
| `line` | | string | `fill` | `fill` or `nofill` |


| `data` | Required | Type |
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/mcuadros/go-defaults v1.2.0
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.8.4
github.com/vicanso/go-charts/v2 v2.6.1
github.com/vicanso/go-charts/v2 v2.6.3
github.com/wcharczuk/go-chart/v2 v2.1.1
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyC
github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
github.com/vicanso/go-charts/v2 v2.6.1 h1:xWODVa4KtzkZrbUNd6WQunqGyFWXgaUeeXMQkFm9RuE=
github.com/vicanso/go-charts/v2 v2.6.1/go.mod h1:Ii2KDI3udTG1wPtiTnntzjlUBJVJTqNscMzh3oYHzUk=
github.com/vicanso/go-charts/v2 v2.6.3 h1:AP+zVZw27nt7kjxY5js70M3YfroDRCodrpdqW/Gdxh4=
github.com/vicanso/go-charts/v2 v2.6.3/go.mod h1:Ii2KDI3udTG1wPtiTnntzjlUBJVJTqNscMzh3oYHzUk=
github.com/wcharczuk/go-chart/v2 v2.1.1 h1:2u7na789qiD5WzccZsFz4MJWOJP72G+2kUuJoSNqWnE=
github.com/wcharczuk/go-chart/v2 v2.1.1/go.mod h1:CyCAUt2oqvfhCl6Q5ZvAZwItgpQKZOkCJGb+VGv6l14=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
Expand Down
2 changes: 1 addition & 1 deletion pkg/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type ChartRequest struct {
Width int `json:"width" query:"width" form:"width" default:"1024"`
Height int `json:"height" query:"height" form:"height" default:"768"`
Style string `json:"style" query:"style" form:"style" default:"vertical"`
Fill bool `json:"fill" query:"fill" form:"fill" default:"false"`
Line string `json:"line" query:"line" default:"nofill" validate:"oneof=nofill fill" message:"line must be fill"`
Output string `json:"output" query:"output" form:"output" default:"png"`
}

Expand Down
6 changes: 5 additions & 1 deletion pkg/line_chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ func NewLineChart() *LineChart {
}

func (c *LineChart) Get(xData []string, yData [][]float64, names []string, req *ChartRequest) ([]byte, error) {
fill := false
if req.Line == "fill" {
fill = true
}
p, err := charts.LineRender(
yData,
charts.HeightOptionFunc(req.Height),
Expand Down Expand Up @@ -44,7 +48,7 @@ func (c *LineChart) Get(xData []string, yData [][]float64, names []string, req *
opt.ValueFormatter = func(f float64) string {
return fmt.Sprintf("%s %s", NumberToK(&f), req.Metric)
}
opt.FillArea = req.Fill
opt.FillArea = fill

idx := len(opt.SeriesList) - 1
if len(opt.SeriesList) > 1 {
Expand Down

0 comments on commit 00525a7

Please sign in to comment.