小编Hid*_*lak的帖子

D3js分组散点图,无碰撞

我正在使用此示例制作散点图:

https://www.d3-graph-gallery.com/graph/boxplot_show_individual_points.html

现在,此示例使用抖动将点的x位置随机化,以进行演示,但我的目标是以这种方式制作这些点,以使它们不会发生碰撞,并且在发生碰撞时位于同一行。

我试图做的(视觉上)最好的例子是某种蜂拥而至的方式,在这种提琴中表示数据:

https://jsfiddle.net/n444k759/4/

第一个示例的片段:

// set the dimensions and margins of the graph
var margin = {top: 10, right: 30, bottom: 30, left: 40},
    width = 460 - margin.left - margin.right,
    height = 400 - margin.top - margin.bottom;

// append the svg object to the body of the page
var svg = d3.select("#my_dataviz")
  .append("svg")
    .attr("width", width + margin.left + margin.right)
    .attr("height", height + margin.top + margin.bottom)
  .append("g")
    .attr("transform",
          "translate(" + margin.left + "," + margin.top + ")");

// …
Run Code Online (Sandbox Code Playgroud)

javascript d3.js

7
推荐指数
1
解决办法
336
查看次数

标签 统计

d3.js ×1

javascript ×1