feat: support split line show option for charts, #69
This commit is contained in:
parent
c7c0655113
commit
f1a231ff4b
13 changed files with 23 additions and 21 deletions
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
|
|
@ -14,6 +14,8 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go:
|
go:
|
||||||
|
- '1.22'
|
||||||
|
- '1.21'
|
||||||
- '1.20'
|
- '1.20'
|
||||||
- '1.19'
|
- '1.19'
|
||||||
- '1.18'
|
- '1.18'
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
|
@ -16,7 +15,7 @@ func writeFile(buf []byte) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
file := filepath.Join(tmpPath, "area-line-chart.png")
|
file := filepath.Join(tmpPath, "area-line-chart.png")
|
||||||
err = ioutil.WriteFile(file, buf, 0600)
|
err = os.WriteFile(file, buf, 0600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
|
@ -16,7 +15,7 @@ func writeFile(buf []byte) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
file := filepath.Join(tmpPath, "bar-chart.png")
|
file := filepath.Join(tmpPath, "bar-chart.png")
|
||||||
err = ioutil.WriteFile(file, buf, 0600)
|
err = os.WriteFile(file, buf, 0600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ func writeFile(buf []byte) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
file := filepath.Join(tmpPath, "chinese-line-chart.png")
|
file := filepath.Join(tmpPath, "chinese-line-chart.png")
|
||||||
err = ioutil.WriteFile(file, buf, 0600)
|
err = os.WriteFile(file, buf, 0600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
|
@ -16,7 +15,7 @@ func writeFile(buf []byte) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
file := filepath.Join(tmpPath, "funnel-chart.png")
|
file := filepath.Join(tmpPath, "funnel-chart.png")
|
||||||
err = ioutil.WriteFile(file, buf, 0600)
|
err = os.WriteFile(file, buf, 0600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
|
@ -16,7 +15,7 @@ func writeFile(buf []byte) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
file := filepath.Join(tmpPath, "horizontal-bar-chart.png")
|
file := filepath.Join(tmpPath, "horizontal-bar-chart.png")
|
||||||
err = ioutil.WriteFile(file, buf, 0600)
|
err = os.WriteFile(file, buf, 0600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
|
@ -17,7 +16,7 @@ func writeFile(buf []byte) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
file := filepath.Join(tmpPath, "line-chart.png")
|
file := filepath.Join(tmpPath, "line-chart.png")
|
||||||
err = ioutil.WriteFile(file, buf, 0600)
|
err = os.WriteFile(file, buf, 0600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -97,6 +96,11 @@ func main() {
|
||||||
Top: 5,
|
Top: 5,
|
||||||
Bottom: 10,
|
Bottom: 10,
|
||||||
}
|
}
|
||||||
|
opt.YAxisOptions = []charts.YAxisOption{
|
||||||
|
{
|
||||||
|
SplitLineShow: charts.FalseFlag(),
|
||||||
|
},
|
||||||
|
}
|
||||||
opt.SymbolShow = charts.FalseFlag()
|
opt.SymbolShow = charts.FalseFlag()
|
||||||
opt.LineStrokeWidth = 1
|
opt.LineStrokeWidth = 1
|
||||||
opt.ValueFormatter = func(f float64) string {
|
opt.ValueFormatter = func(f float64) string {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
|
@ -17,7 +16,7 @@ func writeFile(buf []byte) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
file := filepath.Join(tmpPath, "painter.png")
|
file := filepath.Join(tmpPath, "painter.png")
|
||||||
err = ioutil.WriteFile(file, buf, 0600)
|
err = os.WriteFile(file, buf, 0600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
|
@ -16,7 +15,7 @@ func writeFile(buf []byte) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
file := filepath.Join(tmpPath, "pie-chart.png")
|
file := filepath.Join(tmpPath, "pie-chart.png")
|
||||||
err = ioutil.WriteFile(file, buf, 0600)
|
err = os.WriteFile(file, buf, 0600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
|
@ -16,7 +15,7 @@ func writeFile(buf []byte) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
file := filepath.Join(tmpPath, "radar-chart.png")
|
file := filepath.Join(tmpPath, "radar-chart.png")
|
||||||
err = ioutil.WriteFile(file, buf, 0600)
|
err = os.WriteFile(file, buf, 0600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
@ -19,7 +18,7 @@ func writeFile(buf []byte, filename string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
file := filepath.Join(tmpPath, filename)
|
file := filepath.Join(tmpPath, filename)
|
||||||
err = ioutil.WriteFile(file, buf, 0600)
|
err = os.WriteFile(file, buf, 0600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ package main
|
||||||
import (
|
import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"math/big"
|
"math/big"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -20,7 +19,7 @@ func writeFile(buf []byte) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
file := filepath.Join(tmpPath, "time-line-chart.png")
|
file := filepath.Join(tmpPath, "time-line-chart.png")
|
||||||
err = ioutil.WriteFile(file, buf, 0600)
|
err = os.WriteFile(file, buf, 0600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
5
yaxis.go
5
yaxis.go
|
|
@ -50,6 +50,8 @@ type YAxisOption struct {
|
||||||
DivideCount int
|
DivideCount int
|
||||||
Unit int
|
Unit int
|
||||||
isCategoryAxis bool
|
isCategoryAxis bool
|
||||||
|
// The flag for show axis split line, set this to true will show axis split line
|
||||||
|
SplitLineShow *bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewYAxisOptions returns a y axis option
|
// NewYAxisOptions returns a y axis option
|
||||||
|
|
@ -100,6 +102,9 @@ func (opt *YAxisOption) ToAxisOption(p *Painter) AxisOption {
|
||||||
axisOpt.StrokeWidth = 1
|
axisOpt.StrokeWidth = 1
|
||||||
axisOpt.SplitLineShow = false
|
axisOpt.SplitLineShow = false
|
||||||
}
|
}
|
||||||
|
if opt.SplitLineShow != nil {
|
||||||
|
axisOpt.SplitLineShow = *opt.SplitLineShow
|
||||||
|
}
|
||||||
return axisOpt
|
return axisOpt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue