简体   繁体   English

我如何摆脱这种不必要的种植?

[英]How do I get rid of this unwanted cropping?

I have a chart created using the amCharts library. 我有一个使用amCharts库创建的图表。 But I face an unwanted crop in the image which is on top of each bar when it goes too high, as I've highlighted here: 但是,当图像过高时,我会在每个小节上方的图像中看到多余的裁切,如下所示:

Please help I don't want to have that cropping. 请帮我不要。

Here is the CSS code: 这是CSS代码:


    #chartdiv {
      width: 100%;
      height: 500px;
      padding: 70px 0;
      border: 3px solid green;
    }

    body {  
      margin: 0 0 0 0;
      overflow:hidden;
      background-color: transparent;
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    }

And here is the last part of JavaScript code: 这是JavaScript代码的最后一部分:


    // Add bullets
    var bullet = series.bullets.push(new am4charts.Bullet());
    var image = bullet.createChild(am4core.Image);
    image.width = 150;
    image.height = 150;
    image.horizontalCenter = "middle";
    image.verticalCenter = "bottom";
    image.dy = 80;
    image.y = am4core.percent(100);
    image.propertyFields.href = "bullet";
    image.tooltipText = series.columns.template.tooltipText;
    image.propertyFields.fill = "color";
    image.filters.push(new am4core.DropShadowFilter());

EDIT: 编辑:

When I add zoom: 0.5; 当我添加zoom: 0.5; to the chartdiv CSS code this happens: 到chartdiv CSS代码会发生这种情况:

The bullets you created are not calculated in the reserved rendered area for your chart. 您创建的项目符号不会在图表的保留渲染区域中计算。 The bullets in your chart are very large, so they are cropped at the top. 图表中的项目符号很大,因此在顶部被裁剪。 If you set paddingTop on your chart it should solve your issue. 如果您在图表上设置paddingTop ,它应该可以解决您的问题。

chart.paddingTop = 50;

I created this code pen from the official amcharts demos and added your bullet configuration. 我是从官方amcharts演示创建此笔的 ,并添加了您的项目符号配置。

Try putting: 尝试放入:

z-index:5;

into the 'chartdiv' id in CSS. 放入CSS中的“ chartdiv” ID。 This is happenning because there is something that is on top of the image at the top. 之所以发生这种情况,是因为图像的顶部位于顶部。 The z-index function, will ensure that the chartdiv is on top of anything else. z-index函数将确保chartdiv位于其他任何东西之上。 If it doesn't work, try increasing the z-index value. 如果不起作用,请尝试增加z-index值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM