eixoX.setAxisTitle(new IAxis.AxisTitle("Data da Consulta"));
eixoY.setAxisTitle(new IAxis.AxisTitle("Medida"));
// Create an ITrace:
ITrace2D traceMin = new Trace2DSimple("Valores Mínimos");
traceMin.setColor(Color.blue);
ITrace2D traceAvg = new Trace2DSimple("Valores Médios");
traceAvg.setColor(Color.green);
ITrace2D traceMax = new Trace2DSimple("Valores Máximos");
traceMax.setColor(Color.red);
// Add the trace to the chart. This has to be done before adding points (deadlock prevention):
if (chkValorMinimo.isSelected()){
chart.addTrace(traceMin);
traceMin.addTracePainter(new TracePainterDisc());
}
if (chkValorMedio.isSelected()){
chart.addTrace(traceAvg);
traceAvg.addTracePainter(new TracePainterDisc());
}
if (chkValorMax.isSelected()){
chart.addTrace(traceMax);
traceMax.addTracePainter(new TracePainterDisc());
}
// Add all points, as it is static:
Object[] values = listSessoes.getSelectedValues();
String medida = "";
if (! listGraficos.isSelectionEmpty())
medida = listGraficos.getSelectedValue().toString();
double min = 180, max = 0;
for(int i = values.length - 1; i>=0; i-- ){
Sessao s = (Sessao) values[i];
s.carregaMedicoes();
if (s != null && s.getMedicoes() != null){
for (Medicao m : s.getMedicoes()){
if (m.getNome().equals(medida + "min") && chkValorMinimo.isSelected()){
traceMin.addPoint(s.getData().getTime(), m.getValor());
min = (m.getValor() < min)?m.getValor():min;
max = (m.getValor() > max)?m.getValor():max;
}
if (m.getNome().equals(medida + "avg") && chkValorMedio.isSelected()){
traceAvg.addPoint(s.getData().getTime(), m.getValor());
min = (m.getValor() < min)?m.getValor():min;
max = (m.getValor() > max)?m.getValor():max;
}
if (m.getNome().equals(medida + "max") && chkValorMax.isSelected()){
traceMax.addPoint(s.getData().getTime(), m.getValor());
min = (m.getValor() < min)?m.getValor():min;
max = (m.getValor() > max)?m.getValor():max;
}
}
}