layout.setWidth100();
//iterate over the retrieved charting data
for (int index = 0; index < displayOrder.length; index++) {
//retrieve the correct measurement definition
final MeasurementDefinition md = measurementDefMap.get(displayOrder[index]);
//load the data results for the given metric definition
List<MeasurementDataNumericHighLowComposite> data = results.get(index);
//locate last and minimum values.
double lastValue = -1;
double minValue = Double.MAX_VALUE;
//collapse the data into comma delimited list for consumption by third party javascript library(jquery.sparkline)
String commaDelimitedList = "";
for (MeasurementDataNumericHighLowComposite d : data) {
if ((!Double.isNaN(d.getValue())) && (!String.valueOf(d.getValue()).contains("NaN"))) {
commaDelimitedList += d.getValue() + ",";
if (d.getValue() < minValue) {
minValue = d.getValue();
}
lastValue = d.getValue();
}
}
DynamicForm row = new DynamicForm();
row.setNumCols(3);
row.setColWidths(65, "*", 100);
row.setWidth100();
row.setAutoHeight();
row.setOverflow(Overflow.VISIBLE);
HTMLFlow graph = new HTMLFlow();
String contents = "<span id='sparkline_" + index + "' class='dynamicsparkline' width='0' " + "values='"
+ commaDelimitedList.substring(0,commaDelimitedList.lastIndexOf(",")) + "'>...</span>";
graph.setContents(contents);
graph.setContentsType(ContentsType.PAGE);
//disable scrollbars on span
graph.setScrollbarSize(0);
CanvasItem graphContainer = new CanvasItem();
graphContainer.setShowTitle(false);
graphContainer.setHeight(16);
graphContainer.setWidth(60);
graphContainer.setCanvas(graph);
final String title = md.getDisplayName();
LinkItem link = new LinkItem();
link.setLinkTitle(title);
link.setShowTitle(false);
link.setClipValue(false);
link.setWrap(true);
if (!BrowserUtility.isBrowserPreIE9()) {
link.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
showPopupWithChart(title, md);
}
});
} else {
link.disable();
}
//Value
String convertedValue = AbstractActivityView.convertLastValueForDisplay(lastValue, md);
StaticTextItem value = AbstractActivityView.newTextItem(convertedValue);
value.setVAlign(VerticalAlignment.TOP);
value.setAlign(Alignment.RIGHT);
value.setWidth("100%");
row.setItems(graphContainer, link, value);
//if graph content returned
if ((!md.getName().trim().contains("Trait.")) && (lastValue != -1)) {
layout.addMember(row);
someChartedData = true;
}
}
if (!someChartedData) {// when there are results but no chartable entries.