remember if data labels were automatically calculated, fix x labels with dynamic data

This commit is contained in:
Martin Lindhe 2016-09-24 01:09:48 +02:00
parent 23b25db083
commit a75e14acaa

View File

@ -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)