分层边缘捆绑:添加父组标签

2024-04-28

我对 HTML 和 JavaScript 还很陌生。我面临着著名的分层边缘捆绑可用here https://bl.ocks.org/mbostock/7607999,由 D3.js 库生成。

My goal is to add a semi-circular label zone in order to obtain something like this: every final node group is labelled with the parent's name. enter image description here

不幸的是,除了上面链接中提供的代码之外,我还没有找到任何可以从中获得灵感的代码:我的想法是修改该代码,添加一些行以生成标签。

我看到了这个link https://bl.ocks.org/mbostock/4339607有一段代码可能可以解决这个问题,但我不知道如何使用它(以及我是否处于正确的方向)

node.append("text")
  .attr("dy", ".31em")
  .attr("x", function(d) { return d.x < 180 === !d.children ? 6 : -6; })
  .style("text-anchor", function(d) { return d.x < 180 === !d.children ? "start" : "end"; })
  .attr("transform", function(d) { return "rotate(" + (d.x < 180 ? d.x - 90 : d.x + 90) + ")"; })
  .text(function(d) { return d.id.substring(d.id.lastIndexOf(".") + 1); });

有人有什么建议吗?


基本思想是在链接周围绘制一系列圆弧,并将标签按圆弧的宽度向外分流。

V4解决方案

d3 v4 代码的工作改编链接块 https://bl.ocks.org/mbostock/7607999在下面:

var flare = "https://gist.githubusercontent.com/robinmackenzie/d01d286d9ac16b474a2a43088c137d00/raw/c53c1eda18cc21636ae52dfffa3e030295916c98/flare.json";
d3.json(flare, function(err, json) {
  if (err) throw err;
  render(json);
});

