在调整浏览器大小之前,Dygraph不显示x轴上的所有日期

时间:2018-02-19 14:15:50

标签: dygraphs

我有一些来自http://dygraphs.com/的Dygraphs,它们最初呈现如下,x轴日期未正确呈现。

enter image description here

然后我通过缩小浏览器的大小来重新调整大小,然后重新调整大小,然后图形正确呈现如下

enter image description here

代码如下:

      new Dygraph(document.getElementById("graphdiv_"+<?php echo $key; ?>),content_<?php echo $key; ?>, {
    legend: 'always',
    showRoller: false,
    rollPeriod: 14,
    customBars: true,
    rightGap:15,
    ylabel: 'Rating',
    strokeWidth: 1.5,
    digitsAfterDecimal: 3,
    axes: {
            y: {
                valueRange: [3, 5]
            }
        }

});

这是一个错误吗?

我最初需要做出哪些调整才能正确渲染图表?

此致 康特

1 个答案:

答案 0 :(得分:0)

以下解决了图形渲染的问题。

$(function() {
        new Dygraph(document.getElementById("graphdiv_"+<?php echo $key; ?>),content_<?php echo $key; ?>, {
                legend: 'always',
                showRoller: false,
                rollPeriod: 14,
                customBars: true,
                rightGap:15,
                ylabel: '',
                dateWindow: [new Date(date.getFullYear(), date.getMonth()-1, date.getDate()), new Date(date.getFullYear(), date.getMonth(), date.getDate())],
                axes: {
                    y: {
                            valueRange: [3, 5]
                        }
                }
        });
});