【问题标题】:x-axis label is cropped when SVG is converted to image D3.js将 SVG 转换为图像 D3.js 时裁剪 x 轴标签
【发布时间】:2016-11-09 23:29:10
【问题描述】:

我正在使用 C3.js 生成折线图。创建 SVG 后,我将使用画布将其转换为 .png 图像。

一切正常,但 x 轴名称是从图像中裁剪出来的。我给画布的宽度和高度与 SVG 的宽度和高度相同。

canvas.width = image.width;
canvas.height = image.height;

任何帮助表示赞赏。

这是小提琴: https://jsfiddle.net/chetan530/rcwyr57w/

【问题讨论】:

    标签: javascript html d3.js svg c3.js


    【解决方案1】:

    也许只是添加一点填充?

    padding: {
      bottom: 20
    }
    

    更新小提琴:https://jsfiddle.net/3xq1rtns/

    【讨论】:

    • 我无法在 UI 上编辑图表。如果我按照您的建议添加填充,它将改变它在 UI 上的显示方式。我可以对下载图像进行编辑。即在使用 getElementsByTagName("svg") 访问 SVG 内容后一次。
    猜你喜欢
    • 1970-01-01
    • 2016-09-10
    • 2023-01-28
    • 2015-02-13
    • 2017-02-12
    • 2013-08-20
    • 2017-08-17
    • 1970-01-01
    • 2020-04-20
    相关资源
    最近更新 更多