3

I am trying to do the following for the x labels in my graph.

The first label should have format:

plot.getGraphWidget()
        .setDomainValueFormat(new SimpleDateFormat("dd/MM/yyyy hh:mm:ss"));

All the other labels should only show minutes and seconds:

plot.getGraphWidget()
        .setDomainValueFormat(new SimpleDateFormat("mm:ss"));

I can set the Format for all labels, but I can't figure out how to change it for only the first label. My graph is dynamic and changes every second (incoming data gets updated each second with a new value).

Is there maybe a function that could help me? (It's all a bit difficult to find with website being down...) Or any other tips?

Any help is greatly appreciated.

Nick
  • 8,181
  • 4
  • 38
  • 63
taranaki
  • 778
  • 3
  • 9
  • 28
  • Update: I have tried to do this for a really long time now and given up. I am now just displaying format hh:mm:ss and assuming that the user will understand that it's current data. – taranaki May 23 '12 at 15:29

1 Answers1

0

Assuming you have no repeating values in your domain model you could keep track of your first value and test for equality inside a custom Formatter implementation. It's not pretty but because there is no way to pass in the index of the item being drawn to the Formatter that's about the only way I can see doing this.

Nick
  • 8,181
  • 4
  • 38
  • 63
  • Another possible solution: If your domain values are evenly spaced (or you at least dont mind that they appear to be on the plot) then you can use a custom Formatter and an array of indexes as your domain values {0, 1, 2, 3, ...} and a lookup table with the corresponding labels inside {"2/1/2012 12:00", "3/1/2012 12:00"}. Inside your formatter when you receive a call to render "0", return the value from the lookup table at index 0 instead. – Nick May 02 '13 at 15:10