当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript lodash.max函数代码示例

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


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

示例1: function

        scope.$watch('highlightTarget', function(target) {
          if (!target) {
            scope.rects = undefined;
            scope.highlightInfo = undefined;
            return;
          }

          if (target.ranges.length) {
            scope.rects = containerCtrl.getRangesRects(target.ranges);

            // gather bbox information and expose it on the scope
            const info = {
              left: _.min(_.map(scope.rects, 'left')),
              right: _.max(_.map(scope.rects, function(rect) {
                return rect.left + rect.width;
              })),
              top: _.min(_.map(scope.rects, 'top')),
              bottom: _.max(_.map(scope.rects, function(rect) {
                return rect.top + rect.height;
              })),
              width: undefined,
              height: undefined,
            };
            info.width = info.right - info.left;
            info.height = info.bottom - info.top;
            scope.highlightInfo = info;
          }
        }, true);
开发者ID:carolinagc,项目名称:paperhive-frontend,代码行数:28,代码来源:highlights.ts

示例2: getRate

function getRate(yLeft, yRight) {
  var rateLeft, rateRight, rate;
  if (checkTwoCross(yLeft, yRight)) {
    rateLeft = yRight.min ? yLeft.min / yRight.min : 0;
    rateRight = yRight.max ? yLeft.max / yRight.max : 0;
  } else {
    if (checkOneSide(yLeft, yRight)) {
      var absLeftMin = Math.abs(yLeft.min);
      var absLeftMax = Math.abs(yLeft.max);
      var absRightMin = Math.abs(yRight.min);
      var absRightMax = Math.abs(yRight.max);
      var upLeft = _.max([absLeftMin, absLeftMax]);
      var downLeft = _.min([absLeftMin, absLeftMax]);
      var upRight = _.max([absRightMin, absRightMax]);
      var downRight = _.min([absRightMin, absRightMax]);

      rateLeft = downLeft ? upLeft / downLeft : upLeft;
      rateRight = downRight ? upRight / downRight : upRight;
    } else {
      if (yLeft.min > 0 || yRight.min > 0) {
        rateLeft = yLeft.max / yRight.max;
        rateRight = 0;
      } else {
        rateLeft = 0;
        rateRight = yLeft.min / yRight.min;
      }
    }
  }

  rate = rateLeft > rateRight ? rateLeft : rateRight;

  return rate;
}
开发者ID:cboggs,项目名称:grafana,代码行数:33,代码来源:align_yaxes.ts

示例3: tileAt

 tileAt(layer: number, x: number, y: number): number {
     let col = _.ceil(x / this.tileWidth) - 1;
     let row = _.ceil(y / this.tileHeight) - 1;
     // make sure col & row aren't negative
     col = _.max([0, col]);
     row = _.max([0, row]);
     return this.layers[layer][row][col];
 }
开发者ID:rbcasperson,项目名称:canvas-tile-map,代码行数:8,代码来源:map.ts

示例4: createScales

export function createScales(props: PositionsBubbleChartProps) {
  const ratio = 12.5
  const { width, height } = props.size
  const minR = 15
  const maxR = 60
  const offset = maxR / 2
  const positionData = getPositionsDataFromSeries(props.data, props.currencyPairs)

  const baseValues = _.map(positionData, (val: any) => {
    return Math.abs(val[baseTradedAmountName])
  })

  const maxValue = _.max(baseValues) || 0
  let minValue = _.min(baseValues) || 0

  if (minValue === maxValue) minValue = 0

  const scales = {
    x: d3.scale.linear()
      .domain([0, props.data.length])
      .range([(-(width / ratio)), (width / ratio) - offset]),
    y: d3.scale.linear()
      .domain([0, props.data.length])
      .range([-(height / (ratio)), height / ratio]),
    r: d3.scale.sqrt()
      .domain([minValue, maxValue])
      .range([minR, maxR])}

  return scales
}
开发者ID:carlosrfernandez,项目名称:ReactiveTraderCloud,代码行数:30,代码来源:chartUtil.ts

示例5: addXHistogramAxis

      function addXHistogramAxis(options, bucketSize) {
        let ticks, min, max;

        if (data.length) {
          ticks = _.map(data[0].data, point => point[0]);

          // Expand ticks for pretty view
          min = Math.max(0, _.min(ticks) - bucketSize);
          max = _.max(ticks) + bucketSize;

          ticks = [];
          for (let i = min; i <= max; i += bucketSize) {
            ticks.push(i);
          }
        } else {
          // Set defaults if no data
          ticks = panelWidth / 100;
          min = 0;
          max = 1;
        }

        options.xaxis = {
          timezone: dashboard.getTimezone(),
          show: panel.xaxis.show,
          mode: null,
          min: min,
          max: max,
          label: "Histogram",
          ticks: ticks
        };
      }
开发者ID:navedalam,项目名称:grafana,代码行数:31,代码来源:graph.ts

示例6: height

 /**
  * Returns how many levels of nodes the tree has
  * @return {number} the height of the tree
  */
 public height(): number {
     if (this._children.length > 0) {
         return 1 + max(this._children.map(c => { return c.height(); }));
     }
     else {
         return 1;
     }
 }
开发者ID:YashdalfTheGray,项目名称:tree-utils,代码行数:12,代码来源:Tree.ts

示例7: getDomainBoundaries

 /*
  * max & min value from two-dimensional array
  */
 public getDomainBoundaries(tsv: TSVFile): DomainBoundaries {
   const chipIndexes = this.getChipHeaderIndexes(tsv.headers);
   const values = _.map(tsv.body.rows, (row: TSVRow) => row.getCellsByIndexes(chipIndexes));
   const flatValues = _.map(_.flatten(values), (value: string) => parseFloat(value));
   const min = _.min(flatValues);
   const max = _.max(flatValues);
   return new DomainBoundaries(min, max);
 }
开发者ID:chipster,项目名称:chipster-web,代码行数:11,代码来源:visualizationTSV.service.ts

示例8: getYAxisWidth

  function getYAxisWidth(elem) {
    let axis_text = elem.selectAll(".axis-y text").nodes();
    let max_text_width = _.max(_.map(axis_text, text => {
      // Use SVG getBBox method
      return text.getBBox().width;
    }));

    return max_text_width;
  }
开发者ID:gofore,项目名称:grafana,代码行数:9,代码来源:rendering.ts

示例9: safeParse

const defaultAreaService : AreaService = (() => {
    let elementaryAreas : { [id : number]: ElementaryArea } 
        = safeParse(window.localStorage.getItem(ELEMENTARY_LOCAL_STORAGE_KEY));
        
    const elementaryCallbacks = $.Callbacks();
    var editArea : ElementaryArea;
    let count = _.max(_.values(elementaryAreas).map((a : ElementaryArea) => a.id)) + 1;
    if (isNaN(count)) {
        count = 1;
    }
    
    $
    .get('http://localhost:8009/elementaryAreas/')
    .then(data => {
        elementaryAreas = data;
        elementaryCallbacks.fire(_.clone(elementaryAreas));
    });
    
    const getElementaryAreas = () => _.clone(elementaryAreas);
    
    const triggerAreasChange = () => { elementaryCallbacks.fire(getElementaryAreas()) };
    
    return {
        getElementaryAreas,
        addElementaryArea: function(area : ElementaryArea, id? : number) {
            const index = id || count++; 
            const newArea = _.clone(area);
            newArea.id = index;
            elementaryAreas[index] = newArea;
            elementaryCallbacks.fire(getElementaryAreas());
        },
        removeElementaryArea: function(id) {
            delete elementaryAreas[id];
            elementaryCallbacks.fire(getElementaryAreas());
        },
        onAreasChange: callback => elementaryCallbacks.add(callback),
        addPoint: (id, point) => elementaryAreas[id].points.push(point),
        setEditArea: id => {
            ToolService.setTool("draw");
            editArea = elementaryAreas[id];
            // TODO: make proper edit here
            editArea.points = [];
            editArea.polygon = Shapes.Polygon(editArea.points, false);
        },
        getCurrentEditArea: () => editArea,
        clearEditArea: () => {
            ToolService.setTool("selection");
            editArea = null;
        },
        setHighlight: function(id, highlight) {
            elementaryAreas[id].hover = highlight;
            elementaryAreas[id].polygon.color = highlight ? 'rgba(77, 163, 44, 0.4)' : null;
            triggerAreasChange();    
        },
        triggerAreasChange
    }
})();
开发者ID:lawliet29,项目名称:mp.backend,代码行数:57,代码来源:services.areas.ts

示例10: getVolcanoPlotDataXBoundary

 /**
  * @Description get the X-domain boundary for the Fold Change columns
  */
 getVolcanoPlotDataXBoundary(tsv: TSVFile): DomainBoundaries {
   let FCIndexes = this.getFCValueHeaderIndex(tsv.headers);
   let values = _.map(tsv.body.rows, (row: TSVRow) => row.getCellsByIndexes(FCIndexes));
   let flatValues = _.map(_.flatten(values), (value: string) => parseFloat(value));
   let min = _.min(flatValues);
   let max = _.max(flatValues);
   console.log(new DomainBoundaries(min, max));
   return new DomainBoundaries(min, max);
 }
开发者ID:chipster,项目名称:chipster-web,代码行数:12,代码来源:volcanoplot.service.ts


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