jqplot条形图不显示数据

发布于 2024-11-18 06:34:30 字数 2327 浏览 3 评论 0原文

没有从萤火虫中得到任何错误。在任何浏览器中均不显示。之前一直在工作,大约一周前停止工作。代码示例...

$(document).ready(function () {
    //Generic names for multiple graphs
    var First = $('#hfFirstOrder').val().split(",");
    var Second = $('#hfSecondOrder').val().split(",");
    var Third = $('#hfThirdOrder').val().split(",");
    var ticks = $('#hfDaysOrder').val().split(",");
    var maxValue = parseInt($('#hfMaxOrder').val());
    var FirstArray = [];
    var SecondArray = [];
    var ThirdArray = [];
    for (i = 0; i < First.length; i++) {
        FirstArray.push(parseInt(First[i]));
        SecondArray.push(parseInt(Second[i]));
        ThirdArray.push(parseInt(Third[i]));
    }
    plotGraph("stackedPurchase", [FirstArray, SecondArray, ThirdArray], true, ticks, "Orders", maxValue, '#000', "Completed",
                '#00F', "Ship/Pick", '#F00', "Back Order");

        function plotGraph(chartName, total, stackBool, tick, yLabel, maxValue, SC1, SL1, SC2, SL2, SC3, SL3) {
        plot = $.jqplot(chartName, total, {
            stackSeries: stackBool,
            seriesDefaults: {
                renderer:$.jqplot.BarRenderer,
                rendererOptions: { barMargin: 20, barWidth: 10 },
                showMarker: false,
                pointLabels: { show: false }
            },
            axes: {
                xaxis: {
                    label: "Days",
                    renderer: $.jqplot.CategoryAxisRenderer,
                    ticks: tick
                },
                yaxis: {
                    label: yLabel,
                    padMin: 0,
                    tickInterval: parseInt(maxValue * .1),
                    min: 0,
                    max: maxValue,
                    tickOptions: { formatString: '%d' }
                }
            },
            series: [{ color: SC1, label: SL1 },
            { color: SC2, label: SL2 },
            { color: SC3, label: SL3 }
        ],
            legend: {
                show: true,
                location: 'e',
                placement: 'outside'
            }
        });
    }
});

然后在 html 中调用 for

<div id="stackedPurchase" style="height:450px;width:900px;" runat="server"></div>

并且各种隐藏值是来自后面代码的 csv 字符串。根据 firebug,它们被正确传递(正确的格式和每个变量的正确数量)。从我最近的编码经验来看,这可能是显而易见的事情。

Not getting any errors from firebug. Not showing in any browser. Was working previously and stopped working about a week ago. Sample of the code...

$(document).ready(function () {
    //Generic names for multiple graphs
    var First = $('#hfFirstOrder').val().split(",");
    var Second = $('#hfSecondOrder').val().split(",");
    var Third = $('#hfThirdOrder').val().split(",");
    var ticks = $('#hfDaysOrder').val().split(",");
    var maxValue = parseInt($('#hfMaxOrder').val());
    var FirstArray = [];
    var SecondArray = [];
    var ThirdArray = [];
    for (i = 0; i < First.length; i++) {
        FirstArray.push(parseInt(First[i]));
        SecondArray.push(parseInt(Second[i]));
        ThirdArray.push(parseInt(Third[i]));
    }
    plotGraph("stackedPurchase", [FirstArray, SecondArray, ThirdArray], true, ticks, "Orders", maxValue, '#000', "Completed",
                '#00F', "Ship/Pick", '#F00', "Back Order");

        function plotGraph(chartName, total, stackBool, tick, yLabel, maxValue, SC1, SL1, SC2, SL2, SC3, SL3) {
        plot = $.jqplot(chartName, total, {
            stackSeries: stackBool,
            seriesDefaults: {
                renderer:$.jqplot.BarRenderer,
                rendererOptions: { barMargin: 20, barWidth: 10 },
                showMarker: false,
                pointLabels: { show: false }
            },
            axes: {
                xaxis: {
                    label: "Days",
                    renderer: $.jqplot.CategoryAxisRenderer,
                    ticks: tick
                },
                yaxis: {
                    label: yLabel,
                    padMin: 0,
                    tickInterval: parseInt(maxValue * .1),
                    min: 0,
                    max: maxValue,
                    tickOptions: { formatString: '%d' }
                }
            },
            series: [{ color: SC1, label: SL1 },
            { color: SC2, label: SL2 },
            { color: SC3, label: SL3 }
        ],
            legend: {
                show: true,
                location: 'e',
                placement: 'outside'
            }
        });
    }
});

And then there's a call in the html for

<div id="stackedPurchase" style="height:450px;width:900px;" runat="server"></div>

And the various hidden values are csv strings from the code behind. According to firebug they are being passed in correctly (right formats and correct number of each variable). Judging from my coding experiences recently, its probably something obvious.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

神妖 2024-11-25 06:34:30

得到了部分答案,前两个图现在可以工作,因为工作中的其他人在没有通知我的情况下移动了 jqplot 内容所在的文件夹。更改顶部脚本中的地址解决了问题。

但由于某种原因,第三个不起作用。

plotGraph("graphQuote", [FirstArray, SecondArray, ThirdArray], false, ticks, "Quotes", maxValue, '#F00', "Request RFQ", '#00F', "RFQ", '#0F0', "Customer Quote");

SecondArray 全部为零值,FirstArray 大部分为零,而 ThirdArray 的大部分字段都有值。蜱有正确的日期。

Got a partial answer, the first two graphs work now because someone else at work moved the folders that the jqplot stuff was in without informing me. Changing the address in the scripts at top fixed the problem.

But for some reason the third one isn't working.

plotGraph("graphQuote", [FirstArray, SecondArray, ThirdArray], false, ticks, "Quotes", maxValue, '#F00', "Request RFQ", '#00F', "RFQ", '#0F0', "Customer Quote");

SecondArray is all zero values, FirstArray is mostly zero and ThirdArray has a value in most of its fields. Ticks has correct dates.

呢古 2024-11-25 06:34:30

好的,找到问题了。 显然

parseInt(maxValue * .1)

如果 maxValue 小于 10, 会很生气并返回 0,并且 jqplot 不喜欢 0 作为刻度间隔。找到了一种更好的间歇训练方法,现在一切正常了。

Alright, found the problem. Apparently

parseInt(maxValue * .1)

gets pissy and returns 0 if maxValue is less than 10, and jqplot doesn't like 0 as a tick interval. Found a better way to do intervals and now everything works.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文