本文整理汇总了TypeScript中vega-util.stringValue函数的典型用法代码示例。如果您正苦于以下问题:TypeScript stringValue函数的具体用法?TypeScript stringValue怎么用?TypeScript stringValue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了stringValue函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: warn
selCmpt.project.forEach(function(p) {
const channel = p.channel;
if (channel !== X && channel !== Y) {
warn('Interval selections only support x and y encoding channels.');
return;
}
const cs = channelSignals(model, selCmpt, channel);
const dname = channelSignalName(selCmpt, channel, 'data');
const vname = channelSignalName(selCmpt, channel, 'visual');
const scaleStr = stringValue(model.scaleName(channel));
const scaleType = model.getScaleComponent(channel).get('type');
const toNum = hasContinuousDomain(scaleType) ? '+' : '';
signals.push.apply(signals, cs);
tupleTriggers.push(dname);
intervals.push(`{encoding: ${stringValue(channel)}, ` +
`field: ${stringValue(p.field)}, extent: ${dname}}`);
scaleTriggers.push({
scaleName: model.scaleName(channel),
expr: `(!isArray(${dname}) || ` +
`(${toNum}invert(${scaleStr}, ${vname})[0] === ${toNum}${dname}[0] && ` +
`${toNum}invert(${scaleStr}, ${vname})[1] === ${toNum}${dname}[1]))`
});
});
开发者ID:troystribling,项目名称:dotfiles,代码行数:26,代码来源:interval.ts
示例2: selectionScaleDomain
export function selectionScaleDomain(model: Model, domainRaw: VgSignalRef): VgSignalRef {
const selDomain = JSON.parse(domainRaw.signal.replace(SELECTION_DOMAIN, ''));
const name = varName(selDomain.selection);
let selCmpt = model.component.selection && model.component.selection[name];
if (selCmpt) {
warn('Use "bind": "scales" to setup a binding for scales and selections within the same view.');
} else {
selCmpt = model.getSelectionComponent(name, selDomain.selection);
if (!selDomain.encoding && !selDomain.field) {
selDomain.field = selCmpt.project[0].field;
if (selCmpt.project.length > 1) {
warn('A "field" or "encoding" must be specified when using a selection as a scale domain. ' +
`Using "field": ${stringValue(selDomain.field)}.`);
}
}
return {
signal: compiler(selCmpt.type).scaleDomain +
`(${stringValue(name + STORE)}, ${stringValue(selDomain.encoding || null)}, ` +
stringValue(selDomain.field || null) +
(selCmpt.resolve === 'global' ? ')' : `, ${stringValue(selCmpt.resolve)})`)
};
}
return {signal: 'null'};
}
开发者ID:troystribling,项目名称:dotfiles,代码行数:26,代码来源:selection.ts
示例3: warn
selCmpt.project.items.forEach((proj, i) => {
const channel = proj.channel;
if (channel !== X && channel !== Y) {
warn('Interval selections only support x and y encoding channels.');
return;
}
const init = selCmpt.init ? selCmpt.init[i] : null;
const cs = channelSignals(model, selCmpt, proj, init);
const dname = proj.signals.data;
const vname = proj.signals.visual;
const scaleName = stringValue(model.scaleName(channel));
const scaleType = model.getScaleComponent(channel).get('type');
const toNum = hasContinuousDomain(scaleType) ? '+' : '';
signals.push(...cs);
dataSignals.push(dname);
scaleTriggers.push({
scaleName: model.scaleName(channel),
expr:
`(!isArray(${dname}) || ` +
`(${toNum}invert(${scaleName}, ${vname})[0] === ${toNum}${dname}[0] && ` +
`${toNum}invert(${scaleName}, ${vname})[1] === ${toNum}${dname}[1]))`
});
});
开发者ID:vega,项目名称:vega-lite,代码行数:26,代码来源:interval.ts
示例4:
topLevelSignals: (model, selCmpt, signals) => {
const bound = selCmpt.scales.filter(proj => !signals.filter(s => s.name === proj.signals.data).length);
// Top-level signals are only needed for multiview displays and if this
// view's top-level signals haven't already been generated.
if (!model.parent || !bound.length) {
return signals;
}
// vlSelectionResolve does not account for the behavior of bound scales in
// multiview displays. Each unit view adds a tuple to the store, but the
// state of the selection is the unit selection most recently updated. This
// state is captured by the top-level signals that we insert and "push
// outer" to from within the units. We need to reassemble this state into
// the top-level named signal, except no single selCmpt has a global view.
const namedSg = signals.filter(s => s.name === selCmpt.name)[0];
const update = namedSg.update;
if (update.indexOf(VL_SELECTION_RESOLVE) >= 0) {
namedSg.update = `{${bound.map(proj => `${stringValue(proj.field)}: ${proj.signals.data}`).join(', ')}}`;
} else {
for (const proj of bound) {
const mapping = `, ${stringValue(proj.field)}: ${proj.signals.data}`;
if (update.indexOf(mapping) < 0) {
namedSg.update = update.substring(0, update.length - 1) + mapping + '}';
}
}
}
return signals.concat(bound.map(proj => ({name: proj.signals.data})));
},
开发者ID:vega,项目名称:vega-lite,代码行数:30,代码来源:scales.ts
示例5: channelSignals
/**
* Returns the visual and data signals for an interval selection.
*/
function channelSignals(model: UnitModel, selCmpt: SelectionComponent, channel: 'x'|'y'): any {
const vname = channelSignalName(selCmpt, channel, 'visual');
const dname = channelSignalName(selCmpt, channel, 'data');
const hasScales = scales.has(selCmpt);
const scaleName = model.scaleName(channel);
const scaleStr = stringValue(scaleName);
const scale = model.getScaleComponent(channel);
const scaleType = scale ? scale.get('type') : undefined;
const size = model.getSizeSignalRef(channel === X ? 'width' : 'height').signal;
const coord = `${channel}(unit)`;
const on = events(selCmpt, function(def: any[], evt: VgEventStream) {
return def.concat(
{events: evt.between[0], update: `[${coord}, ${coord}]`}, // Brush Start
{events: evt, update: `[${vname}[0], clamp(${coord}, 0, ${size})]`} // Brush End
);
});
// React to pan/zooms of continuous scales. Non-continuous scales
// (bin-linear, band, point) cannot be pan/zoomed and any other changes
// to their domains (e.g., filtering) should clear the brushes.
on.push({
events: {signal: selCmpt.name + SCALE_TRIGGER},
update: hasContinuousDomain(scaleType) && !isBinScale(scaleType) ?
`[scale(${scaleStr}, ${dname}[0]), scale(${scaleStr}, ${dname}[1])]` : `[0, 0]`
});
return hasScales ? [{name: dname, on: []}] : [{
name: vname, value: [], on: on
}, {
name: dname,
on: [{events: {signal: vname}, update: `${vname}[0] === ${vname}[1] ? null : invert(${scaleStr}, ${vname})`}]
}];
}
开发者ID:troystribling,项目名称:dotfiles,代码行数:37,代码来源:interval.ts
示例6: unitName
export function unitName(model: Model) {
let name = stringValue(model.name);
const facet = getFacetModel(model);
if (facet) {
name += (facet.facet.row ? ` + '_' + (${accessPathWithDatum(facet.vgField('row'), 'facet')})` : '')
+ (facet.facet.column ? ` + '_' + (${accessPathWithDatum(facet.vgField('column'), 'facet')})` : '');
}
return name;
}
开发者ID:troystribling,项目名称:dotfiles,代码行数:9,代码来源:selection.ts
示例7: function
topLevelSignals: function(model, selCmpt, signals) {
const hasSignal = signals.filter((s) => s.name === selCmpt.name);
const data = `data(${stringValue(selCmpt.name + STORE)})`;
const values = `${data}[0].values`;
return hasSignal.length ? signals : signals.concat({
name: selCmpt.name,
update: `${data}.length && {` +
selCmpt.project.map((p, i) => `${p.field}: ${values}[${i}]`).join(', ') + '}'
});
},
开发者ID:troystribling,项目名称:dotfiles,代码行数:10,代码来源:single.ts
示例8: function
signals: function(model, selCmpt, signals) {
const name = selCmpt.name;
const hasScales = scalesCompiler.has(selCmpt);
const delta = name + DELTA;
const {x, y} = positionalProjections(selCmpt);
const sx = stringValue(model.scaleName(X));
const sy = stringValue(model.scaleName(Y));
let events = parseSelector(selCmpt.zoom, 'scope');
if (!hasScales) {
events = events.map((e) => (e.markname = name + INTERVAL_BRUSH, e));
}
signals.push({
name: name + ANCHOR,
on: [{
events: events,
update: !hasScales ? `{x: x(unit), y: y(unit)}` :
'{' + [
(sx ? `x: invert(${sx}, x(unit))` : ''),
(sy ? `y: invert(${sy}, y(unit))` : '')
].filter((expr) => !!expr).join(', ') + '}'
}]
}, {
name: delta,
on: [{
events: events,
force: true,
update: 'pow(1.001, event.deltaY * pow(16, event.deltaMode))'
}]
});
if (x !== null) {
onDelta(model, selCmpt, 'x', 'width', signals);
}
if (y !== null) {
onDelta(model, selCmpt, 'y', 'height', signals);
}
return signals;
}
开发者ID:troystribling,项目名称:dotfiles,代码行数:42,代码来源:zoom.ts
示例9: channelSignals
/**
* Returns the visual and data signals for an interval selection.
*/
function channelSignals(
model: UnitModel,
selCmpt: SelectionComponent<'interval'>,
proj: SelectionProjection,
init?: SelectionInitArray
): any {
const channel = proj.channel;
const vname = proj.signals.visual;
const dname = proj.signals.data;
const hasScales = scales.has(selCmpt);
const scaleName = stringValue(model.scaleName(channel));
const scale = model.getScaleComponent(channel as ScaleChannel);
const scaleType = scale ? scale.get('type') : undefined;
const scaled = (str: string) => `scale(${scaleName}, ${str})`;
const size = model.getSizeSignalRef(channel === X ? 'width' : 'height').signal;
const coord = `${channel}(unit)`;
const on = events(selCmpt, (def: any[], evt: EventStream) => {
return [
...def,
{events: evt.between[0], update: `[${coord}, ${coord}]`}, // Brush Start
{events: evt, update: `[${vname}[0], clamp(${coord}, 0, ${size})]`} // Brush End
];
});
// React to pan/zooms of continuous scales. Non-continuous scales
// (band, point) cannot be pan/zoomed and any other changes
// to their domains (e.g., filtering) should clear the brushes.
on.push({
events: {signal: selCmpt.name + SCALE_TRIGGER},
update: hasContinuousDomain(scaleType) ? `[${scaled(`${dname}[0]`)}, ${scaled(`${dname}[1]`)}]` : `[0, 0]`
});
return hasScales
? [{name: dname, on: []}]
: [
{
name: vname,
...(init ? {init: assembleInit(init, scaled)} : {value: []}),
on: on
},
{
name: dname,
...(init ? {init: assembleInit(init)} : {}), // Cannot be `value` as `init` may require datetime exprs.
on: [
{
events: {signal: vname},
update: `${vname}[0] === ${vname}[1] ? null : invert(${scaleName}, ${vname})`
}
]
}
];
}
开发者ID:vega,项目名称:vega-lite,代码行数:56,代码来源:interval.ts
示例10: unitName
export function unitName(model: Model) {
let name = stringValue(model.name);
const facetModel = getFacetModel(model);
if (facetModel) {
const {facet} = facetModel;
for (const channel of FACET_CHANNELS) {
if (facet[channel]) {
name += ` + '__facet_${channel}_' + (${accessPathWithDatum(facetModel.vgField(channel), 'facet')})`;
}
}
}
return name;
}
开发者ID:vega,项目名称:vega-lite,代码行数:13,代码来源:index.ts
注:本文中的vega-util.stringValue函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论