function render(classes) {
  
  // original code
  var diameter = 960,
      radius = diameter / 2,
      innerRadius = radius - 120;

  var cluster = d3.cluster()
      .size([360, innerRadius]);

  var line = d3.radialLine()
      .curve(d3.curveBundle.beta(0.85))
      .radius(function(d) { return d.y; })
      .angle(function(d) { return d.x / 180 * Math.PI; });

  var svg = d3.select("body").append("svg")
      .attr("width", diameter)
      .attr("height", diameter)
    .append("g")
      .attr("transform", "translate(" + radius + "," + radius + ")");

  var link = svg.append("g").selectAll(".link"),
      node = svg.append("g").selectAll(".node");

  var root = packageHierarchy(classes)
      .sum(function(d) { return d.size; });

  cluster(root);
  
  // added code -----
  var arcInnerRadius = innerRadius;
  var arcWidth = 30;
  var arcOuterRadius = arcInnerRadius + arcWidth;
  
  var arc = d3.arc()
    .innerRadius(arcInnerRadius)
    .outerRadius(arcOuterRadius)
    .startAngle(function(d) { return d.st; })
    .endAngle(function(d) { return d.et; });
    
  var leafGroups = d3.nest()
    .key(function(d) { return d.parent.data.name.split(".")[1]; })
    .entries(root.leaves())
    
  var arcAngles = leafGroups.map(function(group) {
    return {
      name: group.key,
      min: d3.min(group.values, function(d) { return d.x }),
      max: d3.max(group.values, function(d) { return d.x })
    }
  });
    
  svg
    .selectAll(".groupArc")
    .data(arcAngles)
    .enter()
    .append("path")
    .attr("id", function(d, i) { return`arc_${i}`; })
    .attr("d", function(d) { return arc({ st: d.min * Math.PI / 180, et: d.max * Math.PI / 180}) }) // note use of arcWidth
    .attr("fill", "steelblue");
    
  svg
    .selectAll(".arcLabel")
    .data(arcAngles)
    .enter()
    .append("text")
    .attr("x", 5) //Move the text from the start angle of the arc
    .attr("dy", (d) => ((arcOuterRadius - arcInnerRadius) * 0.8)) //Move the text down
    .append("textPath")
    .attr("class", "arcLabel")
    .attr("xlink:href", (d, i) => `#arc_${i}`)
    .text((d, i) => d.name)
    .style("font", `300 14px "Helvetica Neue", Helvetica, Arial, sans-serif`)
    .style("fill", "#fff");

  // ----------------

  link = link
    .data(packageImports(root.leaves()))
    .enter().append("path")
      .each(function(d) { d.source = d[0], d.target = d[d.length - 1]; })
      .attr("class", "link")
      .attr("d", line);

  node = node
    .data(root.leaves())
    .enter().append("text")
      .attr("class", "node")
      .attr("dy", "0.31em")
      .attr("transform", function(d) { return "rotate(" + (d.x - 90) + ")translate(" + (d.y + 8 + arcWidth) + ",0)" + (d.x < 180 ? "" : "rotate(180)"); })
      .attr("text-anchor", function(d) { return d.x < 180 ? "start" : "end"; })
      .text(function(d) { return d.data.key; })
      .on("mouseover", mouseovered)
      .on("mouseout", mouseouted);

  function mouseovered(d) {
    node
        .each(function(n) { n.target = n.source = false; });

    link
        .classed("link--target", function(l) { if (l.target === d) return l.source.source = true; })
        .classed("link--source", function(l) { if (l.source === d) return l.target.target = true; })
      .filter(function(l) { return l.target === d || l.source === d; })
        .raise();

    node
        .classed("node--target", function(n) { return n.target; })
        .classed("node--source", function(n) { return n.source; });
  }

  function mouseouted(d) {
    link
        .classed("link--target", false)
        .classed("link--source", false);

    node
        .classed("node--target", false)
        .classed("node--source", false);
  }

  // Lazily construct the package hierarchy from class names.
  function packageHierarchy(classes) {
    var map = {};

    function find(name, data) {
      var node = map[name], i;
      if (!node) {
        node = map[name] = data || {name: name, children: []};
        if (name.length) {
          node.parent = find(name.substring(0, i = name.lastIndexOf(".")));
          node.parent.children.push(node);
          node.key = name.substring(i + 1);
        }
      }
      return node;
    }

    classes.forEach(function(d) {
      find(d.name, d);
    });

    return d3.hierarchy(map[""]);
  }

  // Return a list of imports for the given array of nodes.
  function packageImports(nodes) {
    var map = {},
        imports = [];

    // Compute a map from name to node.
    nodes.forEach(function(d) {
      map[d.data.name] = d;
    });

    // For each import, construct a link from the source to target node.
    nodes.forEach(function(d) {
      if (d.data.imports) d.data.imports.forEach(function(i) {
        imports.push(map[d.data.name].path(map[i]));
      });
    });

    return imports;
  }


}
.node {
  font: 300 11px "Helvetica Neue", Helvetica, Arial, sans-serif;
  fill: #bbb;
}

.node:hover {
  fill: #000;
}

.link {
  stroke: steelblue;
  stroke-opacity: 0.4;
  fill: none;
  pointer-events: none;
}

.node:hover,
.node--source,
.node--target {
  font-weight: 700;
}

.node--source {
  fill: #2ca02c;
}

.node--target {
  fill: #d62728;
}

.link--source,
.link--target {
  stroke-opacity: 1;
  stroke-width: 2px;
}

.link--source {
  stroke: #d62728;
}

