feat: support bar chart

This commit is contained in:
vicanso 2022-02-01 11:19:31 +08:00
parent 3a9897f9ad
commit 6ae7e1d1b3
5 changed files with 112 additions and 8 deletions

View file

@ -27,12 +27,8 @@ import (
"github.com/wcharczuk/go-chart/v2/drawing"
)
type LineChartOption struct {
ChartOption
}
func NewLineChart(opt LineChartOption) (*Draw, error) {
result, err := chartBasicRender(&opt.ChartOption)
func LineChartRender(opt ChartOption) (*Draw, error) {
result, err := chartBasicRender(&opt)
if err != nil {
return nil, err
}
@ -54,7 +50,7 @@ func NewLineChart(opt LineChartOption) (*Draw, error) {
for i, series := range opt.SeriesList {
points := make([]Point, 0)
for j, item := range series.Data {
y := yRange.getHeight(item.Value)
y := yRange.getRestHeight(item.Value)
points = append(points, Point{
Y: y,
X: xRange.getWidth(float64(j)),