Compare commits
7 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 958172a1f1 | |||
| 0eacc8e394 | |||
|
|
d25a827706 | ||
|
|
5842c71b1d | ||
|
|
e7dc4189d5 | ||
|
|
32e6dd52d0 | ||
|
|
9614835723 |
43 changed files with 138 additions and 99 deletions
18
README.md
18
README.md
|
|
@ -1,5 +1,7 @@
|
|||
# go-charts
|
||||
|
||||
Clone from https://github.com/vicanso/go-charts
|
||||
|
||||
[](https://github.com/vicanso/go-charts/blob/master/LICENSE)
|
||||
[](https://github.com/vicanso/go-charts/actions)
|
||||
|
||||
|
|
@ -33,7 +35,7 @@ More examples can be found in the [./examples/](./examples/) directory.
|
|||
package main
|
||||
|
||||
import (
|
||||
charts "github.com/vicanso/go-charts/v2"
|
||||
charts "git.smarteching.com/zeni/go-charts/v2"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
@ -99,7 +101,7 @@ func main() {
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/vicanso/go-charts/v2"
|
||||
"git.smarteching.com/zeni/go-charts/v2"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
@ -174,7 +176,7 @@ func main() {
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/vicanso/go-charts/v2"
|
||||
"git.smarteching.com/zeni/go-charts/v2"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
@ -231,7 +233,7 @@ func main() {
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/vicanso/go-charts/v2"
|
||||
"git.smarteching.com/zeni/go-charts/v2"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
@ -286,7 +288,7 @@ func main() {
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/vicanso/go-charts/v2"
|
||||
"git.smarteching.com/zeni/go-charts/v2"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
@ -344,7 +346,7 @@ func main() {
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/vicanso/go-charts/v2"
|
||||
"git.smarteching.com/zeni/go-charts/v2"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
@ -384,7 +386,7 @@ func main() {
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/vicanso/go-charts/v2"
|
||||
"git.smarteching.com/zeni/go-charts/v2"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
@ -449,7 +451,7 @@ func main() {
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/vicanso/go-charts/v2"
|
||||
"git.smarteching.com/zeni/go-charts/v2"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
|
|||
16
README_zh.md
16
README_zh.md
|
|
@ -32,7 +32,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
charts "github.com/vicanso/go-charts/v2"
|
||||
charts "git.smarteching.com/zeni/go-charts/v2"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
@ -98,7 +98,7 @@ func main() {
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/vicanso/go-charts/v2"
|
||||
"git.smarteching.com/zeni/go-charts/v2"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
@ -173,7 +173,7 @@ func main() {
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/vicanso/go-charts/v2"
|
||||
"git.smarteching.com/zeni/go-charts/v2"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
@ -230,7 +230,7 @@ func main() {
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/vicanso/go-charts/v2"
|
||||
"git.smarteching.com/zeni/go-charts/v2"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
@ -285,7 +285,7 @@ func main() {
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/vicanso/go-charts/v2"
|
||||
"git.smarteching.com/zeni/go-charts/v2"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
@ -343,7 +343,7 @@ func main() {
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/vicanso/go-charts/v2"
|
||||
"git.smarteching.com/zeni/go-charts/v2"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
@ -383,7 +383,7 @@ func main() {
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/vicanso/go-charts/v2"
|
||||
"git.smarteching.com/zeni/go-charts/v2"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
@ -447,7 +447,7 @@ func main() {
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/vicanso/go-charts/v2"
|
||||
"git.smarteching.com/zeni/go-charts/v2"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
|
|||
4
alias.go
4
alias.go
|
|
@ -23,8 +23,8 @@
|
|||
package charts
|
||||
|
||||
import (
|
||||
"github.com/wcharczuk/go-chart/v2"
|
||||
"github.com/wcharczuk/go-chart/v2/drawing"
|
||||
"git.smarteching.com/zeni/go-chart/v2"
|
||||
"git.smarteching.com/zeni/go-chart/v2/drawing"
|
||||
)
|
||||
|
||||
type Box = chart.Box
|
||||
|
|
|
|||
2
axis.go
2
axis.go
|
|
@ -26,7 +26,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/golang/freetype/truetype"
|
||||
"github.com/wcharczuk/go-chart/v2"
|
||||
"git.smarteching.com/zeni/go-chart/v2"
|
||||
)
|
||||
|
||||
type axisPainter struct {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/wcharczuk/go-chart/v2/drawing"
|
||||
"git.smarteching.com/zeni/go-chart/v2/drawing"
|
||||
)
|
||||
|
||||
func TestAxis(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import (
|
|||
"math"
|
||||
|
||||
"github.com/golang/freetype/truetype"
|
||||
"github.com/wcharczuk/go-chart/v2"
|
||||
"git.smarteching.com/zeni/go-chart/v2"
|
||||
)
|
||||
|
||||
type barChart struct {
|
||||
|
|
@ -63,6 +63,8 @@ type BarChartOption struct {
|
|||
// The legend option
|
||||
Legend LegendOption
|
||||
BarWidth int
|
||||
// Margin of bar
|
||||
BarMargin int
|
||||
}
|
||||
|
||||
func (b *barChart) render(result *defaultRenderResult, seriesList SeriesList) (Box, error) {
|
||||
|
|
@ -88,6 +90,9 @@ func (b *barChart) render(result *defaultRenderResult, seriesList SeriesList) (B
|
|||
margin = 5
|
||||
barMargin = 3
|
||||
}
|
||||
if opt.BarMargin > 0 {
|
||||
barMargin = opt.BarMargin
|
||||
}
|
||||
seriesCount := len(seriesList)
|
||||
// 总的宽度-两个margin-(总数-1)的barMargin
|
||||
barWidth := (width - 2*margin - barMargin*(seriesCount-1)) / seriesCount
|
||||
|
|
|
|||
|
|
@ -67,6 +67,8 @@ type ChartOption struct {
|
|||
LineStrokeWidth float64
|
||||
// The bar with of bar chart
|
||||
BarWidth int
|
||||
// The margin of each bar
|
||||
BarMargin int
|
||||
// The bar height of horizontal bar chart
|
||||
BarHeight int
|
||||
// Fill the area of line chart
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/wcharczuk/go-chart/v2/drawing"
|
||||
"git.smarteching.com/zeni/go-chart/v2/drawing"
|
||||
)
|
||||
|
||||
func TestChartOption(t *testing.T) {
|
||||
|
|
|
|||
12
charts.go
12
charts.go
|
|
@ -27,7 +27,7 @@ import (
|
|||
"math"
|
||||
"sort"
|
||||
|
||||
"github.com/wcharczuk/go-chart/v2"
|
||||
"git.smarteching.com/zeni/go-chart/v2"
|
||||
)
|
||||
|
||||
const labelFontSize = 10
|
||||
|
|
@ -375,10 +375,11 @@ func Render(opt ChartOption, opts ...OptionFunc) (*Painter, error) {
|
|||
if len(barSeriesList) != 0 {
|
||||
handler.Add(func() error {
|
||||
_, err := NewBarChart(p, BarChartOption{
|
||||
Theme: opt.theme,
|
||||
Font: opt.font,
|
||||
XAxis: opt.XAxis,
|
||||
BarWidth: opt.BarWidth,
|
||||
Theme: opt.theme,
|
||||
Font: opt.font,
|
||||
XAxis: opt.XAxis,
|
||||
BarWidth: opt.BarWidth,
|
||||
BarMargin: opt.BarMargin,
|
||||
}).render(renderResult, barSeriesList)
|
||||
return err
|
||||
})
|
||||
|
|
@ -391,6 +392,7 @@ func Render(opt ChartOption, opts ...OptionFunc) (*Painter, error) {
|
|||
Theme: opt.theme,
|
||||
Font: opt.font,
|
||||
BarHeight: opt.BarHeight,
|
||||
BarMargin: opt.BarMargin,
|
||||
YAxisOptions: opt.YAxisOptions,
|
||||
}).render(renderResult, horizontalBarSeriesList)
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import (
|
|||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/wcharczuk/go-chart/v2"
|
||||
"git.smarteching.com/zeni/go-chart/v2"
|
||||
)
|
||||
|
||||
func BenchmarkMultiChartPNGRender(b *testing.B) {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import (
|
|||
"regexp"
|
||||
"strconv"
|
||||
|
||||
"github.com/wcharczuk/go-chart/v2"
|
||||
"git.smarteching.com/zeni/go-chart/v2"
|
||||
)
|
||||
|
||||
func convertToArray(data []byte) []byte {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/wcharczuk/go-chart/v2/drawing"
|
||||
"git.smarteching.com/zeni/go-chart/v2/drawing"
|
||||
)
|
||||
|
||||
func TestConvertToArray(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/vicanso/go-charts/v2"
|
||||
"git.smarteching.com/zeni/go-charts/v2"
|
||||
)
|
||||
|
||||
func writeFile(buf []byte) error {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/vicanso/go-charts/v2"
|
||||
"git.smarteching.com/zeni/go-charts/v2"
|
||||
)
|
||||
|
||||
func writeFile(buf []byte) error {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import (
|
|||
"net/http"
|
||||
"strconv"
|
||||
|
||||
charts "github.com/vicanso/go-charts/v2"
|
||||
charts "git.smarteching.com/zeni/go-charts/v2"
|
||||
)
|
||||
|
||||
var html = `<!DOCTYPE html>
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/vicanso/go-charts/v2"
|
||||
"git.smarteching.com/zeni/go-charts/v2"
|
||||
)
|
||||
|
||||
func writeFile(buf []byte) error {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/vicanso/go-charts/v2"
|
||||
"git.smarteching.com/zeni/go-charts/v2"
|
||||
)
|
||||
|
||||
func writeFile(buf []byte) error {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/vicanso/go-charts/v2"
|
||||
"git.smarteching.com/zeni/go-charts/v2"
|
||||
)
|
||||
|
||||
func writeFile(buf []byte) error {
|
||||
|
|
@ -65,6 +65,9 @@ func main() {
|
|||
"China",
|
||||
"World",
|
||||
}),
|
||||
func(opt *charts.ChartOption) {
|
||||
opt.SeriesList[0].RoundRadius = 5
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/vicanso/go-charts/v2"
|
||||
"git.smarteching.com/zeni/go-charts/v2"
|
||||
)
|
||||
|
||||
func writeFile(buf []byte) error {
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
|
||||
charts "github.com/vicanso/go-charts/v2"
|
||||
"github.com/wcharczuk/go-chart/v2/drawing"
|
||||
charts "git.smarteching.com/zeni/go-charts/v2"
|
||||
"git.smarteching.com/zeni/go-chart/v2/drawing"
|
||||
)
|
||||
|
||||
func writeFile(buf []byte) error {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/vicanso/go-charts/v2"
|
||||
"git.smarteching.com/zeni/go-charts/v2"
|
||||
)
|
||||
|
||||
func writeFile(buf []byte) error {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/vicanso/go-charts/v2"
|
||||
"git.smarteching.com/zeni/go-charts/v2"
|
||||
)
|
||||
|
||||
func writeFile(buf []byte) error {
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/vicanso/go-charts/v2"
|
||||
"github.com/wcharczuk/go-chart/v2/drawing"
|
||||
"git.smarteching.com/zeni/go-charts/v2"
|
||||
"git.smarteching.com/zeni/go-chart/v2/drawing"
|
||||
)
|
||||
|
||||
func writeFile(buf []byte, filename string) error {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import (
|
|||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/vicanso/go-charts/v2"
|
||||
"git.smarteching.com/zeni/go-charts/v2"
|
||||
)
|
||||
|
||||
func writeFile(buf []byte) error {
|
||||
|
|
|
|||
2
font.go
2
font.go
|
|
@ -27,7 +27,7 @@ import (
|
|||
"sync"
|
||||
|
||||
"github.com/golang/freetype/truetype"
|
||||
"github.com/wcharczuk/go-chart/v2/roboto"
|
||||
"git.smarteching.com/zeni/go-chart/v2/roboto"
|
||||
)
|
||||
|
||||
var fonts = sync.Map{}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/wcharczuk/go-chart/v2/roboto"
|
||||
"git.smarteching.com/zeni/go-chart/v2/roboto"
|
||||
)
|
||||
|
||||
func TestInstallFont(t *testing.T) {
|
||||
|
|
|
|||
10
go.mod
10
go.mod
|
|
@ -1,17 +1,17 @@
|
|||
module github.com/vicanso/go-charts/v2
|
||||
module git.smarteching.com/zeni/go-charts/v2
|
||||
|
||||
go 1.17
|
||||
go 1.24.1
|
||||
|
||||
require (
|
||||
git.smarteching.com/zeni/go-chart/v2 v2.1.4
|
||||
github.com/dustin/go-humanize v1.0.1
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
|
||||
github.com/stretchr/testify v1.8.2
|
||||
github.com/wcharczuk/go-chart/v2 v2.1.0
|
||||
github.com/stretchr/testify v1.10.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
golang.org/x/image v0.0.0-20200927104501-e162460cd6b5 // indirect
|
||||
golang.org/x/image v0.21.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
|
|
|||
20
go.sum
20
go.sum
|
|
@ -1,4 +1,5 @@
|
|||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
git.smarteching.com/zeni/go-chart/v2 v2.1.4 h1:pF06+F6eqJLIG8uMiTVPR5TygPGMjM/FHMzTxmu5V/Q=
|
||||
git.smarteching.com/zeni/go-chart/v2 v2.1.4/go.mod h1:b3ueW9h3pGGXyhkormZAvilHaG4+mQti+bMNPdQBeOQ=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||
|
|
@ -7,20 +8,11 @@ github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF0
|
|||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
|
||||
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/wcharczuk/go-chart/v2 v2.1.0 h1:tY2slqVQ6bN+yHSnDYwZebLQFkphK4WNrVwnt7CJZ2I=
|
||||
github.com/wcharczuk/go-chart/v2 v2.1.0/go.mod h1:yx7MvAVNcP/kN9lKXM/NTce4au4DFN99j6i1OwDclNA=
|
||||
golang.org/x/image v0.0.0-20200927104501-e162460cd6b5 h1:QelT11PB4FXiDEXucrfNckHoFxwt8USGY1ajP1ZF5lM=
|
||||
golang.org/x/image v0.0.0-20200927104501-e162460cd6b5/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
golang.org/x/image v0.21.0 h1:c5qV36ajHpdj4Qi0GnE0jUc/yuo33OLFaa0d+crTD5s=
|
||||
golang.org/x/image v0.21.0/go.mod h1:vUbsLavqK/W303ZroQQVKQ+Af3Yl6Uz1Ppu5J/cLz78=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/wcharczuk/go-chart/v2/drawing"
|
||||
"git.smarteching.com/zeni/go-chart/v2/drawing"
|
||||
)
|
||||
|
||||
func TestGrid(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ package charts
|
|||
|
||||
import (
|
||||
"github.com/golang/freetype/truetype"
|
||||
"github.com/wcharczuk/go-chart/v2"
|
||||
"git.smarteching.com/zeni/go-chart/v2"
|
||||
)
|
||||
|
||||
type horizontalBarChart struct {
|
||||
|
|
@ -50,6 +50,8 @@ type HorizontalBarChartOption struct {
|
|||
// The legend option
|
||||
Legend LegendOption
|
||||
BarHeight int
|
||||
// Margin of bar
|
||||
BarMargin int
|
||||
}
|
||||
|
||||
// NewHorizontalBarChart returns a horizontal bar chart renderer
|
||||
|
|
@ -81,6 +83,9 @@ func (h *horizontalBarChart) render(result *defaultRenderResult, seriesList Seri
|
|||
margin = 5
|
||||
barMargin = 3
|
||||
}
|
||||
if opt.BarMargin > 0 {
|
||||
barMargin = opt.BarMargin
|
||||
}
|
||||
seriesCount := len(seriesList)
|
||||
// 总的高度-两个margin-(总数-1)的barMargin
|
||||
barHeight := (height - 2*margin - barMargin*(seriesCount-1)) / seriesCount
|
||||
|
|
@ -136,14 +141,26 @@ func (h *horizontalBarChart) render(result *defaultRenderResult, seriesList Seri
|
|||
fillColor = item.Style.FillColor
|
||||
}
|
||||
right := w
|
||||
seriesPainter.OverrideDrawingStyle(Style{
|
||||
FillColor: fillColor,
|
||||
}).Rect(chart.Box{
|
||||
Top: y,
|
||||
Left: 0,
|
||||
Right: right,
|
||||
Bottom: y + barHeight,
|
||||
})
|
||||
if series.RoundRadius <= 0 {
|
||||
seriesPainter.OverrideDrawingStyle(Style{
|
||||
FillColor: fillColor,
|
||||
}).Rect(chart.Box{
|
||||
Top: y,
|
||||
Left: 0,
|
||||
Right: right,
|
||||
Bottom: y + barHeight,
|
||||
})
|
||||
} else {
|
||||
seriesPainter.OverrideDrawingStyle(Style{
|
||||
FillColor: fillColor,
|
||||
}).RoundedRect(chart.Box{
|
||||
Top: y,
|
||||
Left: 0,
|
||||
Right: right,
|
||||
Bottom: y + barHeight,
|
||||
}, series.RoundRadius)
|
||||
}
|
||||
|
||||
// 如果label不需要展示,则返回
|
||||
if labelPainter == nil {
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import (
|
|||
"math"
|
||||
|
||||
"github.com/golang/freetype/truetype"
|
||||
"github.com/wcharczuk/go-chart/v2/drawing"
|
||||
"git.smarteching.com/zeni/go-chart/v2/drawing"
|
||||
)
|
||||
|
||||
type lineChart struct {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/wcharczuk/go-chart/v2/drawing"
|
||||
"git.smarteching.com/zeni/go-chart/v2/drawing"
|
||||
)
|
||||
|
||||
func TestMarkLine(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/wcharczuk/go-chart/v2/drawing"
|
||||
"git.smarteching.com/zeni/go-chart/v2/drawing"
|
||||
)
|
||||
|
||||
func TestMarkPoint(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import (
|
|||
"math"
|
||||
|
||||
"github.com/golang/freetype/truetype"
|
||||
"github.com/wcharczuk/go-chart/v2"
|
||||
"git.smarteching.com/zeni/go-chart/v2"
|
||||
)
|
||||
|
||||
type ValueFormatter func(float64) string
|
||||
|
|
@ -860,3 +860,7 @@ func (p *Painter) LegendLineDot(box Box) *Painter {
|
|||
p.FillStroke()
|
||||
return p
|
||||
}
|
||||
|
||||
func (p *Painter) GetRenderer() chart.Renderer {
|
||||
return p.render
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ import (
|
|||
|
||||
"github.com/golang/freetype/truetype"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/wcharczuk/go-chart/v2"
|
||||
"github.com/wcharczuk/go-chart/v2/drawing"
|
||||
"git.smarteching.com/zeni/go-chart/v2"
|
||||
"git.smarteching.com/zeni/go-chart/v2/drawing"
|
||||
)
|
||||
|
||||
func TestPainterOption(t *testing.T) {
|
||||
|
|
|
|||
26
pie_chart.go
26
pie_chart.go
|
|
@ -27,7 +27,7 @@ import (
|
|||
"math"
|
||||
|
||||
"github.com/golang/freetype/truetype"
|
||||
"github.com/wcharczuk/go-chart/v2"
|
||||
"git.smarteching.com/zeni/go-chart/v2"
|
||||
)
|
||||
|
||||
type pieChart struct {
|
||||
|
|
@ -234,23 +234,35 @@ func (p *pieChart) render(result *defaultRenderResult, seriesList SeriesList) (B
|
|||
continue
|
||||
}
|
||||
if currentQuadrant != s.quadrant {
|
||||
currentQuadrant = s.quadrant
|
||||
if s.quadrant == 1 {
|
||||
minY = cy * 2
|
||||
maxY = 0
|
||||
prevY = cy * 2
|
||||
}
|
||||
if s.quadrant == 2 {
|
||||
prevY = minY
|
||||
if currentQuadrant != 3 {
|
||||
prevY = s.lineEndY
|
||||
} else {
|
||||
prevY = minY
|
||||
}
|
||||
}
|
||||
if s.quadrant == 3 {
|
||||
minY = cy * 2
|
||||
maxY = 0
|
||||
prevY = 0
|
||||
if currentQuadrant != 4 {
|
||||
prevY = s.lineEndY
|
||||
} else {
|
||||
minY = cy * 2
|
||||
maxY = 0
|
||||
prevY = 0
|
||||
}
|
||||
}
|
||||
if s.quadrant == 4 {
|
||||
prevY = maxY
|
||||
if currentQuadrant != 1 {
|
||||
prevY = s.lineEndY
|
||||
} else {
|
||||
prevY = maxY
|
||||
}
|
||||
}
|
||||
currentQuadrant = s.quadrant
|
||||
}
|
||||
prevY = s.calculateY(prevY)
|
||||
if prevY > maxY {
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ import (
|
|||
|
||||
"github.com/dustin/go-humanize"
|
||||
"github.com/golang/freetype/truetype"
|
||||
"github.com/wcharczuk/go-chart/v2"
|
||||
"github.com/wcharczuk/go-chart/v2/drawing"
|
||||
"git.smarteching.com/zeni/go-chart/v2"
|
||||
"git.smarteching.com/zeni/go-chart/v2/drawing"
|
||||
)
|
||||
|
||||
type radarChart struct {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/dustin/go-humanize"
|
||||
"github.com/wcharczuk/go-chart/v2"
|
||||
"git.smarteching.com/zeni/go-chart/v2"
|
||||
)
|
||||
|
||||
type SeriesData struct {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ package charts
|
|||
|
||||
import (
|
||||
"github.com/golang/freetype/truetype"
|
||||
"github.com/wcharczuk/go-chart/v2"
|
||||
"git.smarteching.com/zeni/go-chart/v2"
|
||||
)
|
||||
|
||||
type labelRenderValue struct {
|
||||
|
|
|
|||
4
table.go
4
table.go
|
|
@ -26,8 +26,8 @@ import (
|
|||
"errors"
|
||||
|
||||
"github.com/golang/freetype/truetype"
|
||||
"github.com/wcharczuk/go-chart/v2"
|
||||
"github.com/wcharczuk/go-chart/v2/drawing"
|
||||
"git.smarteching.com/zeni/go-chart/v2"
|
||||
"git.smarteching.com/zeni/go-chart/v2/drawing"
|
||||
)
|
||||
|
||||
type tableChart struct {
|
||||
|
|
|
|||
2
theme.go
2
theme.go
|
|
@ -24,7 +24,7 @@ package charts
|
|||
|
||||
import (
|
||||
"github.com/golang/freetype/truetype"
|
||||
"github.com/wcharczuk/go-chart/v2/drawing"
|
||||
"git.smarteching.com/zeni/go-chart/v2/drawing"
|
||||
)
|
||||
|
||||
const ThemeDark = "dark"
|
||||
|
|
|
|||
4
util.go
4
util.go
|
|
@ -29,8 +29,8 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/dustin/go-humanize"
|
||||
"github.com/wcharczuk/go-chart/v2"
|
||||
"github.com/wcharczuk/go-chart/v2/drawing"
|
||||
"git.smarteching.com/zeni/go-chart/v2"
|
||||
"git.smarteching.com/zeni/go-chart/v2/drawing"
|
||||
)
|
||||
|
||||
func TrueFlag() *bool {
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/wcharczuk/go-chart/v2"
|
||||
"github.com/wcharczuk/go-chart/v2/drawing"
|
||||
"git.smarteching.com/zeni/go-chart/v2"
|
||||
"git.smarteching.com/zeni/go-chart/v2/drawing"
|
||||
)
|
||||
|
||||
func TestGetDefaultInt(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue