Preventing overlap of text in D3 pie chart

后端 未结 2 1363
别跟我提以往
别跟我提以往 2020-12-19 05:04

I\'ve been googling around, but I can\'t seem to grasp this.

My situation is that the countries overlap when presented on the pie chart:

This is an example

2条回答
  •  温柔的废话
    2020-12-19 05:39

    One more solution would be to change the order of the data with the USA being first. You might find the angle of the pie layout to be more readable.

    var data_values = [48, 1, 1, 1, 1, 1, 1, 4];
    var titles = ["USA","Pakistan", "Israel", "Netherlands", "Italy", "Uruguay",       "United Kingdom", "Austria", "China"]
    

    http://jsfiddle.net/rocky1616/oLzsrd4o/

    Musically_ut's solution would work nicely here as well. You can even take the angle down a bit if that worked in your design.

      var getAngle = function (d) {
          return (180 / Math.PI * (d.startAngle + d.endAngle) / 2 + 45);
      };
    

    http://jsfiddle.net/2uT7F/26/

    You would need to create a if else block to take care of the USA item but this is a start if it helps.

提交回复
热议问题