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

Method updateData

gui/chart.go:667–685  ·  view source on GitHub ↗

updateData regenerates the lines for the current data

()

Source from the content-addressed store, hash-verified

665
666// updateData regenerates the lines for the current data
667func (lg *Graph) updateData() {
668
669 lines := 1
670 if lg.chart.scaleX != nil {
671 lines = lg.chart.scaleX.lines
672 }
673 step := 1.0 / (float32(lines) * lg.chart.countStepX)
674
675 positions := math32.NewArrayF32(0, 0)
676 rangeY := lg.chart.maxY - lg.chart.minY
677 for i := 0; i < len(lg.data); i++ {
678 px := float32(i) * step
679 vy := lg.data[i]
680 py := -1 + ((vy - lg.chart.minY) / rangeY)
681 positions.Append(px, py, 0)
682 }
683 lg.vbo.SetBuffer(positions)
684 lg.SetChanged(true)
685}
686
687// recalc recalculates the position and width of the this panel
688func (lg *Graph) recalc() {

Callers 2

SetDataMethod · 0.95
updateGraphsMethod · 0.80

Calls 4

AppendMethod · 0.95
NewArrayF32Function · 0.92
SetBufferMethod · 0.80
SetChangedMethod · 0.80

Tested by

no test coverage detected