MCPcopy Create free account
hub / github.com/cogentcore/core / xValue

Method xValue

plot/plotcore/tablexy.go:193–212  ·  view source on GitHub ↗

xValue returns an x value at given row in table

(row int)

Source from the content-addressed store, hash-verified

191
192// xValue returns an x value at given row in table
193func (txy *tableXY) xValue(row int) float32 {
194 if txy.table == nil || txy.table.Table == nil || row >= txy.table.Len() {
195 return 0
196 }
197 trow := txy.table.Indexes[row] // true table row
198 xc := txy.table.Table.Columns[txy.xColumn]
199 x := float32(0.0)
200 switch {
201 case xc.IsString():
202 x = float32(row)
203 case xc.NumDims() > 1:
204 _, sz := xc.RowCellSize()
205 if txy.xIndex < sz && txy.xIndex >= 0 {
206 x = float32(xc.FloatRowCell(trow, txy.xIndex))
207 }
208 default:
209 x = float32(xc.Float1D(trow))
210 }
211 return x
212}
213
214// XY returns an x, y pair at given row in table
215func (txy *tableXY) XY(row int) (x, y float32) {

Callers 1

XYMethod · 0.95

Calls 6

LenMethod · 0.65
IsStringMethod · 0.65
NumDimsMethod · 0.65
RowCellSizeMethod · 0.65
FloatRowCellMethod · 0.65
Float1DMethod · 0.65

Tested by

no test coverage detected