* Creates a surface on the visor * * Most methods in tfjs-vis that take a surface also take a SurfaceInfo * so you rarely need to call this method unless you want to make a custom * plot. * * ```js * // Create a surface on a tab * tfvis.visor().surface({name: 'My Surface', ta
(options: SurfaceInfo)
| 135 | * @doc {heading: 'Visor & Surfaces', subheading: 'Visor Methods'} |
| 136 | */ |
| 137 | surface(options: SurfaceInfo) { |
| 138 | const {name} = options; |
| 139 | const tab = options.tab == null ? DEFAULT_TAB : options.tab; |
| 140 | |
| 141 | if (name == null || |
| 142 | // tslint:disable-next-line |
| 143 | !(typeof name === 'string' || name as any instanceof String)) { |
| 144 | throw new Error( |
| 145 | // tslint:disable-next-line |
| 146 | 'You must pass a config object with a \'name\' property to create or retrieve a surface'); |
| 147 | } |
| 148 | |
| 149 | const finalOptions: SurfaceInfoStrict = { |
| 150 | ...options, |
| 151 | tab, |
| 152 | }; |
| 153 | |
| 154 | const key = `${name}-${tab}`; |
| 155 | if (!this.surfaceList.has(key)) { |
| 156 | this.surfaceList.set(key, finalOptions); |
| 157 | } |
| 158 | |
| 159 | this.renderVisor(this.el, this.surfaceList); |
| 160 | return this.visorComponent.getSurface(name, tab); |
| 161 | } |
| 162 | |
| 163 | /** |
| 164 | * Returns a boolean indicating if the visor is in 'fullscreen' mode |
no test coverage detected