【问题标题】:Dygraph not showing all dates on x axis until I adjust the browser size在我调整浏览器大小之前,Dygraph 不会在 x 轴上显示所有日期
【发布时间】:2018-02-25 21:51:15
【问题描述】:

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

然后我通过将浏览器变小再变大来调整浏览器的大小,然后图形正确呈现如下

代码如下:

      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]
            }
        }

});

这是一个错误吗?

我需要进行哪些调整才能使图表最初正确呈现?

问候 联系方式

【问题讨论】:

  • 请出示您的代码好吗?
  • @LucidioVacas 我已经添加了 dygraph 代码。还有其他相关的代码吗?

标签: dygraphs


【解决方案1】:

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

$(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]
                        }
                }
        });
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-07-06
    • 2021-12-25
    • 1970-01-01
    • 2017-06-10
    • 1970-01-01
    • 1970-01-01
    • 2012-03-12
    • 1970-01-01
    相关资源
    最近更新 更多