feat: support echart options

This commit is contained in:
vicanso 2022-02-16 22:51:02 +08:00
parent b934b853a9
commit 519c8a492e
8 changed files with 803 additions and 2 deletions

View file

@ -27,6 +27,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/wcharczuk/go-chart/v2"
"github.com/wcharczuk/go-chart/v2/drawing"
)
func TestGetDefaultInt(t *testing.T) {
@ -139,3 +140,42 @@ func TestConvertPercent(t *testing.T) {
assert.Equal(-1.0, convertPercent("a%"))
assert.Equal(0.1, convertPercent("10%"))
}
func TestParseColor(t *testing.T) {
assert := assert.New(t)
c := parseColor("")
assert.True(c.IsZero())
c = parseColor("#333")
assert.Equal(drawing.Color{
R: 51,
G: 51,
B: 51,
A: 255,
}, c)
c = parseColor("#313233")
assert.Equal(drawing.Color{
R: 49,
G: 50,
B: 51,
A: 255,
}, c)
c = parseColor("rgb(31,32,33)")
assert.Equal(drawing.Color{
R: 31,
G: 32,
B: 33,
A: 255,
}, c)
c = parseColor("rgba(50,51,52,250)")
assert.Equal(drawing.Color{
R: 50,
G: 51,
B: 52,
A: 250,
}, c)
}