AddColumn to datatable with a serie of T
(name string, ctyp ColumnType, opt ...ColumnOption)
| 59 | |
| 60 | // AddColumn to datatable with a serie of T |
| 61 | func (t *DataTable) AddColumn(name string, ctyp ColumnType, opt ...ColumnOption) error { |
| 62 | var options ColumnOptions |
| 63 | for _, o := range opt { |
| 64 | o(&options) |
| 65 | } |
| 66 | |
| 67 | // create serie based on ctyp |
| 68 | sr, err := newColumnSerie(ctyp, options) |
| 69 | if err != nil { |
| 70 | return errors.Wrap(err, ErrCreateSerie.Error()) |
| 71 | } |
| 72 | |
| 73 | return t.addColumn(&column{ |
| 74 | name: strings.TrimSpace(name), |
| 75 | typ: ctyp, |
| 76 | serie: sr, |
| 77 | hidden: options.Hidden, |
| 78 | formulae: strings.TrimSpace(options.Expr), |
| 79 | }) |
| 80 | } |
| 81 | |
| 82 | // RenameColumn to rename a column |
| 83 | func (t *DataTable) RenameColumn(old, name string) error { |