MCPcopy
hub / github.com/g3n/engine / SetScaleX

Method SetScaleX

gui/chart.go:160–182  ·  view source on GitHub ↗

SetScaleX sets the X scale number of lines, lines color and label font size

(lines int, color *math32.Color)

Source from the content-addressed store, hash-verified

158
159// SetScaleX sets the X scale number of lines, lines color and label font size
160func (ch *Chart) SetScaleX(lines int, color *math32.Color) {
161
162 if ch.scaleX != nil {
163 ch.ClearScaleX()
164 }
165
166 // Add scale lines
167 ch.scaleX = newChartScaleX(ch, lines, color)
168 ch.Add(ch.scaleX)
169
170 // Add scale labels
171 // The positions of the labels will be set by 'recalc()'
172 value := ch.firstX
173 for i := 0; i < lines; i++ {
174 l := NewLabel(fmt.Sprintf(ch.formatX, value))
175 l.SetColor4(math32.NewColor4("black"))
176 l.SetFontSize(ch.fontSizeX)
177 ch.Add(l)
178 ch.labelsX = append(ch.labelsX, l)
179 value += ch.stepX
180 }
181 ch.recalc()
182}
183
184// ClearScaleX removes the X scale if it was previously set
185func (ch *Chart) ClearScaleX() {

Callers 1

buildChartFunction · 0.95

Calls 8

ClearScaleXMethod · 0.95
SetColor4Method · 0.95
SetFontSizeMethod · 0.95
recalcMethod · 0.95
NewColor4Function · 0.92
newChartScaleXFunction · 0.85
NewLabelFunction · 0.85
AddMethod · 0.45

Tested by

no test coverage detected