MCPcopy Index your code
hub / github.com/microsoft/SandDance / internalScaleFunctions

Function internalScaleFunctions

docs/app/js/sanddance-app.js:142853–142866  ·  view source on GitHub ↗
(codegen, fnctx, visitors)

Source from the content-addressed store, hash-verified

142851 return (0, _vegaUtil.isFunction)(name) ? name : (0, _vegaUtil.isString)(name) ? (s = ctx.scales[name]) && s.value : undefined;
142852}
142853function internalScaleFunctions(codegen, fnctx, visitors) {
142854 // add helper method to the 'this' expression function context
142855 fnctx.__bandwidth = (s)=>s && s.bandwidth ? s.bandwidth() : 0; // register AST visitors for internal scale functions
142856 visitors._bandwidth = scaleVisitor;
142857 visitors._range = scaleVisitor;
142858 visitors._scale = scaleVisitor; // resolve scale reference directly to the signal hash argument
142859 const ref = (arg)=>"_[" + (arg.type === (0, _vegaExpression.Literal) ? (0, _vegaUtil.stringValue)(ScalePrefix + arg.value) : (0, _vegaUtil.stringValue)(ScalePrefix) + "+" + codegen(arg)) + "]"; // define and return internal scale function code generators
142860 // these internal functions are called by mark encoders
142861 return {
142862 _bandwidth: (args)=>`this.__bandwidth(${ref(args[0])})`,
142863 _range: (args)=>`${ref(args[0])}.range()`,
142864 _scale: (args)=>`${ref(args[0])}(${codegen(args[1])})`
142865 };
142866}
142867function geoMethod(methodName, globalMethod) {
142868 return function(projection, geojson, group) {
142869 if (projection) {

Callers 1

buildFunctionsFunction · 0.70

Calls 2

refFunction · 0.70
codegenFunction · 0.70

Tested by

no test coverage detected