jqplot:分隔刻度和系列值 [英] jqplot: Separating ticks and series values

查看:118
本文介绍了jqplot:分隔刻度和系列值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Web服务,该服务在一个数组中发送日期值(用于x轴).它在另一个数组中发送y轴值.

I have a web service that sends date values (for x-axis) in one array. It sends y-axis values in another array.

是否可以让jqPlot用2个这样的数组创建图表.文档似乎表明这是可能的.

Is it possible to have jqPlot create a chart with 2 such arrays. Documentation seems to indicate this is possible.

我知道将日期和序列值组合在一个数组中是可行的.想要避免合并两个数组的额外处理.

I know combining the date and series value in one array works. Would like to avoid the extra processing of combining the 2 arrays.

此jsFiddle http://jsfiddle.net/abhivm/HmnmH/1/显示示例代码.谁能看一下,让我知道该怎么做?

This jsFiddle http://jsfiddle.net/abhivm/HmnmH/1/ shows sample code. Can anyone please look and let me know how to do this?

jsFiddle今天早上返回错误,因此在下面发布jQuery代码.

jsFiddle is returning errors this morning, so posting the jQuery code below.

$(document).ready(function() {
    var dateValues = ["01/15/2012", "01/17/2012", "01/18/2012", "01/19/2012"];
    var dailyValues = [219, 73, 73, 146];

    plot2 = $.jqplot('chart', [dailyValues], {

        axes: {
            xaxis: {
                renderer: $.jqplot.DateAxisRenderer,
                ticks: dateValues
            }
        }
    });
});

谢谢 阿比(Abhi)

Thanks Abhi

推荐答案

我无法找到让jqPlot接受您要如何定义输入的方法(ticks选项似乎仅适用于数字).我对避免额外处理"的评论感到好奇.使用jQuery就像:

I can not figure out a way for jqPlot to accept how you want to define your inputs (the ticks option seems to only work with numbers). I'm curious as to the "avoid the extra processing" comment. With jQuery it would be as easy as:

$.map(dateValues, 
       function(val,idx){
           return [[val,dailyValues[idx]]];
       }
);

将两个数组合并"为点对.

to "merge" the two arrays into point pairs.

这篇关于jqplot:分隔刻度和系列值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