Skip to content

Commit

Permalink
- add optional style arg to plot
Browse files Browse the repository at this point in the history
  • Loading branch information
rocketlaunchr-cto committed Apr 13, 2020
1 parent a28754a commit 79dad91
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions plot/wcharczuk/go-chart/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ import (
// Currently x can be nil, a SeriesFloat64 or a SeriesTime. nil values in the x and y Series are ignored.
//
// NOTE: To "unjoin" the lines, you can adjust the style to chart.Style{StrokeWidth: chart.Disabled, DotWidth: 2}.
func S(ctx context.Context, y *dataframe.SeriesFloat64, x interface{}, r ...dataframe.Range) (chart.Series, error) {
func S(ctx context.Context, y *dataframe.SeriesFloat64, x interface{}, r *dataframe.Range, style ...chart.Style) (chart.Series, error) {

var out chart.Series

if len(r) == 0 {
r = append(r, dataframe.Range{})
if r == nil {
r = &dataframe.Range{}
}

yNRows := y.NRows(dataframe.DontLock)

start, end, err := r[0].Limits(yNRows)
start, end, err := r.Limits(yNRows)
if err != nil {
return nil, err
}
Expand All @@ -34,6 +34,10 @@ func S(ctx context.Context, y *dataframe.SeriesFloat64, x interface{}, r ...data
case nil:
cs := chart.ContinuousSeries{Name: y.Name(dataframe.DontLock)}

if len(style) > 0 {
cs.Style = style[0]
}

xVals := []float64{}
yVals := []float64{}

Expand All @@ -60,6 +64,10 @@ func S(ctx context.Context, y *dataframe.SeriesFloat64, x interface{}, r ...data

cs := chart.ContinuousSeries{Name: y.Name(dataframe.DontLock)}

if len(style) > 0 {
cs.Style = style[0]
}

xVals := []float64{}
yVals := []float64{}

Expand Down Expand Up @@ -90,6 +98,10 @@ func S(ctx context.Context, y *dataframe.SeriesFloat64, x interface{}, r ...data

cs := chart.TimeSeries{Name: y.Name(dataframe.DontLock)}

if len(style) > 0 {
cs.Style = style[0]
}

xVals := []time.Time{}
yVals := []float64{}

Expand Down

0 comments on commit 79dad91

Please sign in to comment.