refactor: support label show for radar chart, #62
This commit is contained in:
parent
c302d0ffa4
commit
98af9866a4
2 changed files with 13 additions and 1 deletions
|
|
@ -344,6 +344,11 @@ func (esList EChartsSeriesList) ToSeriesList() SeriesList {
|
|||
Data: NewSeriesDataFromValues(dataItem.Value.values),
|
||||
Max: item.Max,
|
||||
Min: item.Min,
|
||||
Label: SeriesLabel{
|
||||
Color: parseColor(item.Label.Color),
|
||||
Show: item.Label.Show,
|
||||
Distance: item.Label.Distance,
|
||||
},
|
||||
})
|
||||
}
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ package charts
|
|||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/dustin/go-humanize"
|
||||
"github.com/golang/freetype/truetype"
|
||||
"github.com/wcharczuk/go-chart/v2"
|
||||
"github.com/wcharczuk/go-chart/v2/drawing"
|
||||
|
|
@ -230,9 +231,15 @@ func (r *radarChart) render(result *defaultRenderResult, seriesList SeriesList)
|
|||
StrokeColor: color,
|
||||
FillColor: dotFillColor,
|
||||
})
|
||||
for _, point := range linePoints {
|
||||
for index, point := range linePoints {
|
||||
seriesPainter.Circle(dotWith, point.X, point.Y)
|
||||
seriesPainter.FillStroke()
|
||||
if series.Label.Show && index < len(series.Data) {
|
||||
value := humanize.FtoaWithDigits(series.Data[index].Value, 2)
|
||||
b := seriesPainter.MeasureText(value)
|
||||
seriesPainter.Text(value, point.X-b.Width()/2, point.Y)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue