示例#1
0
 public GraphView refreshGraph(double[] values) {
   GraphViewData[] data = new GraphViewData[Globals.NUMBER_DATA];
   for (int i = 0; i < Globals.NUMBER_DATA; i++) {
     data[i] = new GraphViewData((i * Globals.FACTOR_MULTIPLY), values[i]);
   }
   graphView = new LineGraphView(mContext, mContext.getString(R.string.titleGraph));
   graphView.addSeries(new GraphViewSeries(data));
   graphView.setViewPort(Globals.X_AXYS_MIN, Globals.X_AXYS_MAX);
   graphView.setScrollable(true);
   graphView.setScalable(true);
   return graphView;
 }
  private void drawEstimationGraph() {
    double output[] = estimator.getEstimataion();

    GraphViewData data[] = new GraphViewData[output.length];
    for (int i = 0; i < output.length; ++i) {
      data[i] = new GraphViewData(i, output[i]);
    }

    // init example series data
    GraphViewSeries exampleSeries = new GraphViewSeries(data);

    // granica hiperglikemiczna
    data = new GraphViewData[output.length];
    for (int i = 0; i < output.length; ++i) {
      data[i] = new GraphViewData(i, 130);
    }

    GraphViewSeries hyperglycemicSeries1 =
        new GraphViewSeries("Hiperglikemia 1", Color.rgb(200, 50, 00), data);

    data = new GraphViewData[output.length];
    for (int i = 0; i < output.length; ++i) {
      data[i] = new GraphViewData(i, 180);
    }

    GraphViewSeries hyperglycemicSeries2 =
        new GraphViewSeries("Hiperglikemia 2", Color.rgb(220, 20, 60), data);

    data = new GraphViewData[output.length];
    for (int i = 0; i < output.length; ++i) {
      data[i] = new GraphViewData(i, 50);
    }

    GraphViewSeries lowSeries = new GraphViewSeries("Dolna granica", Color.rgb(255, 215, 00), data);

    GraphView graphView = new LineGraphView(this, "Poziom cukru [mg/dl]");

    graphView.setHorizontalLabels(new String[] {"0h", "1h", "2h", "3h", "4h", "5h", "6h"});

    graphView.addSeries(hyperglycemicSeries1);
    graphView.addSeries(hyperglycemicSeries2);
    graphView.addSeries(lowSeries);
    graphView.addSeries(exampleSeries); // data

    graphView.setViewPort(0, 360);

    LinearLayout layout = (LinearLayout) findViewById(R.id.graph1);
    layout.addView(graphView);
  }
示例#3
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.graphs);

    // init example series data
    exampleSeries1 =
        new GraphViewSeries(
            new GraphViewData[] {
              new GraphViewData(1, 2.0d),
              new GraphViewData(2, 1.5d),
              new GraphViewData(2.5, 3.0d) // another frequency
              ,
              new GraphViewData(3, 2.5d),
              new GraphViewData(4, 1.0d),
              new GraphViewData(5, 3.0d)
            });

    // graph with dynamically genereated horizontal and vertical labels
    if (getIntent().getStringExtra("type").equals("bar")) {
      graphView =
          new BarGraphView(
              this // context
              ,
              "GraphViewDemo" // heading
              );
    } else {
      graphView =
          new LineGraphView(
              this // context
              ,
              "GraphViewDemo" // heading
              );
    }
    graphView.addSeries(exampleSeries1); // data

    LinearLayout layout = (LinearLayout) findViewById(R.id.graph1);
    layout.addView(graphView);

    // ----------
    exampleSeries2 =
        new GraphViewSeries(
            new GraphViewData[] {
              new GraphViewData(1, 2.0d),
              new GraphViewData(2, 1.5d),
              new GraphViewData(2.5, 3.0d) // another frequency
              ,
              new GraphViewData(3, 2.5d),
              new GraphViewData(4, 1.0d),
              new GraphViewData(5, 3.0d)
            });

    // graph with custom labels and drawBackground
    if (getIntent().getStringExtra("type").equals("bar")) {
      graphView = new BarGraphView(this, "GraphViewDemo");
    } else {
      graphView = new LineGraphView(this, "GraphViewDemo");
      ((LineGraphView) graphView).setDrawBackground(true);
    }
    graphView.addSeries(exampleSeries2); // data
    graphView.setViewPort(1, 4);
    graphView.setScalable(true);

    layout = (LinearLayout) findViewById(R.id.graph2);
    layout.addView(graphView);
  }