feat: support stroke width of line chart
This commit is contained in:
parent
817fceff73
commit
e530adccb6
4 changed files with 15 additions and 5 deletions
|
|
@ -64,6 +64,8 @@ type ChartOption struct {
|
||||||
BackgroundColor Color
|
BackgroundColor Color
|
||||||
// The flag for show symbol of line, set this to *false will hide symbol
|
// The flag for show symbol of line, set this to *false will hide symbol
|
||||||
SymbolShow *bool
|
SymbolShow *bool
|
||||||
|
// The stroke width of line chart
|
||||||
|
LineStrokeWidth float64
|
||||||
// The child charts
|
// The child charts
|
||||||
Children []ChartOption
|
Children []ChartOption
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -377,10 +377,11 @@ func Render(opt ChartOption, opts ...OptionFunc) (*Painter, error) {
|
||||||
if len(lineSeriesList) != 0 {
|
if len(lineSeriesList) != 0 {
|
||||||
handler.Add(func() error {
|
handler.Add(func() error {
|
||||||
_, err := NewLineChart(p, LineChartOption{
|
_, err := NewLineChart(p, LineChartOption{
|
||||||
Theme: opt.theme,
|
Theme: opt.theme,
|
||||||
Font: opt.font,
|
Font: opt.font,
|
||||||
XAxis: opt.XAxis,
|
XAxis: opt.XAxis,
|
||||||
SymbolShow: opt.SymbolShow,
|
SymbolShow: opt.SymbolShow,
|
||||||
|
StrokeWidth: opt.LineStrokeWidth,
|
||||||
}).render(renderResult, lineSeriesList)
|
}).render(renderResult, lineSeriesList)
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,7 @@ func main() {
|
||||||
Bottom: 10,
|
Bottom: 10,
|
||||||
}
|
}
|
||||||
opt.SymbolShow = charts.FalseFlag()
|
opt.SymbolShow = charts.FalseFlag()
|
||||||
|
opt.LineStrokeWidth = 1
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,8 @@ type LineChartOption struct {
|
||||||
Legend LegendOption
|
Legend LegendOption
|
||||||
// The flag for show symbol of line, set this to *false will hide symbol
|
// The flag for show symbol of line, set this to *false will hide symbol
|
||||||
SymbolShow *bool
|
SymbolShow *bool
|
||||||
|
// The stroke width of line
|
||||||
|
StrokeWidth float64
|
||||||
// background is filled
|
// background is filled
|
||||||
backgroundIsFilled bool
|
backgroundIsFilled bool
|
||||||
}
|
}
|
||||||
|
|
@ -95,12 +97,16 @@ func (l *lineChart) render(result *defaultRenderResult, seriesList SeriesList) (
|
||||||
markPointPainter,
|
markPointPainter,
|
||||||
markLinePainter,
|
markLinePainter,
|
||||||
}
|
}
|
||||||
|
strokeWidth := opt.StrokeWidth
|
||||||
|
if strokeWidth == 0 {
|
||||||
|
strokeWidth = defaultStrokeWidth
|
||||||
|
}
|
||||||
for index := range seriesList {
|
for index := range seriesList {
|
||||||
series := seriesList[index]
|
series := seriesList[index]
|
||||||
seriesColor := opt.Theme.GetSeriesColor(series.index)
|
seriesColor := opt.Theme.GetSeriesColor(series.index)
|
||||||
drawingStyle := Style{
|
drawingStyle := Style{
|
||||||
StrokeColor: seriesColor,
|
StrokeColor: seriesColor,
|
||||||
StrokeWidth: defaultStrokeWidth,
|
StrokeWidth: strokeWidth,
|
||||||
}
|
}
|
||||||
|
|
||||||
seriesPainter.SetDrawingStyle(drawingStyle)
|
seriesPainter.SetDrawingStyle(drawingStyle)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue