MCPcopy Create free account
hub / github.com/microsoft/SandDance / initSpec

Method initSpec

packages/sanddance-specs/src/specBuilder.ts:279–340  ·  view source on GitHub ↗
(dataName: string)

Source from the content-addressed store, hash-verified

277 }
278
279 private initSpec(dataName: string) {
280 const { globalSignals } = this;
281 const { facetAxesAdjustX, facetAxesAdjustY, minCellWidth, minCellHeight, plotOffsetLeft, plotOffsetBottom, plotOffsetTop, plotOffsetRight, plotHeightOut, plotWidthOut } = globalSignals;
282 const { specContext } = this;
283 const { insight } = specContext;
284 const groupMark: GroupMark = {
285 type: 'group',
286 //style: 'cell',
287 encode: {
288 update: {
289 x: { signal: `${SignalNames.PlotOffsetLeft} - ${SignalNames.FacetAxesAdjustX}` },
290 y: { signal: SignalNames.PlotOffsetTop },
291 height: { signal: `${SignalNames.PlotHeightOut} - ${SignalNames.FacetAxesAdjustY}` },
292 width: { signal: `${SignalNames.PlotWidthOut} + ${SignalNames.FacetAxesAdjustX}` },
293 },
294 },
295 };
296 const inputDataname = 'input';
297 const vegaSpec: Spec = {
298 $schema: 'https://vega.github.io/schema/vega/v5.json',
299 //style: 'cell',
300 data: [{ name: inputDataname }, { name: dataName, source: inputDataname, transform: [] }],
301 marks: [groupMark],
302 signals: textSignals(specContext, SignalNames.ViewportHeight).concat([
303 minCellWidth,
304 minCellHeight,
305 {
306 name: SignalNames.ViewportHeight,
307 update: `max(${SignalNames.MinCellHeight}, ${insight.size.height})`,
308 },
309 {
310 name: SignalNames.ViewportWidth,
311 update: `max(${SignalNames.MinCellWidth}, ${insight.size.width})`,
312 },
313 plotOffsetLeft,
314 plotOffsetTop,
315 plotOffsetBottom,
316 plotOffsetRight,
317 facetAxesAdjustX,
318 facetAxesAdjustY,
319 {
320 name: SignalNames.PlotHeightIn,
321 update: `${SignalNames.ViewportHeight} - ${SignalNames.PlotOffsetBottom} + ${SignalNames.FacetAxesAdjustY}`,
322 },
323 {
324 name: SignalNames.PlotWidthIn,
325 update: `${SignalNames.ViewportWidth} - ${SignalNames.PlotOffsetLeft} - ${SignalNames.PlotOffsetRight}`,
326 },
327 plotHeightOut,
328 plotWidthOut,
329 {
330 name: 'height',
331 update: `${SignalNames.PlotOffsetTop} + ${SignalNames.PlotHeightOut} + ${SignalNames.PlotOffsetBottom} - ${SignalNames.FacetAxesAdjustY}`,
332 },
333 {
334 name: 'width',
335 update: `${SignalNames.PlotWidthOut} + ${SignalNames.PlotOffsetLeft} + ${SignalNames.PlotOffsetRight}`,
336 },

Callers 1

buildMethod · 0.95

Calls 1

textSignalsFunction · 0.90

Tested by

no test coverage detected