简体   繁体   English

wkhtmltoimage不显示highcharts图的网格线

[英]wkhtmltoimage does not show gridlines of highcharts graph

I'm using symfony to generate a simple highcharts graph , but wkhtmltoimage does not show the gridlines properly: 我正在使用symfony生成一个简单的highcharts图 ,但wkhtmltoimage没有正确显示网格线:

wkhtmltoimage highcharts graph

My knp_snappy.image config is the following: 我的knp_snappy.image配置如下:

options:
        encoding:           UTF-8
        format:             svg
        width:              0
        enable-smart-width: true
        zoom:               3

and I have added the following options to the graph: 我在图表中添加了以下选项:

plotOptions: {
        series: {
                shadow: false,
                animation:false,
                enableMouseTracking: false
        }
}

What am I doing wrong? 我究竟做错了什么? If i use wkhtmltopdf the output is correct.. 如果我使用wkhtmltopdf输出是正确的..

Ok, i have done! 好的,我做到了!

The problem is with the perfectly horizontal (or vertical) path, probably is related with old's webkit bug 问题在于完全水平(或垂直)的路径,可能与旧的webkit bug有关

Than my solution is to edit the horizontal (and vertical) line of the grid to make it not perfectly horizontal-vertical. 比我的解决方案是编辑网格的水平(和垂直)线,使其不是完全水平 - 垂直。

//fix bug of horizontal-vertical path (TODO: check all series)
yaxis = document.getElementsByClassName('highcharts-yaxis-grid')[0].childNodes;
for (i=0; i<yaxis.length; i++) {
    if (yaxis[i].nodeName.toLowerCase() == 'path') {
        d = yaxis[i].getAttribute('d').split(' ')[2];
        yaxis[i].setAttribute('d', yaxis[i].getAttribute('d').replace(d, parseInt(d)+0.000001));
    }
}

xaxis = document.getElementsByClassName('highcharts-xaxis-grid')[0].childNodes;
for (i=0; i<yaxis.length; i++) {
    if (yaxis[i].nodeName.toLowerCase() == 'path') {
        d = yaxis[i].getAttribute('d').split(' ')[1];
        yaxis[i].setAttribute('d', yaxis[i].getAttribute('d').replace(d, parseInt(d)+0.000001));
    }
}

For example, with the following horizontal path i have to edit the first occurrency of the number 264.5, 213.5, 163 例如,使用以下水平路径,我必须编辑数字264.5,213.5,163的第一个并发

<g class="highcharts-grid highcharts-yaxis-grid ">
    <path d="M 77 264.5 L 413 264.5"></path>
    <path d="M 77 213.5 L 413 213.5"></path>
    <path d="M 77 163.5 L 413 163.5"></path>
</g>

to obtain the following non-horizontal lines 获得以下非水平线

<g class="highcharts-grid highcharts-yaxis-grid ">
    <path d="M 77 264.500001 L 413 264.5"></path>
    <path d="M 77 213.500001 L 413 213.5"></path>
    <path d="M 77 163.500001 L 413 163.5"></path>
</g>

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

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