.link--target {
  stroke: #2ca02c;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.13.0/d3.min.js"></script>

您可以看到添加用于绘制和标记圆弧的离散代码块 - 计算圆弧生成器的起始角度和结束角度的关键位是:

  var leafGroups = d3.nest()
    .key(function(d) { return d.parent.data.name.split(".")[1]; })
    .entries(root.leaves())
    
  var arcAngles = leafGroups.map(function(group) {
    return {
      name: group.key,
      min: d3.min(group.values, function(d) { return d.x }),
      max: d3.max(group.values, function(d) { return d.x })
    }
  });

For leafGroups,嵌套函数通过键的第二项对层次结构的叶子进行分组,例如flare.analytics.cluster = analytics and flare.vis.operator.distortion = vis。这里有一个针对不同数据集的选择,您需要考虑一下,例如如果叶子始终处于一致的深度;标签总是独一无二的。定义“父组”可以是自上而下或自下而上的定义。

For arcAngles,您只需要每组的最小值和最大值,然后您可以继续绘制弧并标记它们。我取消了一些标签here https://www.visualcinnamon.com/2015/09/placing-text-on-arcs/这是一篇关于在 d3 中标记弧的精彩文章。您需要再次考虑一下这一点,因为如果标签对于弧来说太长,它看起来不太好 - 请参阅示例中的“显示”标签。

另一个变化在这里:

  node = node
    .data(root.leaves())
    .enter().append("text")
      .attr("class", "node")
      .attr("dy", "0.31em")
      .attr("transform", function(d) { return "rotate(" + (d.x - 90) + ")translate(" + (d.y + 8 + arcWidth) + ",0)" + (d.x < 180 ? "" : "rotate(180)"); })
      .attr("text-anchor", function(d) { return d.x < 180 ? "start" : "end"; })
      .text(function(d) { return d.data.key; })
      .on("mouseover", mouseovered)
      .on("mouseout", mouseouted);

注意到你需要添加arcWidth当设置transform属性 - 这会将节点标签向外移动以容纳弧。

V6+解决方案

这里有一个更新版本的分层边缘捆绑可观察总部 https://observablehq.com/@d3/hierarchical-edge-bundling使用 d3 v6 的页面(也是由 Mike Bostok 编写)。我们可以添加类似的代码来识别组,获取角度的最小/最大,并将标签向外推一点以容纳弧。

const flare = "https://gist.githubusercontent.com/robinmackenzie/d01d286d9ac16b474a2a43088c137d00/raw/c53c1eda18cc21636ae52dfffa3e030295916c98/flare.json";
const colorin = "#00f";
const colorout = "#f00";
const colornone = "#ccc";
const width = 960;
const radius = width / 2;

d3.json(flare).then(json => render(json));

function render(data) {

  const line = d3.lineRadial()
    .curve(d3.curveBundle.beta(0.85))
    .radius(d => d.y)
    .angle(d => d.x);

  const tree = d3.cluster()
    .size([2 * Math.PI, radius - 100]);

  const root = tree(bilink(d3.hierarchy(hierarchy(data))
    .sort((a, b) => d3.ascending(a.height, b.height) || d3.ascending(a.data.name, b.data.name))));

  const svg = d3.select("body")
    .append("svg")
    .attr("width", width)
    .attr("height", width)
    .append("g")
    .attr("transform", `translate(${radius},${radius})`);

  // NEW CODE BELOW ----------------------------------------
  // add arcs with labels
  const arcInnerRadius = radius - 100;
  const arcWidth = 30;
  const arcOuterRadius = arcInnerRadius + arcWidth;
  const arc = d3
    .arc()
    .innerRadius(arcInnerRadius)
    .outerRadius(arcOuterRadius)
    .startAngle((d) => d.start)
    .endAngle((d) => d.end);

  const leafGroups = d3.groups(root.leaves(), d => d.parent.data.name);
  const arcAngles = leafGroups.map(g => ({
    name: g[0],
    start: d3.min(g[1], d => d.x),
    end: d3.max(g[1], d => d.x)
  }));

  svg
    .selectAll(".arc")
    .data(arcAngles)
    .enter()
    .append("path")
    .attr("id", (d, i) => `arc_${i}`)
    .attr("d", (d) => arc({start: d.start, end: d.end}))
    .attr("fill", "blue")
    .attr("stroke", "blue");
  svg
    .selectAll(".arcLabel")
    .data(arcAngles) 
    .enter()
    .append("text")
    .attr("x", 5) //Move the text from the start angle of the arc
    .attr("dy", (d) => ((arcOuterRadius - arcInnerRadius) * 0.8)) //Move the text down
    .append("textPath")
    .attr("class", "arcLabel")
    .attr("xlink:href", (d, i) => `#arc_${i}`)
    .text((d, i) => ((d.end - d.start) < (6 * Math.PI / 180)) ? "" : d.name); // 6 degrees min arc length for label to apply
    
  // --------------------------------------------------------



  // add nodes
  const node = svg.append("g")
      .attr("font-family", "sans-serif")
      .attr("font-size", 10)
    .selectAll("g")
    .data(root.leaves())
    .join("g")
      .attr("transform", d => `rotate(${d.x * 180 / Math.PI - 90}) translate(${d.y}, 0)`)
    .append("text")
      .attr("dy", "0.31em")
      .attr("x", d => d.x < Math.PI ? (arcWidth + 5) : (arcWidth + 5) * -1) // note use of arcWidth
      .attr("text-anchor", d => d.x < Math.PI ? "start" : "end")
      .attr("transform", d => d.x >= Math.PI ? "rotate(180)" : null)
      .text(d => d.data.name)
      .each(function(d) { d.text = this; })
      .on("mouseover", overed)
      .on("mouseout", outed)
      .call(text => text.append("title").text(d => `${id(d)} ${d.outgoing.length} outgoing ${d.incoming.length} incoming`));

  // add edges
  const link = svg.append("g")
      .attr("stroke", colornone)
      .attr("fill", "none")
    .selectAll("path")
    .data(root.leaves().flatMap(leaf => leaf.outgoing))
    .join("path")
      .style("mix-blend-mode", "multiply")
      .attr("d", ([i, o]) => line(i.path(o)))
      .each(function(d) { d.path = this; });

  function overed(event, d) {
    link.style("mix-blend-mode", null);
    d3.select(this).attr("font-weight", "bold");
    d3.selectAll(d.incoming.map(d => d.path)).attr("stroke", colorin).raise();
    d3.selectAll(d.incoming.map(([d]) => d.text)).attr("fill", colorin).attr("font-weight", "bold");
    d3.selectAll(d.outgoing.map(d => d.path)).attr("stroke", colorout).raise();
    d3.selectAll(d.outgoing.map(([, d]) => d.text)).attr("fill", colorout).attr("font-weight", "bold");
  }

  function outed(event, d) {
    link.style("mix-blend-mode", "multiply");
    d3.select(this).attr("font-weight", null);
    d3.selectAll(d.incoming.map(d => d.path)).attr("stroke", null);
    d3.selectAll(d.incoming.map(([d]) => d.text)).attr("fill", null).attr("font-weight", null);
    d3.selectAll(d.outgoing.map(d => d.path)).attr("stroke", null);
    d3.selectAll(d.outgoing.map(([, d]) => d.text)).attr("fill", null).attr("font-weight", null);
  }  

  function id(node) {
    return `${node.parent ? id(node.parent) + "." : ""}${node.data.name}`;
  }

  function bilink(root) {
    const map = new Map(root.leaves().map(d => [id(d), d]));
    for (const d of root.leaves()) d.incoming = [], d.outgoing = d.data.imports.map(i => [d, map.get(i)]);
    for (const d of root.leaves()) for (const o of d.outgoing) o[1].incoming.push(o);
    return root;
  }

  function hierarchy(data, delimiter = ".") {
    let root;
    const map = new Map;
    data.forEach(function find(data) {
      const {name} = data;
      if (map.has(name)) return map.get(name);
      const i = name.lastIndexOf(delimiter);
      map.set(name, data);
      if (i >= 0) {
        find({name: name.substring(0, i), children: []}).children.push(data);
        data.name = name.substring(i + 1);
      } else {
        root = data;
      }
      return data;
    });
    return root;
  }
  
}
.node {
  font: 300 11px "Helvetica Neue", Helvetica, Arial, sans-serif;
  fill: #fff;
}

.arcLabel {
  font: 300 14px "Helvetica Neue", Helvetica, Arial, sans-serif;
  fill: #fff;
}

.node:hover {
  fill: #000;
}

.link {
  stroke: steelblue;
  stroke-opacity: 0.4;
  fill: none;
  pointer-events: none;
}

.node:hover,
.node--source,
.node--target {
  font-weight: 700;
}

.node--source {
  fill: #2ca02c;
}

.node--target {
  fill: #d62728;
}

.link--source,
.link--target {
  stroke-opacity: 1;
  stroke-width: 2px;
}

.link--source {
  stroke: #d62728;
}

.link--target {
  stroke: #2ca02c;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/6.0.0/d3.min.js"></script>

需要注意的一些差异:

  • The hierarchy功能不同于packageHierarchy原始块中的函数 - 似乎我们不再拥有层次结构的完整路径,因此存在歧义flare.vis.data.EdgeSprite vs flare.data.DataField即,两个叶可以在层次结构的不同分支中具有相同的“父级”。
  • 我已经修复了输入以适应这一点,但它改变了“父组”的识别方式,即原始版本中的自下而上与自上而下。
  • nest已经消失了,所以你可以使用groups instead
  • v4 似乎有以度为单位的角度定义的对象,但在 v6 中它们以弧度为单位 - 所以你会看到一些* Math.PI / 180在 v4 版本中,而不是在 v6 版本中 - 但它只是度数/弧度转换。
  • 对于长标签,我使用一个阈值,使得弧长必须至少为 6 度,否则标签将不会放置(.text((d, i) => ((d.end - d.start) < (6 * Math.PI / 180)) ? "" : d.name);)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

分层边缘捆绑:添加父组标签 的相关文章

  • 在响应式设计中将顶部元素移动到底部的最佳方法是什么

    我有以下 HTML 格式 将给定元素放置在桌面上的顶部和移动设备上的底部 宽度 p I am on the top of desktop page and bottom of mobile page p 以响应式方式重新排序未知高度的元素最
  • 无法读取未定义错误的属性“匹配”

    我试图在 React JS 前端显示一些文本来代替个人资料图像 当它不可用时 基本上 我将当前客户名称传递给一个函数 该函数提取名称中所有单词的第一个字符 我能够仅显示名称 但是当我执行函数调用时 出现 无法读取未定义的属性 匹配 错误 并
  • 更改模板标签 <# {% {{ 等后,John Resig 的微模板出现语法错误

    我在使用 John Resig 的 Micro 模板时遇到了一些麻烦 谁能帮我解释为什么它不起作用 这是模板 以及发动机的改装部分 str replace r t n g split join t replace gt t g 1 r re
  • webpack 加载器并包含

    我是 webpack 的新手 我正在尝试了解加载器及其属性 例如测试 加载器 包含等 这是我在 google 中找到的 webpack config js 的示例片段 module loaders test js loader babel
  • jQuery 提交未触发

    我觉得问这个很愚蠢 但为什么我的 submit 没有发出警报 HTML div class buttonbar style margin left 10 div
  • 在 Jest 测试中设置时刻时区

    我有 util 函数 它以特定的日期格式解析给定的日期 即 2019 01 28 然后使用momentJS检索当天的开始并将其转换为 ISO 日期格式 dates js import moment from moment export co
  • 使用 jQuery animate 时,有没有办法隐藏 webkit 浏览器中显示的工件?

    我正在使用 jQuery animate 在网页上的项目中滑动 由于某种原因 只有在 webkit 浏览器中 元素动画的空间中才会出现伪影痕迹 有没有办法阻止或隐藏这种情况 一旦您加载此处的页面 它们就会出现在轮播上 http www my
  • 如何使用jsPDF设置图像以适合页面宽度?

    有什么办法可以解决这个问题吗 我尝试以毫米为单位设置宽度和高度 如何将其设置为全角 您可以获取 PDF 文档的宽度和高度 如下所示 var doc new jsPDF p mm a4 var width doc internal pageS
  • 在浏览器中打开的 .mhtml 文件中填写输入

    我想对 mhtml 文件运行 e2e 测试 即填写表格 在 mhtml 文件上查看和提取数据效果非常好 但我无法填写任何内容input字段 既不是手动也不是通过木偶操作者 你可以用这个试试 mhtml 文件 https gist githu
  • HTML 中按钮内的图标

    我需要在 HTML 中将小图标放在按钮内 例如 我需要在我的网站上有 facebook 按钮 在按钮内首先是 F 图标 然后是 facebook 怎么做
  • Javascript 警报/消息框中的欧元符号或其他实体

    有谁知道我如何在 javascript 警报窗口中显示欧元或其他 html 实体 alert u20AC HTML 实体字符查找 http leftlogic com lounge articles entity lookup
  • ES6 模板文字可以在运行时替换(或重用)吗?

    tl dr 是否可以制作可重用的模板文字 我一直在尝试使用模板文字 但我想我就是不明白 现在我感到沮丧 我的意思是 我想我明白了 但 它 不应该是它的运作方式 或者它应该如何实现 它应该变得不同 我看到的所有示例 甚至标记模板 都要求 替换
  • AngularJS 中的嵌套模块

    我有 2 个不同的 AngularJs 模块 一个 widgetContainer 和一个 widget 小部件可以显示为独立的应用程序 也可以包含在小部件容器中 一个 widgetContainer 包含 0 N 个 widget 如果我
  • 为什么行框之间有空格,而不是由于半行距?

    在下面的代码示例中 您将看到垂直流动的之间有空白spans是 每个之间有空白line box 我想首先声明这与之间的差距无关inline block框 甚至是结果半领先 https www w3 org TR CSS21 visudet h
  • jQuery 更改为隐藏字段后触发重力表单中的表单更新

    简而言之 是否有 JavaScript 函数或挂钩来触发重力形式的更新 以便执行条件逻辑 原问题 我正在使用重力形式 并且创建了一个 变化时 事件 gform 1 find gfield date dropdown month select
  • 图像未显示在从 HTML 创建的 PDF 上

    我想动态创建 PDF 这意味着我将从 Google Drive 获取文件 然后将它们放入 HTML 代码中 并尝试从中创建 PDF 一切工作正常 除了图像没有显示 我现在正在做的是 从 HTML 字符串创建 HtmlOutput 获取该 H
  • KML 中的 JavaScript 被 Google 地球插件忽略

    我创建了一个简单的 KML 文件 该文件可以在独立的 Google 地球客户端中运行 但在 Google 地球插件中根本无法运行 无论浏览器如何
  • Nodejs 解码 base64 并使用流将它们保存到文件中

    在我的node js应用程序中 我使用以下代码行解码base64编码的图像 const fileDataDecoded Buffer from base64EncodedfileData base64 到目前为止 我可以使用以下代码编写一个
  • 仅使用 javascript 获取网站的正文元素

    我想检索以下网站的正文内容http sports espn go com nhl bottomline scores nhl s left1 http sports espn go com nhl bottomline scores nhl
  • ReactJS setState 仅在嵌套在 setState 中时才有效

    问题 当我使用 this setState 并在回调中输出状态时 它根本不会改变 但是当我将 setstate 嵌套在 setstate 中时 它将正常工作 例子 这不行 this setState data newData 这确实有效 t

随机推荐

  • 获取 Bash 和 KornShell (ksh) 中命令的退出代码

    我想写这样的代码 command some command safeRunCommand command safeRunCommand cmnd 1 cmnd if 0 then printf Error when executing co
  • 如何使用相机谷歌地图 xcode 移动标记(图钉)

    我在我的应用程序中使用谷歌地图 API 我的应用程序中有两个按钮 第一个按钮在我的地图中添加一个标记 图钉 现在我想要第二个按钮将添加的图钉水平移动到页面中心 并使其移动到页面顶部的 25 我希望相机 用户正在查看的区域 也移动它 这是我的
  • 使用 python 从 XSD 文件创建特定的 XML 文件

    我有一个现有的 xsd 架构 并且需要创建 希望使用 Python 带有一些特定输入的 XML 文件 最好的方法是什么 我尝试了 Element Tree 和 xmlschema 但我无法判断它们是否允许从已知的 XSD 架构开始生成 XM
  • 您应该通过属性访问同一类中的变量吗?

    如果您有一个获取和设置实例变量的属性 那么通常您总是使用该类外部的属性来访问它 我的问题是你也应该在课堂上这样做吗 如果有的话 我总是使用该属性 即使是在班级内 但我想听到一些支持和反对的论据 以确定哪个是最正确的以及为什么 或者这只是项目
  • 使 HTML5 视频海报与视频本身大小相同

    有谁知道如何调整 HTML5 视频海报的大小 使其适合视频本身的确切尺寸 这是一个显示问题的 jsfiddle http jsfiddle net zPacg 7 http jsfiddle net zPacg 7 这是代码 HTML
  • Console.ReadLine() 末尾没有换行符?

    问题很简单 当我使用 Console ReadLine 控制台上打印的下一个内容将在下一行 有什么办法可以继续打印该行吗 提前致谢 请检查 控制台 Read 这不会导致新行或换行
  • MySQL 监听通知等效项

    是否有相当于 PostgresQL 的notify http www postgresql org docs 9 1 static sql notify html and listen http www postgresql org doc
  • 如何在 C# 中将 IEnumerable 转换为 Enum?

    我已将多个字符串解析为枚举标志 但看不到将它们合并为单个枚举位字段的巧妙方法 我使用的方法循环遍历字符串值 然后 将值转换为 Enum 对象 如下所示 Flags public enum MyEnum None 0 First 1 Seco
  • Spring - 使用 new 是一种不好的做法吗?

    正在创建对象by hand 即使用new操作员而不是注册Springbean 和使用依赖注入被认为是不好的做法吗 我的意思是 确实Spring IoC容器必须了解应用程序中的所有对象吗 如果是这样 为什么 你希望 Spring 创建 bea
  • dask groupby 不合并分区

    我有一组数据 我想要对其进行一些简单的 groupby count 操作 但我似乎无法使用 dask 来完成此操作 我很可能不理解 dask 中执行 groupby reduce 的方式 特别是当索引位于分组键中时 所以我将用玩具数据来说明
  • 当父类也实现 IDisposable 时,在子类上实现 IDisposable

    我有一个父类和子类都需要实现IDisposable 应该在哪里virtual and base Dispose 通话发挥作用 当我刚刚覆盖Dispose bool disposing 打电话 说我实现了感觉真的很奇怪IDisposable没
  • PyCharm 虚拟环境和 Anaconda 环境有什么区别?

    当我在 PyCharm 中创建新项目时 它会创建一个新的虚拟环境 我读到 当我执行Python脚本时 它们是使用此环境中的解释器而不是系统环境来执行的 因此 如果我需要安装一些软件包 我只能将它们安装在这个环境中 而不是在系统环境中 这很酷
  • 绘图 Deedle 框架

    我有以下代码 let mychart frame GetAllSeries gt Seq iter fun key value gt Chart Line value Name key gt Chart Combine where fram
  • 如何使用 haproxy 负载均衡器 Kafka Bootstrap?

    我有一个 kafka 集群 由 3 台在 AWS 上运行的机器组成 卡夫卡1到卡夫卡3 我正在使用新型卡夫卡消费者 gt 0 8 我知道kafka客户端连接到其中一台kafka服务器 获取服务器元数据 然后直接连接到代理 我想确保在代理发生
  • 执行aapt失败

    请帮忙解决这个错误 Failed to execute aapt com android ide common process ProcessException Failed to execute aapt at com android b
  • Hibernate 在更新集合时删除孤儿

    我发现从 Hibernate 中的集合中删除时 孤立记录不会被删除 我一定是做了一些简单的错误 这是 Hibernate 101 但我找不到它 鉴于以下情况 public class Book ManyToOne NotNull Autho
  • Javascript Replace() 仅替换第一个匹配项[重复]

    这个问题已经存在了 你好 请参阅这里的 jsfiddle http jsfiddle net moolood jU9QY http jsfiddle net moolood jU9QY var toto bien address 1 bie
  • 在 Java 中从 Json 字符串中提取字段

    我正在尝试从以下 Json 字符串中提取每个 company id 的 id String test company id 4100 data drm user id 572901936637129135 direct status id
  • 什么是window.onpaint?

    有人推荐here https stackoverflow com questions 6944037 how to run java script code before page load that window onpaint用于在页面
  • 分层边缘捆绑:添加父组标签

    我对 HTML 和 JavaScript 还很陌生 我面临着著名的分层边缘捆绑可用here https bl ocks org mbostock 7607999 由 D3 js 库生成 My goal is to add a semi ci