MCPcopy
hub / github.com/tensorflow/tfjs / surface

Method surface

tfjs-vis/src/visor.ts:137–161  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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

Callers 6

visor_test.tsFile · 0.80
getDrawAreaFunction · 0.80
setupListenersFunction · 0.80
addLoaderElementFunction · 0.80

Calls 3

hasMethod · 0.80
getSurfaceMethod · 0.80
setMethod · 0.45

Tested by

no test coverage detected