javascript - jqplot 1个月失败

标签 javascript jquery jqplot

由于某种原因,jqplot 无法正确渲染标签,最终将所有线点推到图表末尾。这是它的样子...

它是这样的:

enter image description here

下面是包含情节点的 JS...

var _a212064_plot_properties;
$(document).ready(function ()
{
    _a212064_plot_properties =
    {
        "legend" :
        {
            "show" : true
        },
        "series" : [
            {
                "label" : "Current Year"
            },
            {
                "label" : "Previous Year"
            }
        ],
        "axes" :
        {
            "xaxis" :
            {
                "tickOptions" :
                {
                    "formatString" : "%b"
                },
                "label" : "Date",
                "min" : "07\/01\/2012 00:00:00",
                "tickInterval" : "1 Month",
                "renderer" : $.jqplot.DateAxisRenderer,
                "properties" : "xaxis"
            },
            "yaxis" :
            {
                "tickRenderer" : $.jqplot.CanvasAxisTickRenderer,
                "tickOptions" :
                {
                    "angle" : -30,
                    "labelPosition" : "middle"
                },
                "labelRenderer" : $.jqplot.CanvasAxisLabelRenderer,
                "labelOptions" :
                {
                    "fontSize" : "13pt"
                },
                "label" : "Organic Visits",
                "properties" : "yaxis"
            }
        },
        "highlighter" :
        {
            "bringSeriesToFront" : true,
            "tooltipLocation" : "n",
            "tooltipOffset" : "0",
            "formatString" : "Point <\/span>%s: %s<\/strong><\/div>"
        },
        "cursor" :
        {
            "show" : true,
            "zoom" : true
        }
    }

    $.jqplot.config.enablePlugins = true;
    $.jqplot.config.defaultHeight = 300;
    $.jqplot.config.defaultWidth = 400;
    _a212064 = $.jqplot("a212064", [[[1341115200, 2330], [1343793600, 2768], [1346472000, 2462], [1349064000, 2331], [1351742400, 2198], [1354338000, 2258], [1357016400, 2763], [1359694800, 2399], [1362114000, 2643], [1364788800, 1550], [1367380800, 621], [1370059200, 356]], [[1341115200, 4654], [1343793600, 4105], [1346472000, 4347], [1349064000, 4163], [1351742400, 3849], [1354338000, 5579], [1357016400, 4908], [1359694800, 3690], [1362114000, 2314], [1364788800, 3173], [1367380800, 2608], [1370059200, 2330]]], _a212064_plot_properties);

}
);

有什么想法吗?将日期放入该标签是我最不明白的事情。

谢谢!

最佳答案

您需要更改xaxis的参数。

这是您的代码的工作副本:Jsfiddle link

var _a212064_plot_properties;
$(document).ready(function ()
{
    _a212064_plot_properties =
    {
        "legend" :
        {
            "show" : true
        },
        "series" : [
            {
                "label" : "Current Year"
            },
            {
                "label" : "Previous Year"
            }
        ],
        "axes" :
        {
            "xaxis" :
            {

                "label" : "Date",
                "renderer" : $.jqplot.DateAxisRenderer
            },
            "yaxis" :
            {
                "tickRenderer" : $.jqplot.CanvasAxisTickRenderer,
                "tickOptions" :
                {
                    "angle" : -30,
                    "labelPosition" : "middle"
                },
                "labelRenderer" : $.jqplot.CanvasAxisLabelRenderer,
                "labelOptions" :
                {
                    "fontSize" : "13pt"
                },
                "label" : "Organic Visits"
            }
        },
        "highlighter" :
        {
            "bringSeriesToFront" : true,
            "tooltipLocation" : "n",
            "tooltipOffset" : "0",
            "formatString" : "Point <\/span>%s: %s<\/strong><\/div>"
        },
        "cursor" :
        {
            "show" : true,
            "zoom" : true
        }
    }

    $.jqplot.config.enablePlugins = true;
    $.jqplot.config.defaultHeight = 300;
    $.jqplot.config.defaultWidth = 400;
    _a212064 = $.jqplot("a212064", [[[1341115200, 2330], [1343793600, 2768], [1346472000, 2462], [1349064000, 2331], [1351742400, 2198], [1354338000, 2258], [1357016400, 2763], [1359694800, 2399], [1362114000, 2643], [1364788800, 1550], [1367380800, 621], [1370059200, 356]], [[1341115200, 4654], [1343793600, 4105], [1346472000, 4347], [1349064000, 4163], [1351742400, 3849], [1354338000, 5579], [1357016400, 4908], [1359694800, 3690], [1362114000, 2314], [1364788800, 3173], [1367380800, 2608], [1370059200, 2330]]], _a212064_plot_properties);

}
);

关于javascript - jqplot 1个月失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17951034/

相关文章:

javascript - 将元素动态移动到视口(viewport)内部

JavaScript 三倍大于

javascript - 在 HTML URL 链接中传递值

javascript - jQuery 问题 :not selector

jquery - Jqplot y轴缩放

javascript - 使用带有 html css 和 js 的 jqplot 在 ios xcode 上创建饼图的问题

javascript - 没有静态 ID 的 jqPlot 目标

javascript - 如何在 JavaScript 中重新定义数组的 + 运算符?

javascript - 为图像 slider 优化/制作更好的 JQuery 代码

javascript - 如何通过最接近的匹配文本获取元素?