added option for line chart bg fill opacity
This commit is contained in:
parent
830d4bdd21
commit
a767b3e1af
3 changed files with 10 additions and 1 deletions
|
|
@ -71,6 +71,8 @@ type ChartOption struct {
|
|||
BarHeight int
|
||||
// Fill the area of line chart
|
||||
FillArea bool
|
||||
// background fill (alpha) opacity
|
||||
Opacity uint8
|
||||
// The child charts
|
||||
Children []ChartOption
|
||||
// The value formatter
|
||||
|
|
|
|||
|
|
@ -409,6 +409,7 @@ func Render(opt ChartOption, opts ...OptionFunc) (*Painter, error) {
|
|||
SymbolShow: opt.SymbolShow,
|
||||
StrokeWidth: opt.LineStrokeWidth,
|
||||
FillArea: opt.FillArea,
|
||||
Opacity: opt.Opacity,
|
||||
}).render(renderResult, lineSeriesList)
|
||||
return err
|
||||
})
|
||||
|
|
|
|||
|
|
@ -70,6 +70,8 @@ type LineChartOption struct {
|
|||
FillArea bool
|
||||
// background is filled
|
||||
backgroundIsFilled bool
|
||||
// background fill (alpha) opacity
|
||||
Opacity uint8
|
||||
}
|
||||
|
||||
func (l *lineChart) render(result *defaultRenderResult, seriesList SeriesList) (Box, error) {
|
||||
|
|
@ -156,6 +158,10 @@ func (l *lineChart) render(result *defaultRenderResult, seriesList SeriesList) (
|
|||
areaPoints := make([]Point, len(points))
|
||||
copy(areaPoints, points)
|
||||
bottomY := yRange.getRestHeight(yRange.min)
|
||||
var opacity uint8 = 200
|
||||
if opt.Opacity != 0 {
|
||||
opacity = opt.Opacity
|
||||
}
|
||||
areaPoints = append(areaPoints, Point{
|
||||
X: areaPoints[len(areaPoints)-1].X,
|
||||
Y: bottomY,
|
||||
|
|
@ -164,7 +170,7 @@ func (l *lineChart) render(result *defaultRenderResult, seriesList SeriesList) (
|
|||
Y: bottomY,
|
||||
}, areaPoints[0])
|
||||
seriesPainter.SetDrawingStyle(Style{
|
||||
FillColor: seriesColor.WithAlpha(200),
|
||||
FillColor: seriesColor.WithAlpha(opacity),
|
||||
})
|
||||
seriesPainter.FillArea(areaPoints)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue