remember if data labels were automatically calculated, fix x labels with dynamic data
This commit is contained in:
parent
23b25db083
commit
a75e14acaa
@ -69,6 +69,7 @@ type LineChart struct {
|
|||||||
labelYSpace int
|
labelYSpace int
|
||||||
maxY float64
|
maxY float64
|
||||||
minY float64
|
minY float64
|
||||||
|
autoLabels bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewLineChart returns a new LineChart with current theme.
|
// NewLineChart returns a new LineChart with current theme.
|
||||||
@ -211,7 +212,8 @@ func (lc *LineChart) calcLabelY() {
|
|||||||
|
|
||||||
func (lc *LineChart) calcLayout() {
|
func (lc *LineChart) calcLayout() {
|
||||||
// set datalabels if it is not provided
|
// 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))
|
lc.DataLabels = make([]string, len(lc.Data))
|
||||||
for i := range lc.Data {
|
for i := range lc.Data {
|
||||||
lc.DataLabels[i] = fmt.Sprint(i)
|
lc.DataLabels[i] = fmt.Sprint(i)
|
||||||
|
Loading…
Reference in New Issue
Block a user