Graphica DateTimeStamp

Does anyone know if the Graphica library can have a datetimestamp as one of its axis? I see years being used in an example but cannot seem to find datetime used.

Tia!

you can set any text you want, formatting ?


import grafica.*;
int nPoints = 10;

void setup() {
  size(520, 400);
  background(150);
  GPointsArray points = new GPointsArray(nPoints);

  for (int i = 0; i < nPoints; i++)  points.add(i, 10*noise(0.1*i));
  // Create a new plot and set its position on the screen
  GPlot plot = new GPlot(this);
  plot.setPos(10, 10);
  //  plot.setOuterDim(500,300);
  plot.setPoints(points);
  plot.setTitleText("x tick label test");
  plot.getXAxis().setAxisLabelText("time");
  //  plot.getXAxis().setOffset(20);
  plot.getXAxis().setRotateTickLabels(true);
  plot.getYAxis().setAxisLabelText("random");
  println(plot.getXAxis().getTicks());
  println(plot.getXAxis().getTicks().length);
  //  String[] xticks = new String[nPoints];
  //  String[] xticks = {"a","b","c","d","e"};
  String[] xticks = new String[plot.getXAxis().getTicks().length]; //{"a","b","c","d","e"};
  for (int i = 0; i < plot.getXAxis().getTicks().length; i++) 
    xticks[i] = year()+"-"+month()+"-"+day()+" "+hour()+":"+minute()+":"+second();
  plot.getXAxis().setTickLabels(xticks);
  //  plot.getXAxis().setDrawTickLabels(true);
  plot.defaultDraw();
}


snap-081

1 Like