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

Method columnsListUpdate

plot/plotcore/ploteditor.go:389–429  ·  view source on GitHub ↗

columnsListUpdate updates the list of columns

()

Source from the content-addressed store, hash-verified

387
388// columnsListUpdate updates the list of columns
389func (pl *PlotEditor) columnsListUpdate() {
390 if pl.table == nil || pl.table.Table == nil {
391 pl.Columns = nil
392 return
393 }
394 dt := pl.table.Table
395 nc := dt.NumColumns()
396 if nc == len(pl.Columns) {
397 return
398 }
399 pl.Columns = make([]*ColumnOptions, nc)
400 clri := 0
401 hasOn := false
402 for ci := range dt.NumColumns() {
403 cn := dt.ColumnName(ci)
404 if pl.Options.XAxis == "" && ci == 0 {
405 pl.Options.XAxis = cn // x-axis defaults to the first column
406 }
407 cp := &ColumnOptions{Column: cn}
408 cp.defaults()
409 tcol := dt.Columns[ci]
410 if tcol.IsString() {
411 cp.IsString = true
412 } else {
413 cp.IsString = false
414 // we enable the first non-string, non-x-axis, non-first column by default
415 if !hasOn && cn != pl.Options.XAxis && ci != 0 {
416 cp.On = true
417 hasOn = true
418 }
419 }
420 cp.fromMetaMap(pl.table.Table.MetaData)
421 inc := 1
422 if cn == pl.Options.XAxis || tcol.IsString() || tcol.DataType() == reflect.Int || tcol.DataType() == reflect.Int64 || tcol.DataType() == reflect.Int32 || tcol.DataType() == reflect.Uint8 {
423 inc = 0
424 }
425 cp.Color = colors.Uniform(colors.Spaced(clri))
426 pl.Columns[ci] = cp
427 clri += inc
428 }
429}
430
431// ColumnsFromMetaMap updates all the column settings from given meta map
432func (pl *PlotEditor) ColumnsFromMetaMap(meta map[string]string) {

Callers 1

makeColumnsMethod · 0.95

Calls 8

defaultsMethod · 0.95
fromMetaMapMethod · 0.95
UniformFunction · 0.92
SpacedFunction · 0.92
NumColumnsMethod · 0.65
ColumnNameMethod · 0.65
IsStringMethod · 0.65
DataTypeMethod · 0.65

Tested by

no test coverage detected