【问题标题】:How to limit the width/height of svg in pygal如何在pygal中限制svg的宽度/高度
【发布时间】:2015-01-11 00:48:39
【问题描述】:

如何限制pygal 生成的 SVG 的宽度/高度?我目前是通过img标签来做的,但是有没有更好的方法?

<img src="http://localhost/images/Store.Diapers.svg" width=800 height=600/>

【问题讨论】:

    标签: python pygal


    【解决方案1】:

    如果对某人有帮助,只需在参数中指定 width=1000, height=800 即可:

    chart = pygal.StackedLine(width=1000, height=800)
    

    【讨论】:

      【解决方案2】:

      您可以为此使用 div....

      将以下内容放入您的代码中:

      <div class="parent">    
         <img src="http://localhost/images/Store.Diapers.svg">    
      </div>    
      

      并将其放入您的 .css 文件中

      .imagebox {
      width: 42px; /*This is the height of the div class it self */
      height: 42px;
      }
      
      /* This changes the height of any image with the <img> tag within the div class*/
      .imagebox img {
      height: 800px;
      width: 600px;
      }
      

      【讨论】:

      • 感谢 Matthijs,它基本上完成了同样的事情。我正在寻找 pygal 原生的非 css/html 解决方案。
      • 但是你为什么不想使用 CSS/HTML?
      • 对于我自己的表示层,我通常更喜欢带有 html 的原生解决方案,所以我会在必要时使用它。所以我对以太的问题。
      猜你喜欢
      • 2021-04-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-02
      • 1970-01-01
      • 2017-12-26
      • 2016-06-15
      • 2013-04-25
      相关资源
      最近更新 更多