1

我陷入了一个问题。你们可能已经在许多应用程序中看到了类似于扫描仪的动画线条。好吧,我需要类似的东西,但我需要它在图表中。

我真正需要的是我需要绘制一条自动从一个点移动到另一个点的垂直线。

让我再解释一下: 1. 我有一个按钮 2. 我按下按钮,图形区域出现。3. 在图形区域上,一条垂直线在该区域中滚动,就好像它正在扫描该区域一样。

我能够绘制这条线,但它有点倾斜。其背后的逻辑如下:

for(i=0;i<frequencyArray.length;i++){
                 myTestArray2.push([i,outFrequencyArray[i]]);
            }

plot.setData([
              {data:myTestArray2,lines:{fill:false,lineWidth:3},shadowSize:10}
                    ]);

function setUpflot(){
            // setup plot

             //console.log("setUpflot");
             var options = {
                // series  : { shadowSize: 0, splines: {show:true,lineWidth:1}},
                 series  : { },

                 yaxis   : { ticks: 5, tickColor:"rgba(148,129,151,0.5)", min: minGraphY, max:maxGraphY,show: true},
                xaxis   : { tickLength:0,  show: false },
                grid    : { borderWidth:0,markings:[
                                {yaxis: { from: 200.0, to: 240.0 },color: "rgba(140,2,28,0.5)"}
                        ]}
             };
4

2 回答 2

6

我把这个放在一起是为了回应昨天的评论。

在这里拉小提琴。

产生:

在此处输入图像描述

plot = $.plot($("#placeholder"),
  [ { data: someData} ], {
  series: {
    lines: { show: true }
  },
  crosshair: { mode: "x" }, // turn crosshair on
  grid: { hoverable: true, autoHighlight: false },
  yaxis: { min: -1.2, max: 1.2 }
});

crossHairPos = plot.getAxes().xaxis.min;
direction = 1;

setCrossHair = function(){
   if (direction == 1){
     crossHairPos += 0.5;   
   }
   else
   {
       crossHairPos -= 0.5;
   }
   if (crossHairPos < plot.getAxes().xaxis.min){
       direction = 1;
       crossHairPos = plot.getAxes().xaxis.min;
   }
   else if (crossHairPos > plot.getAxes().xaxis.max)
   {
       direction = 0;
       crossHairPos = plot.getAxes().xaxis.max;
   }
  plot.setCrosshair({x: crossHairPos})
  setTimeout(setCrossHair,100);
}

// kick it off
setTimeout(setCrossHair,100);
于 2013-03-08T14:01:48.697 回答
1
var frequencyIndex = 0; //dynamic values stored intialised with 0.
var outFrequencyArray = [];

for(i=0;i<totalPoints;i++){

              outFrequencyArray.push(minGraphY-1);
          } 


opd=Math.tan(Math.PI/2);
outFrequencyArray.splice(frequencyIndex,0,opd);
frequencyIndex++;
for(i=0;i<frequencyArray.length;i++){
myTestArray2.push([i,outFrequencyArray[i]]);
        }

plot.setData([
          {data:myTestArray2,lines:{fill:false,lineWidth:3},shadowSize:10}
                ]);

function setUpflot(){
        // setup plot

         //console.log("setUpflot");
         var options = {
            // series  : { shadowSize: 0, splines: {show:true,lineWidth:1}},
             series  : { },

             yaxis   : { ticks: 5, tickColor:"rgba(148,129,151,0.5)", min: minGraphY, max:maxGraphY,show: true},
            xaxis   : { tickLength:0,  show: false },
            grid    : { borderWidth:0,markings:[
                            {yaxis: { from: 200.0, to: 240.0 },color: "rgba(140,2,28,0.5)"}
                    ]}
         };
于 2013-03-08T10:59:32.433 回答