• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript model.getTopSpecQueryItem函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中compassql/build/src/model.getTopSpecQueryItem函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getTopSpecQueryItem函数的具体用法?TypeScript getTopSpecQueryItem怎么用?TypeScript getTopSpecQueryItem使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了getTopSpecQueryItem函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: it

    it('converts SpecQueryGroup<SpecQueryModel> to SpecQueryGroup<PlotObject>', () => {
      const group = buildSpecQueryModelGroup([
        {
          mark: Mark.BAR,
          encodings: [
            {channel: Channel.X}
          ]
        }
      ]);

      const data = {url: 'a/data/set.csv'};

      const plotObjectGroup = convertToPlotObjectsGroup(group, data);
      // should have a spec
      expect(getTopSpecQueryItem(plotObjectGroup).spec).toEqual(
        {
          data: { url: 'a/data/set.csv' },
          mark: 'bar',
          encoding: { x: {} },
          config:
          {
            overlay: { line: true },
            scale: { useUnaggregatedDomain: true }
          }
        });
    });
开发者ID:rpmunoz,项目名称:voyager,代码行数:26,代码来源:plot.test.ts


示例2: getTopSpecQueryItem

 return modelGroup.items.map(item => {
   if (isSpecQueryGroup<PlotObject>(item)) {
     const childModelGroup = item as SpecQueryGroup<PlotObject>;
     return getTopSpecQueryItem(childModelGroup);
   }
   return item as PlotObject;
 });
开发者ID:rpmunoz,项目名称:voyager,代码行数:7,代码来源:plot.ts


示例3: plotObject

 const items = modelGroup.items.map(item => {
   if (isSpecQueryGroup<SpecQueryModel>(item)) {
     const childModelGroup = item as SpecQueryModelGroup;
     return plotObject(data, getTopSpecQueryItem(childModelGroup));
   }
   // FIXME: include data in the main spec?
   return plotObject(data, item as SpecQueryModel);
 });
开发者ID:rpmunoz,项目名称:voyager,代码行数:8,代码来源:plot.ts


示例4: shelfSpecReducer

export function shelfSpecReducer(shelfSpec: Readonly<ShelfUnitSpec> = DEFAULT_SHELF_UNIT_SPEC,
                                 action: Action,
                                 schema: Schema): ShelfUnitSpec {
  switch (action.type) {
    case SHELF_CLEAR:
      return DEFAULT_SHELF_UNIT_SPEC;

    case SHELF_MARK_CHANGE_TYPE: {
      const mark = action.payload;
      return {
        ...shelfSpec,
        mark
      };
    }

    case SHELF_FIELD_ADD: {
      const {shelfId, fieldDef} = action.payload;
      return addEncoding(shelfSpec, shelfId, fieldDef);
    }

    case SHELF_FIELD_AUTO_ADD: {
      const {fieldDef} = action.payload;

      if (shelfSpec.anyEncodings.length > 0 || isWildcard(fieldDef.field)) {
        // If there was an encoding shelf or if the field is a wildcard, just add to wildcard shelf
        return {
          ...shelfSpec,
          anyEncodings: [
            ...shelfSpec.anyEncodings,
            {
              channel: SHORT_WILDCARD,
              ...fieldDef
            }
          ]
        };
      } else {
        // Otherwise, query for the best encoding if there is no wildcard channel
        const query = autoAddFieldQuery(shelfSpec, fieldDef);
        const rec = recommend(query, schema);
        const topSpecQuery = getTopSpecQueryItem(rec.result).specQuery;

        return {
          ...fromSpecQuery(topSpecQuery, shelfSpec.config),
          // retain auto-mark if mark is previously auto
          ...(isWildcard(shelfSpec.mark) ? {mark: shelfSpec.mark} : {})
        };
      }
    }

    case SHELF_FIELD_REMOVE:
      return removeEncoding(shelfSpec, action.payload).shelf;

    case SHELF_FIELD_MOVE: {
      const {to, from} = action.payload;

      const {fieldDef: fieldDefFrom, shelf: removedShelf1} = removeEncoding(shelfSpec, from);
      const {fieldDef: fieldDefTo, shelf: removedShelf2} = removeEncoding(removedShelf1, to);

      const addedShelf1 = addEncoding(removedShelf2, to, fieldDefFrom);
      const addedShelf2 = addEncoding(addedShelf1, from, fieldDefTo);

      return addedShelf2;
    }

    case SHELF_FUNCTION_CHANGE: {
      const {shelfId, fn} = action.payload;

      return modifyEncoding(shelfSpec, shelfId, (fieldDef: Readonly<ShelfFieldDef | ShelfAnyEncodingDef>) => {
        // Remove all existing functions then assign new function
        const {aggregate: _a, bin: _b, timeUnit: _t, hasFn: _h, ...newFieldDef} = fieldDef;

        return {
          ...newFieldDef,
          ...(getFunctionMixins(fn))
        };
      });
    }

    case SHELF_SPEC_LOAD:
      const {spec} = action.payload;
      const specQ = isWildcard(shelfSpec.mark) ? {
        ...fromSpec(spec),
        mark: SHORT_WILDCARD
      } : fromSpec(spec);

      // Restore wildcard mark if the shelf previously has wildcard mark.
      return fromSpecQuery(specQ, shelfSpec.config);
  }
  return shelfSpec;
}
开发者ID:rpmunoz,项目名称:voyager,代码行数:90,代码来源:spec.ts



注:本文中的compassql/build/src/model.getTopSpecQueryItem函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript wildcard.isWildcard函数代码示例发布时间:2022-05-25
下一篇:
TypeScript watcher.Watcher类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap