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

TypeScript d3.select函数代码示例

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

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



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

示例1: drawLegendValues

function drawLegendValues(elem, colorScale, rangeFrom, rangeTo, maxValue, minValue, legendWidth) {
  let legendElem = $(elem).find('svg');
  let legend = d3.select(legendElem.get(0));

  if (legendWidth <= 0 || legendElem.get(0).childNodes.length === 0) {
    return;
  }

  let legendValueScale = d3.scaleLinear()
    .domain([0, rangeTo])
    .range([0, legendWidth]);

  let ticks = buildLegendTicks(0, rangeTo, maxValue, minValue);
  let xAxis = d3.axisBottom(legendValueScale)
    .tickValues(ticks)
    .tickSize(2);

  let colorRect = legendElem.find(":first-child");
  let posY = colorRect.height() + 2;
  let posX = getSvgElemX(colorRect);

  d3.select(legendElem.get(0)).append("g")
    .attr("class", "axis")
    .attr("transform", "translate(" + posX + "," + posY + ")")
    .call(xAxis);

  legend.select(".axis").select(".domain").remove();
}
开发者ID:PaulMest,项目名称:grafana,代码行数:28,代码来源:color_legend.ts


示例2: highlightCard

 function highlightCard(event) {
   let color = d3.select(event.target).style("fill");
   let highlightColor = d3.color(color).darker(2);
   let strokeColor = d3.color(color).brighter(4);
   let current_card = d3.select(event.target);
   tooltip.originalFillColor = color;
   current_card.style("fill", highlightColor)
   .style("stroke", strokeColor)
   .style("stroke-width", 1);
 }
开发者ID:PaulMest,项目名称:grafana,代码行数:10,代码来源:rendering.ts


示例3: drawColorLegend

function drawColorLegend(elem, colorScheme, rangeFrom, rangeTo, maxValue, minValue) {
  let legendElem = $(elem).find('svg');
  let legend = d3.select(legendElem.get(0));
  clearLegend(elem);

  let legendWidth = Math.floor(legendElem.outerWidth()) - 30;
  let legendHeight = legendElem.attr("height");

  let rangeStep = 1;
  if (rangeTo - rangeFrom > legendWidth) {
    rangeStep = Math.floor((rangeTo - rangeFrom) / legendWidth);
  }
  let widthFactor = legendWidth / (rangeTo - rangeFrom);
  let valuesRange = d3.range(rangeFrom, rangeTo, rangeStep);

  let colorScale = getColorScale(colorScheme, maxValue, minValue);
  legend.selectAll(".heatmap-color-legend-rect")
    .data(valuesRange)
    .enter().append("rect")
    .attr("x", d => d * widthFactor)
    .attr("y", 0)
    .attr("width", rangeStep * widthFactor + 1) // Overlap rectangles to prevent gaps
    .attr("height", legendHeight)
    .attr("stroke-width", 0)
    .attr("fill", d => colorScale(d));

  drawLegendValues(elem, colorScale, rangeFrom, rangeTo, maxValue, minValue, legendWidth);
}
开发者ID:PaulMest,项目名称:grafana,代码行数:28,代码来源:color_legend.ts


示例4: drawSimpleOpacityLegend

function drawSimpleOpacityLegend(elem, options) {
  let legendElem = $(elem).find('svg');
  clearLegend(elem);

  let legend = d3.select(legendElem.get(0));
  let legendWidth = Math.floor(legendElem.outerWidth());
  let legendHeight = legendElem.attr("height");

  if (legendWidth) {
    let legendOpacityScale;
    if (options.colorScale === 'linear') {
      legendOpacityScale = d3.scaleLinear()
      .domain([0, legendWidth])
      .range([0, 1]);
    } else if (options.colorScale === 'sqrt') {
      legendOpacityScale = d3.scalePow().exponent(options.exponent)
      .domain([0, legendWidth])
      .range([0, 1]);
    }

    let rangeStep = 10;
    let valuesRange = d3.range(0, legendWidth, rangeStep);
    var legendRects = legend.selectAll(".heatmap-opacity-legend-rect").data(valuesRange);

    legendRects.enter().append("rect")
      .attr("x", d => d)
      .attr("y", 0)
      .attr("width", rangeStep)
      .attr("height", legendHeight)
      .attr("stroke-width", 0)
      .attr("fill", options.cardColor)
      .style("opacity", d => legendOpacityScale(d));
  }
}
开发者ID:PaulMest,项目名称:grafana,代码行数:34,代码来源:color_legend.ts


示例5: drawOpacityLegend

function drawOpacityLegend(elem, options, rangeFrom, rangeTo, maxValue, minValue) {
  let legendElem = $(elem).find('svg');
  let legend = d3.select(legendElem.get(0));
  clearLegend(elem);

  let legendWidth = Math.floor(legendElem.outerWidth()) - 30;
  let legendHeight = legendElem.attr("height");

  let rangeStep = 10;
  let widthFactor = legendWidth / (rangeTo - rangeFrom);
  let valuesRange = d3.range(rangeFrom, rangeTo, rangeStep);

  let opacityScale = getOpacityScale(options, maxValue, minValue);
  legend.selectAll(".heatmap-opacity-legend-rect")
    .data(valuesRange)
    .enter().append("rect")
    .attr("x", d => d * widthFactor)
    .attr("y", 0)
    .attr("width", rangeStep * widthFactor)
    .attr("height", legendHeight)
    .attr("stroke-width", 0)
    .attr("fill", options.cardColor)
    .style("opacity", d => opacityScale(d));

  drawLegendValues(elem, opacityScale, rangeFrom, rangeTo, maxValue, minValue, legendWidth);
}
开发者ID:PaulMest,项目名称:grafana,代码行数:26,代码来源:color_legend.ts


示例6: addHeatmapCanvas

  function addHeatmapCanvas() {
    let heatmap_elem = $heatmap[0];

    width = Math.floor($heatmap.width()) - padding.right;
    height = Math.floor($heatmap.height()) - padding.bottom;

    cardPadding = panel.cards.cardPadding !== null ? panel.cards.cardPadding : CARD_PADDING;
    cardRound = panel.cards.cardRound !== null ? panel.cards.cardRound : CARD_ROUND;

    if (heatmap) {
      heatmap.remove();
    }

    heatmap = d3.select(heatmap_elem)
      .append("svg")
      .attr("width", width)
      .attr("height", height);
  }
开发者ID:PaulMest,项目名称:grafana,代码行数:18,代码来源:rendering.ts


示例7: drawSimpleColorLegend

function drawSimpleColorLegend(elem, colorScale) {
  let legendElem = $(elem).find('svg');
  clearLegend(elem);

  let legendWidth = Math.floor(legendElem.outerWidth());
  let legendHeight = legendElem.attr("height");

  if (legendWidth) {
    let valuesNumber = Math.floor(legendWidth / 2);
    let rangeStep  = Math.floor(legendWidth / valuesNumber);
    let valuesRange = d3.range(0, legendWidth, rangeStep);

    let legend = d3.select(legendElem.get(0));
    var legendRects = legend.selectAll(".heatmap-color-legend-rect").data(valuesRange);

    legendRects.enter().append("rect")
      .attr("x", d => d)
      .attr("y", 0)
      .attr("width", rangeStep + 1) // Overlap rectangles to prevent gaps
      .attr("height", legendHeight)
      .attr("stroke-width", 0)
      .attr("fill", d => colorScale(d));
  }
}
开发者ID:PaulMest,项目名称:grafana,代码行数:24,代码来源:color_legend.ts


示例8: resetCardHighLight

 function resetCardHighLight(event) {
   d3.select(event.target).style("fill", tooltip.originalFillColor)
   .style("stroke", tooltip.originalFillColor)
   .style("stroke-width", 0);
 }
开发者ID:PaulMest,项目名称:grafana,代码行数:5,代码来源:rendering.ts


示例9: add

 add() {
   this.tooltip = d3.select("body")
     .append("div")
     .attr("class", "heatmap-tooltip graph-tooltip grafana-tooltip");
 }
开发者ID:PaulMest,项目名称:grafana,代码行数:5,代码来源:heatmap_tooltip.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript Viewport.getContext函数代码示例发布时间:2022-05-25
下一篇:
TypeScript d3.scalePow函数代码示例发布时间: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