Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

309
Views
¿Cómo mostrar múltiples valores en el gráfico d3 sunburst?

Estoy probando un gráfico de rayos solares usando d3 (V4) y Vue2 para mostrar los valores de Ventas, Prominencia, Goly% en un solo gráfico.

bolígrafo de trabajo.

aquí está mi JSON

 { name: "root", children: [{ name: "product1", children: [{ name: "zone1", size: 45632, salience: 200, goly: 10, }, { name: "zone2", size: 986413, salience: 100, goly: 20, }, ], }, { name: "product2", children: [{ name: "zone1", size: 54752, salience: 250, goly: 15, }, { name: "zone2", size: 973542, salience: 170, goly: 18, }, ], }, { name: "product3", children: [{ name: "zone1", size: 671378, salience: 378, goly: 35, }, { name: "zone2", size: 12345, salience: 615, goly: 26, }, ], }, ] };

el tamaño en json anterior denota valor de ventas.

Intenté usar eachBefore como se menciona aquí

 root["salience"] = 1; root.eachBefore(d => { if (d.parent) { let parent_salience = d.parent.salience; if (parent_salience === NaN) parent_salience = 0; d.salience = d.data.salience + parent_salience; }; });

pero tampoco funcionó.

incluso traté de alterar el código fuente de la función de suma

 Node.prototype = hierarchy.prototype = { constructor: Node, count: node_count, each: node_each, eachAfter: node_eachAfter, eachBefore: node_eachBefore, sum: node_sum, sum2: node_sum2, /* altered here */ sort: node_sort, path: node_path, ancestors: node_ancestors, descendants: node_descendants, leaves: node_leaves, links: node_links, copy: node_copy }; function node_sum2(value) { return this.eachAfter(function(node) { var obj = value(node.data); var sum = +obj.sales || 0, salience = +obj.salience || 0, goly = +obj.goly || 0, children = node.children, _children = node.data.children, i = children && children.length; while (--i >= 0) { sum += children[i].value; salience += children[i].salience; goly += children[i].goly; } node.value = sum; node.salience = salience; node.goly = goly; }); }

pero obtengo el mismo resultado incluso si uso d3.sum2() en lugar de d3.sum

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!