MCPcopy Index your code
hub / github.com/g3n/engine / SetScaleY

Method SetScaleY

gui/chart.go:206–233  ·  view source on GitHub ↗

SetScaleY sets the Y scale number of lines and color

(lines int, color *math32.Color)

Source from the content-addressed store, hash-verified

204
205// SetScaleY sets the Y scale number of lines and color
206func (ch *Chart) SetScaleY(lines int, color *math32.Color) {
207
208 if ch.scaleY != nil {
209 ch.ClearScaleY()
210 }
211
212 if lines < 2 {
213 lines = 2
214 }
215
216 // Add scale lines
217 ch.scaleY = newChartScaleY(ch, lines, color)
218 ch.Add(ch.scaleY)
219
220 // Add scale labels
221 // The position of the labels will be set by 'recalc()'
222 value := ch.minY
223 step := (ch.maxY - ch.minY) / float32(lines-1)
224 for i := 0; i < lines; i++ {
225 l := NewLabel(fmt.Sprintf(ch.formatY, value))
226 l.SetColor4(math32.NewColor4("black"))
227 l.SetFontSize(ch.fontSizeY)
228 ch.Add(l)
229 ch.labelsY = append(ch.labelsY, l)
230 value += step
231 }
232 ch.recalc()
233}
234
235// ClearScaleY removes the Y scale if it was previously set
236func (ch *Chart) ClearScaleY() {

Callers 1

buildChartFunction · 0.95

Calls 8

ClearScaleYMethod · 0.95
SetColor4Method · 0.95
SetFontSizeMethod · 0.95
recalcMethod · 0.95
NewColor4Function · 0.92
newChartScaleYFunction · 0.85
NewLabelFunction · 0.85
AddMethod · 0.45

Tested by

no test coverage detected