2

我尝试为我的心电图创建一个自定义网格,但没有任何效果。
我想得到一个具有特定突出显示线的网格。为了减少我使用的网格线xyMultipleSeriesRenderer.setXLabels(10)xyMultipleSeriesRenderer.setYLabels(10).
现在我想从 X 轴和 Y 轴每隔四行突出显示,或者使它们比其他行大。
这是我发现的东西。

http://www.google.de/imgres?um=1&client=firefox-a&sa=N&rls=org.mozilla:de:official&hl=de&biw=1680&bih=920&tbm=isch&tbnid=0PCpcj6UTWULcM:&imgrefurl=http://android.codeandmagic。 org/2012/10/achartengine-live-scrolling-graph/2012-10-03-19-16-10-2/&docid=yfaTOinxMsdA-M&imgurl=http://android.codeandmagic.org/wp-content/uploads/ 2012/10/2012-10-03-19.16.101.png&w=720&h=1280&ei=8bDCUdP3E8zPsgbKpICYBw&zoom=1&iact=rc&dur=317&page=1&tbnh=147&tbnw=83&start=0&ndsp=51&ved=1t:429,r:5, i:97&tx=29&ty=58

这几乎是我正在寻找的。但我还需要 y 轴的阈值。
有人有想法吗?我很高兴任何提示!

补充:

是的,突出线条真的很容易。我只是在 (0,20) 处添加一个点,在 (1000,20) 处添加一个点。这对水平线非常有效。

但是如果我想对垂直线做同样的事情,我会得到一条对角线。对于静态折线图,如果我只在 (30,0) 处添加一个点,在 (30,100) 处添加一个点,它就可以工作。但是,如果我对实时折线图做同样的事情,我只会得到这种丑陋的倾斜。谁能给我解释一下???我还尝试更改(30,0)和(29,1000)之类的值,但我仍然得到对角线:(

4

2 回答 2

1

解决方案是添加一些额外的系列,每个系列只包含 2 个点,每个这样的系列都会定义这样一条线。

于 2013-06-20T12:17:46.597 回答
0

你好谢谢你的回答。但是我已经有两个系列了。我有一个系列可以生成我的动态图。我试着向你展示我的代码。

public class TraceActivity extends Activity implements Observer
  {
  private GraphicalView view;
  private DynamicGraph dynamicGraph = new DynamicGraph();
  private static Thread thread;
  private dynamicValue value; //get from observable

 protected void onCreate(Bundle savedInstanceState)
 {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_patient);

     /* Thread for the graphs */
    thread = new Thread()
    {
        public void run()
        {

            for (int i = 0; i < 1000; i++)
            { 

                try
                {
                    Thread.sleep(1000);
                }
                catch (InterruptedException e)
                {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

                dynamicGraph.setRange();
                Point point = getDataFromReceiver(i, value);

        // here I try to add the vertical line 
            dynamicGraph.addNewLine(30, 0);    
          dynamicGraph.addNewLine(30, 100);    // this line is painted at 31,100)

                dynamicGraph.addNewPoint(point);

                View.repaint();

            }

        }
    };
    thread.start();

}

public Point getDataFromReceiver(int x, int parameter)
  {
    return new Point(x, parameter);
  }

@Override
  protected void onStart()
  {
    super.onStart();
    runOnUiThread(new ShowView(dynamicgraph.getView(this)));
  }

private class ShowView implements Runnable
   {
    GraphicalView graphView;
    public ShowTocoView(GraphicalView graphicalView)
    {
        graphView = graphicalView;
    }

    @Override
    public void run()
    {
        if (View == null)
        {
            LinearLayout layout = (LinearLayout) findViewById(R.id.View);
            View = graphView;
            layout.addView(View);
        }
        else
        {
            View.repaint();
        }
    }
}

public class DynamicGraph
{
    /** The chart view that displays the data. */
private GraphicalView view;

private TimeSeries Data = new TimeSeries("Toco");
private TimeSeries verticalLine = new TimeSeries("");

/** The main dataset that includes all the series that go into a chart. */
private XYMultipleSeriesDataset mDataset = new XYMultipleSeriesDataset();

/** The main renderer that includes all the renderers customizing a chart. */
private XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer();

/** The most recently created renderer, customizing the current series. */
private XYSeriesRenderer rendererData = new XYSeriesRenderer();
private XYSeriesRenderer rendererVerticalLine = new XYSeriesRenderer();

GraphBuilder graphBuilder = new GraphBuilder(mRenderer, 10);

public TocoGraph()
{
    mDataset.addSeries(Data);
    mDataset.addSeries(verticalLine);

    // graphBuilder build the grid and set the XYSeriesRenderer
    graphBuilder.setAndAddXYSeriesRenderer(rendererData, Color.BLACK, 2f);
    graphBuilder.setAndAddXYSeriesRenderer(rendererVerticalLine,
            Color.rgb(247, 131, 62), 2f);

}

public GraphicalView getView(Context context)
{
    view = ChartFactory.getLineChartView(context, mDataset, mRenderer);
    return view;
}

public void setRange()
{
    graphBuilder.setRange(Data, 100, 0);
}
public void addNewPoint(Point p)
{
    Data.add(p.getX(), p.getY());

}

public void addNewLine(int x, int y)
{
    verticalLine.add(x, y);
}   }

所以我没有理由,为什么垂直线不垂直。你有想法吗?

于 2013-07-02T16:06:02.727 回答