绘制2个数组输入x-y [英] Plot with 2 array inputs x-y
问题描述
var 我使用Flot Charts,并且有2个向量表示x和y变量,如下所示: x = [1.778,1.767,2.308,2.41]
var y = [35.94,35.97,36.01,36.04]
问题是,当我想绘制时,以下语法:
$(document).ready (function(){
$ .plot($(#placeholder),[d1]);
});
只允许绘制d1变量!具有以下形式:
var d1 = [[0,0],[1,4],[2,7 ],[3,3],[4,2]];
如果您有3或4个点要绘制,那很好,但是当您有近50个绘图,你需要更多的自动化功能。
我的问题是:是否有任何方法绘制Flot中的2个ARRAY VARIABLES或将它们转换为使用函数绘制它们?
var x = [1.778,1.767,2.308,2.41];
var y = [35.94,35.97,36.01,36.04],d1 = [];
for(var i = 0; i< x.length; i ++)
d1.push([x [i],y [i]]);
I am using Flot Charts and I have 2 vectors that represent the x and y variables that look like this:
var x = [1.778,1.767,2.308,2.41]
var y = [35.94,35.97,36.01,36.04]
The problem is that when I want to plot, the following syntaxis:
$(document).ready(function () {
$.plot($("#placeholder"), [d1]);
});
does only allow to plot the d1 variable!! Which has the following form:
var d1= [ [0,0], [1,4], [2,7], [3,3], [4,2] ];
That is fine if you have 3 or 4 points to plot, but when you have almost 50 to plot, you need something more automatized.
My question is: Is there any way of plotting 2 ARRAY VARIABLES in Flot or converting them to plot them using a function?
You can create a two dimensional array from x,y arrays like this
var x = [1.778,1.767,2.308,2.41];
var y = [35.94,35.97,36.01,36.04],d1=[];
for(var i=0;i<x.length;i++)
d1.push([x[i],y[i]]);
这篇关于绘制2个数组输入x-y的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!