How to use the vega-lite/build/src/fielddef.isFieldDef function in vega-lite

To help you get started, we’ve selected a few vega-lite examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vega / voyager / src / components / plot / index.tsx View on Github external
private onSort(channel: 'x' | 'y') {
    // TODO: really take `sort` as input instead of toggling like this
    const {spec, onSort} = this.props;
    const channelDef = spec.encoding[channel];
    if (isFieldDef(channelDef)) {
      const sort = channelDef.sort === 'descending' ? undefined : 'descending';
      onSort(channel, sort);
    }
  }
github vega / voyager / src / reducers / result.ts View on Github external
function resultPlotSpecModifyFieldReducer(encoding: EncodingWithFacet, action: ResultModifyAction) {
  const {channel, prop, value} = action.payload;
  const channelDef = encoding[channel];
  if (!channelDef) {
    console.error(`${action.type} no working for channel ${channel} without field.`);
  } else if (isArray(channelDef)) {
    console.error(`${action.type}  not supported for detail and order`);
    return encoding;
  } else if (!isFieldDef(channelDef)) {
    console.error(`${action.type}  not supported for detail and order`);
    return encoding;
  }
  const fieldDef = encoding[channel] as FieldDef;
  switch (action.type) {
    case RESULT_MODIFY_FIELD_PROP:
      return {
        ...encoding,
        [channel]: modifyFieldProp(fieldDef, prop, value)
      };

    case RESULT_MODIFY_NESTED_FIELD_PROP: {
      const {nestedProp} = action.payload;
      return {
        ...encoding,
        [channel]: modifyNestedFieldProp(fieldDef, prop, nestedProp, value)
github vega / voyager / src / components / plot / index.tsx View on Github external
private renderSortButton(channel: 'x' | 'y') {
    const {spec} = this.props;
    const channelDef = spec.encoding[channel];
    if (isFieldDef(channelDef) && isDiscrete(channelDef)) {
      return <i title="Sort">;
    }
    return undefined;
  }
</i>