退出 svg 时图像被裁剪

Image is cropped when exiting the svg

我正在将图片放在栏的顶部。但是具有最高值的条的图像被剪切了。我该怎么做才能放大图形或者我该怎么做才能不裁剪图像。

(我对svg不是很熟练,d3.js) https://jsfiddle.net/htyu6uLo/

   var aColoresChart=["#5DD255","#D4D4D4","#EA4335"];
    var chart = c3.generate({
      bindto: '#chart',
      data: {
          columns: [
                [1,5,6,7]
          ],
          color: function(color, d) {
             return aColoresChart[d.index];
          },
          type: 'bar',
          labels: true, //to display the labels in the bar chart
          bar: {
                width: {
                    ratio: 0.5 // this makes bar width 50% of length between ticks
                }
          }
      },
      size: {
                height: 235
            },
            bar: {
                width: 35
            },
            padding: {
                left: 40
            },
          tooltip: {
            show: false
          },
          legend: {
            show: false
          },
          axis: {
          x: {
              type: 'category',
              categories: ['one','two', 'three']
          },
          y:{
            tick: {
              format: d3.format('f'),
              count:7
            }
          }
      },
  });


  d3.selectAll('#chart .c3-texts text.c3-text')
    .each(function(d,i){

      var barposition= d3.select(this);
      d3.select('#chart .c3-texts').append('image')
        .attr("xlink:href", 'https://image.freepik.com/free-icon/happy-emoticon_318-40206.jpg')
        .attr("x", function(){ return barposition.attr('x')-20; } )
        .attr("y", function(){ return barposition.attr('y')-47; })
        .attr('text-anchor','middle')
        .attr('class','topimage')
        .attr("width", 50)
        .attr("height", 50);
  });

max中轴

在您的情况下,数据: columns: [ [1,5,6,7] //here 7 is max ],

因此,如果您在

中给出最多 10 个
   y:{
        max: 10,//give it a higher max number than the data max we have.
        tick: {
          format: d3.format('f'),
          count:7
        }
      }

工作样本here