Merge pull request #103 from martinlindhe/linechart-fix-x-label-dynamic-data
linechart: remember if data labels were automatically calculated
This commit is contained in:
commit
c1c69b79dd
@ -69,6 +69,7 @@ type LineChart struct {
|
||||
labelYSpace int
|
||||
maxY float64
|
||||
minY float64
|
||||
autoLabels bool
|
||||
}
|
||||
|
||||
// NewLineChart returns a new LineChart with current theme.
|
||||
@ -211,7 +212,8 @@ func (lc *LineChart) calcLabelY() {
|
||||
|
||||
func (lc *LineChart) calcLayout() {
|
||||
// set datalabels if it is not provided
|
||||
if lc.DataLabels == nil || len(lc.DataLabels) == 0 {
|
||||
if (lc.DataLabels == nil || len(lc.DataLabels) == 0) || lc.autoLabels {
|
||||
lc.autoLabels = true
|
||||
lc.DataLabels = make([]string, len(lc.Data))
|
||||
for i := range lc.Data {
|
||||
lc.DataLabels[i] = fmt.Sprint(i)
|
||||
|
Loading…
Reference in New Issue
Block a user