【问题标题】:Making a pie chart bigger without affecting the doughnut chart在不影响圆环图的情况下使饼图更大
【发布时间】:2017-01-12 07:35:10
【问题描述】:

我正在使用canvasjs 制作饼图和圆环图。

我在圆环图中有饼图。我在 CSS 方面不是那么好。这里的饼图位于中心,但它仍然非常小。我不知道如何让它变大,因为如果我试图让它变大,它会弄乱饼图。

有什么办法可以让饼图变大,这样饼图和圆环图之间就没有太多空间了。

我在这里张贴我的结果图片。

我正在使用这些属性:

甜甜圈

 width="100%" height="250px" top="0px" position="absolute" backgroundColor="transparent" uniqueID ="doughnut"

饼图

width="78px" height="100px" top="75px" position="absolute" left="560px"  backgroundColor="transparent" uniqueID=”pie”

编辑:如果我增加饼图的高度和宽度导致 -

当我将背景颜色设置为透明时,为什么会出现空白??

这是我的饼图属性-

                   type: "pie",
                   backgroundColor: "transparent",
                   indexLabelFontColor: "white",
                   indexLabelFontSize: "14px",
                   markerType: "circle",
                   radius : "100%",
                   innerRadius :"200px",

我想要这样的东西-

【问题讨论】:

    标签: html css canvasjs


    【解决方案1】:

    由于容器的高度和宽度,您可能会得到更小的饼图。因为 CanvasJS 图表使用容器的高度和宽度来确定图表的高度。

    width="78px" height="100px" top="75px" position="absolute" left="560px"  backgroundColor="transparent" uniqueID=”pie”
    

    尝试在上面给出的语句中改变高度和宽度,以查看变化并根据您的要求获得适当大小的饼图。
    您还应该根据包含饼图的容器的 heightwidth 来改变 topleft。 p>

    【讨论】:

    • 我已经尝试过了,但是由于增加了高度和宽度,它的 div 与甜甜圈的内圈重叠,结果在甜甜圈上添加了一些空白......尽管我已将背景颜色设置为透明。 .查看我编辑的图片
    • 在图表中将 backgroundColor 设置为 transparent,而不是在 div 中更改它。看看这个链接:jsfiddle.net/m95jjzx5/2
    • 甜甜圈上的空白区域还在吗?
    • 看看这个链接:jsfiddle.net/m95jjzx5/4饼图没有白色背景,它也是响应式的。
    • 而且 backgroundColor 不应该在数据中。它应该直接保存在图表选项中。
    【解决方案2】:

    尝试使用这种布局:

    <div class="parent">
      <div class="doughnut"></div>
      <div class="pie"></div>
    </div>
    

    并应用此 CSS:

    .parent {
      position: relative;
    }
    
    .doughnut, .pie {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
    }
    

    【讨论】:

    • 不,它现在不工作,只有饼图出现]
    • Opps,有一个类型,再试一次。
    • 但是你改变了什么?
    • position: absolute:更改为position: absolute;
    • 好的,你能发布你的 html 和 CSS 吗?
    【解决方案3】:

    我能够弄清楚如何做到这一点-

    我正在使用这些属性

    #parent {
      position: relative;
    }
    
    #doughnutContainer, #pieContainer {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%);
    }
    #doughnutContainer {
      width:800px;
      height:250px;
    }
    #pieContainer {
      transform: translate(-50%, 28%);
      width:200px; 
      height:160px;
    }
    

    【讨论】:

    • @VishwasR 我编辑了问题,请检查我想要这样的图像
    • @shv22 请不要继续编辑相同的问题,因为这可能会使其他用户感到困惑。
    • @Beevk 我只是在为 canvasjs 论坛的人更新问题,因为我无法在那里上传图片,而且我已经回答了我的问题......
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-13
    • 2021-01-17
    • 1970-01-01
    • 1970-01-01
    • 2016-04-18
    • 2014-03-13
    相关资源
    最近更新 更多