refactor: update examples
This commit is contained in:
parent
2316689ce5
commit
1258262f2c
4 changed files with 65 additions and 54 deletions
38
README.md
38
README.md
|
|
@ -49,22 +49,8 @@ func writeFile(file string, buf []byte) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func chartsRender() ([]byte, error) {
|
func chartsRender() ([]byte, error) {
|
||||||
d, err := charts.Render(charts.ChartOption{
|
d, err := charts.LineRender([][]float64{
|
||||||
Type: charts.ChartOutputPNG,
|
{
|
||||||
Title: charts.TitleOption{
|
|
||||||
Text: "Line",
|
|
||||||
},
|
|
||||||
XAxis: charts.NewXAxisOption([]string{
|
|
||||||
"Mon",
|
|
||||||
"Tue",
|
|
||||||
"Wed",
|
|
||||||
"Thu",
|
|
||||||
"Fri",
|
|
||||||
"Sat",
|
|
||||||
"Sun",
|
|
||||||
}),
|
|
||||||
SeriesList: charts.SeriesList{
|
|
||||||
charts.NewSeriesFromValues([]float64{
|
|
||||||
150,
|
150,
|
||||||
230,
|
230,
|
||||||
224,
|
224,
|
||||||
|
|
@ -72,9 +58,25 @@ func chartsRender() ([]byte, error) {
|
||||||
135,
|
135,
|
||||||
147,
|
147,
|
||||||
260,
|
260,
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
})
|
},
|
||||||
|
// output type
|
||||||
|
charts.PNGTypeOption(),
|
||||||
|
// title
|
||||||
|
charts.TitleOptionFunc(charts.TitleOption{
|
||||||
|
Text: "Line",
|
||||||
|
}),
|
||||||
|
// x axis
|
||||||
|
charts.XAxisOptionFunc(charts.NewXAxisOption([]string{
|
||||||
|
"Mon",
|
||||||
|
"Tue",
|
||||||
|
"Wed",
|
||||||
|
"Thu",
|
||||||
|
"Fri",
|
||||||
|
"Sat",
|
||||||
|
"Sun",
|
||||||
|
})),
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
38
README_zh.md
38
README_zh.md
|
|
@ -49,22 +49,8 @@ func writeFile(file string, buf []byte) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func chartsRender() ([]byte, error) {
|
func chartsRender() ([]byte, error) {
|
||||||
d, err := charts.Render(charts.ChartOption{
|
d, err := charts.LineRender([][]float64{
|
||||||
Type: charts.ChartOutputPNG,
|
{
|
||||||
Title: charts.TitleOption{
|
|
||||||
Text: "Line",
|
|
||||||
},
|
|
||||||
XAxis: charts.NewXAxisOption([]string{
|
|
||||||
"Mon",
|
|
||||||
"Tue",
|
|
||||||
"Wed",
|
|
||||||
"Thu",
|
|
||||||
"Fri",
|
|
||||||
"Sat",
|
|
||||||
"Sun",
|
|
||||||
}),
|
|
||||||
SeriesList: charts.SeriesList{
|
|
||||||
charts.NewSeriesFromValues([]float64{
|
|
||||||
150,
|
150,
|
||||||
230,
|
230,
|
||||||
224,
|
224,
|
||||||
|
|
@ -72,9 +58,25 @@ func chartsRender() ([]byte, error) {
|
||||||
135,
|
135,
|
||||||
147,
|
147,
|
||||||
260,
|
260,
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
})
|
},
|
||||||
|
// output type
|
||||||
|
charts.PNGTypeOption(),
|
||||||
|
// title
|
||||||
|
charts.TitleOptionFunc(charts.TitleOption{
|
||||||
|
Text: "Line",
|
||||||
|
}),
|
||||||
|
// x axis
|
||||||
|
charts.XAxisOptionFunc(charts.NewXAxisOption([]string{
|
||||||
|
"Mon",
|
||||||
|
"Tue",
|
||||||
|
"Wed",
|
||||||
|
"Thu",
|
||||||
|
"Fri",
|
||||||
|
"Sat",
|
||||||
|
"Sun",
|
||||||
|
})),
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,11 @@ import (
|
||||||
// OptionFunc option function
|
// OptionFunc option function
|
||||||
type OptionFunc func(opt *ChartOption)
|
type OptionFunc func(opt *ChartOption)
|
||||||
|
|
||||||
|
// PNGTypeOption set png type of chart's output
|
||||||
|
func PNGTypeOption() OptionFunc {
|
||||||
|
return TypeOptionFunc(ChartOutputPNG)
|
||||||
|
}
|
||||||
|
|
||||||
// TypeOptionFunc set type of chart's output
|
// TypeOptionFunc set type of chart's output
|
||||||
func TypeOptionFunc(t string) OptionFunc {
|
func TypeOptionFunc(t string) OptionFunc {
|
||||||
return func(opt *ChartOption) {
|
return func(opt *ChartOption) {
|
||||||
|
|
|
||||||
|
|
@ -24,22 +24,8 @@ func writeFile(file string, buf []byte) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func chartsRender() ([]byte, error) {
|
func chartsRender() ([]byte, error) {
|
||||||
d, err := charts.Render(charts.ChartOption{
|
d, err := charts.LineRender([][]float64{
|
||||||
Type: charts.ChartOutputPNG,
|
{
|
||||||
Title: charts.TitleOption{
|
|
||||||
Text: "Line",
|
|
||||||
},
|
|
||||||
XAxis: charts.NewXAxisOption([]string{
|
|
||||||
"Mon",
|
|
||||||
"Tue",
|
|
||||||
"Wed",
|
|
||||||
"Thu",
|
|
||||||
"Fri",
|
|
||||||
"Sat",
|
|
||||||
"Sun",
|
|
||||||
}),
|
|
||||||
SeriesList: charts.SeriesList{
|
|
||||||
charts.NewSeriesFromValues([]float64{
|
|
||||||
150,
|
150,
|
||||||
230,
|
230,
|
||||||
224,
|
224,
|
||||||
|
|
@ -47,9 +33,25 @@ func chartsRender() ([]byte, error) {
|
||||||
135,
|
135,
|
||||||
147,
|
147,
|
||||||
260,
|
260,
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
})
|
},
|
||||||
|
// output type
|
||||||
|
charts.PNGTypeOption(),
|
||||||
|
// title
|
||||||
|
charts.TitleOptionFunc(charts.TitleOption{
|
||||||
|
Text: "Line",
|
||||||
|
}),
|
||||||
|
// x axis
|
||||||
|
charts.XAxisOptionFunc(charts.NewXAxisOption([]string{
|
||||||
|
"Mon",
|
||||||
|
"Tue",
|
||||||
|
"Wed",
|
||||||
|
"Thu",
|
||||||
|
"Fri",
|
||||||
|
"Sat",
|
||||||
|
"Sun",
|
||||||
|
})),
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue