绘制错误点的情节

时间:2014-04-19 19:07:14

标签: jquery flot

var plot = $.plot($("#statsChart"), [{
    data: [
        [1, 2],
        [2, 0],
        [3, 0],
        [4, 0],
        [5, 0],
        [6, 0],
        [7, 0],
        [8, 0],
        [9, 0],
        [10, 0],
        [11, 0],
        [12, 0]
    ],
    label: "Serviços ativos"
}, {
    data: [
        [1, 2],
        [2, 0],
        [3, 0],
        [4, 0],
        [5, 0],
        [6, 0],
        [7, 0],
        [8, 0],
        [9, 0],
        [10, 0],
        [11, 0],
        [12, 0]
    ],
    label: "Serviços em processo"
}, {
    data: [
        [1, 0],
        [2, 0],
        [3, 0],
        [4, 0],
        [5, 0],
        [6, 0],
        [7, 0],
        [8, 0],
        [9, 0],
        [10, 0],
        [11, 0],
        [12, 0]
    ],
    label: "Registos"
}], {
    series: {
        lines: {
            show: true,
            lineWidth: 1,
            fill: true,
            fillColor: {
                colors: [{
                    opacity: 0.1
                }, {
                    opacity: 0.13
                }]
            }
        },
        points: {
            show: true,
            lineWidth: 2,
            radius: 3
        },
        shadowSize: 0,
        stack: true
    },
    grid: {
        hoverable: true,
        clickable: true,
        tickColor: "#f9f9f9",
        borderWidth: 0
    },
    legend: {
        // show: false
        labelBoxBorderColor: "#fff"
    },
    colors: ["#343e4b", "#7e91aa", "#4387bf", "#3b9ff3"],
    xaxis: {
        ticks: [
            [1, "JAN"],
            [2, "FEV"],
            [3, "MAR"],
            [4, "ABR"],
            [5, "MAI"],
            [6, "JUN"],
            [7, "JUL"],
            [8, "AGO"],
            [9, "SET"],
            [10, "OUT"],
            [11, "NOV"],
            [12, "DEZ"]
        ],
        font: {
            size: 12,
            family: "Open Sans, Arial",
            variant: "small-caps",
            color: "#697695"
        }
    },
    yaxis: {
        ticks: 3,
        tickDecimals: 0,
        font: {
            size: 12,
            color: "#9da3a9"
        }
    }
});

function showTooltip(x, y, contents) {
    $('<div id="tooltip">' + contents + '</div>').css({
        position: 'absolute',
        display: 'none',
        top: y - 30,
        left: x - 50,
        color: "#fff",
        padding: '2px 5px',
        'border-radius': '6px',
        'background-color': '#000',
        opacity: 0.80
    }).appendTo("body").fadeIn(200);
}
var previousPoint = null;
$("#statsChart").bind("plothover", function (event, pos, item) {
    if (item) {
        if (previousPoint != item.dataIndex) {
            previousPoint = item.dataIndex;
            $("#tooltip").remove();
            var x = item.datapoint[0].toFixed(0),
                y = item.datapoint[1].toFixed(0);
            var month = item.series.xaxis.ticks[item.dataIndex].label;
            showTooltip(item.pageX, item.pageY,
                item.series.label + " of " + month + ": " + y);
        }
    } else {
        $("#tooltip").remove();
        previousPoint = null;
    }
});

但问题是,当情节在“ServiçosAtivos”(第一次数据录入)上显示正确的数据,然后第二个条目(“serviçosemprocesso”)没有出现而是出现最后一个条目(“Registos”) )当值应为0时,值为4.

这个图是用flot制作的,我尝试使用变量来设置数据输出它是一样的。

此外,我已经检查过编码器文档,所有内容似乎都已正确编码。

任何帮助?

(Flot github:https://github.com/flot/flot

更新

解决了,删除了修复问题的jquery.flot.stack.js和jquery.flot.resize.js

0 个答案:

没有答案