- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的问题出在这张图片上。我正在尝试绘制一个以传感器数据作为我的点 (X,y) 的图表。当网页加载时,它会读取一个 csv 文件并将此数据发送到来 self 的代码隐藏的 ajax 调用。这是我背后的代码返回的内容:
var myData = new Stats {
Time = dataContainer.time,
LhXVals = dataContainer.lhXVals,
LhYVals = dataContainer.lhYVals,
LhZVals = dataContainer.lhZVals,
RhXVals = dataContainer.rhXVals,
RhYVals = dataContainer.rhYVals
};
这是我的 Stats 类的样子。我解析数据然后将其存储在列表中。
然后我将其发送到 ajax 调用。这是我的 ajax 成功函数:
var time = new Array();
var lhXVals = new Array();
var cumulative = new Array();
var data2;
success: function (result) {
time = result.d.Time; //Time is a List<double>
lhXVals = result.d.LhXVals; //Left-Hand-X-Values is a List<double>, both are the same size
//check if time and lhXVals are empty, if not proceed
if (time.length > 0 || lhXVals.legnth > 0) {
for (var i = 0; i < time.length; ++i) {
//only grabbing little bit of data just to test,
//only taking first 2 elements
if (i == 6)
break;
//use the time data ex:(510.2838439) as my X-axes
//use the left-hand-X-Values ex:(23.9384384) as my Y-axes
debugger;
cumulative.push([parseFloat(time[i]), parseFloat(lhXVals[i])]);//data2 was a manually populated example i used before
data2 = [[4.53123342, 0], [4.9039293, 24.89323233], [6, 0], [6, -12.134], [8, 0], [8, 6.932]];
//an index in the "cumulative" array would look like this:
// [0]: [510.2838439,23.9384384]
}
}
updateOnce(cumulative);
updateOnce(cumulative);
函数接受我在 flot.setData()
方法中使用的累积点数组来绘制新图形。
function updateOnce(cumulative) {
debugger;
plot.setData([cumulative]);
plot.draw();//draws nothing
}
然而,最大的问题是,当 plot.draw();
被绘制时,我的图表上什么也没有,我也不知道为什么。我已经尝试了我能想到的一切。我试过将数据解析为 float ,然后保留它但没有改变任何东西。我在“累积”中的数据存储与我为图形点创建的手动数组(var 数据)完全相同,但它不起作用,我一直在努力。
编辑对于下面的评论。我最初是这样设置的:
function updateOnce(cumulative) {
debugger;
plot.setData([cumulative]);
plot.draw(); //draws nothing
}
//implementing getData Last
var plot = $.plot("#placeholder", [getData()], {
series: {
shadowSize: 0 // Drawing is faster without shadows
},
yaxis: {
min: -50,
max: 50
},
xaxis: {
show: true
}
});
我返回的数据是手动设置的点 (x,y) 数组,因此它会首先在图形上绘制一些东西,它确实这样做了。然后当 ajax 最终返回一些数据时,我用返回的数据启动重绘。
最佳答案
如果坐标轴的最小值/最大值在 setData
调用中发生变化,您需要调用 plot.setupGrid()
来重新计算坐标轴。来自documentation , 加粗我的:
setData(data)
You can use this to reset the data used. Note that axis scaling, ticks, legend etc. will not be recomputed (use setupGrid() to do that). You'll probably want to call draw() afterwards.
You can use this function to speed up redrawing a small plot if you know that the axes won't change. Put in the new data with setData(newdata), call draw(), and you're good to go. Note that for large datasets, almost all the time is consumed in draw() plotting the data so in this case don't bother.
setupGrid()
Recalculate and set axis scaling, ticks, legend etc.
Note that because of the drawing model of the canvas, this function will immediately redraw (actually reinsert in the DOM) the labels and the legend, but not the actual tick lines because they're drawn on the canvas. You need to call draw() to get the canvas redrawn.
关于c# - 图表不会得出我的观点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20939346/
Closed. This question is opinion-based。它当前不接受答案。
我有一个项目需要在工作和在家中使用两台不同的计算机进行。 我需要能够在两台计算机上都处理代码,所以问题有两个。 共享代码 共享工作空间。 用svn 1很简单;但是我感到很讨厌将损坏的代码提交给svn,
我正在尝试在 Eclipse 中实现 coreNLP 情绪分析器。得到错误: Unable to resolve "edu/stanford/nlp/models/lexparser/englishP
我有一个输入框: 如果我在输入字段中输入 .75 ,则应在 .75 之前自动添加 0 ,使其变为 0.75 此外,如果我输入 1.3 那么它应该变成 1.30 我已经尝试过: echo "
我有一个带有以下行的父组件 根据上下文,它呈现路由器配置中定义的两个组件之一 path: 'parent', component: Parent, children: [ {
我安装了最新的 angular-ui-select (v0.12) 和 angular v1.2.27。我的页面无法加载。我得到: expected expression, got . (a poin
我是一名优秀的程序员,十分优秀!