feat: support make point and make line
This commit is contained in:
parent
fd05250305
commit
e558634dda
16 changed files with 308 additions and 51 deletions
|
|
@ -28,14 +28,28 @@ import (
|
|||
"github.com/wcharczuk/go-chart/v2/drawing"
|
||||
)
|
||||
|
||||
func NewMarkPoint(markPointTypes ...string) SeriesMarkPoint {
|
||||
data := make([]SeriesMarkPointData, len(markPointTypes))
|
||||
for index, t := range markPointTypes {
|
||||
data[index] = SeriesMarkPointData{
|
||||
Type: t,
|
||||
}
|
||||
}
|
||||
return SeriesMarkPoint{
|
||||
Data: data,
|
||||
}
|
||||
}
|
||||
|
||||
type markPointRenderOption struct {
|
||||
Draw *Draw
|
||||
FillColor drawing.Color
|
||||
Font *truetype.Font
|
||||
Series *Series
|
||||
Points []Point
|
||||
}
|
||||
|
||||
func markPointRender(d *Draw, opt markPointRenderOption) {
|
||||
func markPointRender(opt *markPointRenderOption) {
|
||||
d := opt.Draw
|
||||
s := opt.Series
|
||||
if len(s.MarkPoint.Data) == 0 {
|
||||
return
|
||||
|
|
@ -54,7 +68,7 @@ func markPointRender(d *Draw, opt markPointRenderOption) {
|
|||
// 设置文本样式
|
||||
chart.Style{
|
||||
FontColor: NewTheme(ThemeDark).GetTextColor(),
|
||||
FontSize: 10,
|
||||
FontSize: labelFontSize,
|
||||
StrokeWidth: 1,
|
||||
Font: opt.Font,
|
||||
}.WriteTextOptionsToRenderer(r)
|
||||
|
|
@ -62,7 +76,7 @@ func markPointRender(d *Draw, opt markPointRenderOption) {
|
|||
p := points[summary.MinIndex]
|
||||
value := summary.MinValue
|
||||
switch markPointData.Type {
|
||||
case SeriesMarkPointDataTypeMax:
|
||||
case SeriesMarkDataTypeMax:
|
||||
p = points[summary.MaxIndex]
|
||||
value = summary.MaxValue
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue