use of org.eclipse.rap.chartjs.pie.PieChartRowData in project rap by entirej.
the class EJRWTPieChartRecordBlockRenderer method refresh.
public void refresh(Object input) {
if (_chartView != null && !_chartView.isDisposed()) {
Collection<EJDataRecord> records = (!multi) ? Arrays.asList(currentRecord == null ? getFirstRecord() : currentRecord) : _block.getRecords();
Collection<EJScreenItemController> screenItems = getScreenItems();
List<String> xlabel = new ArrayList<String>(screenItems.size());
for (EJScreenItemController sItem : screenItems) {
if (sItem.isSpacerItem())
continue;
xlabel.add(sItem.getProperties().getLabel());
}
PieChartRowData chartRowData = new PieChartRowData(xlabel.toArray(new String[0]));
for (EJDataRecord ejDataRecord : records) {
if (ejDataRecord == null)
continue;
Object lbl = labelColumn != null ? ejDataRecord.getValue(labelColumn) : "";
PieChartRowData.RowInfo rowInfo = new RowInfo();
rowInfo.setLabel(lbl != null ? lbl.toString() : "");
boolean[] hidden = new boolean[screenItems.size()];
ChartStyle[] styles = new ChartStyle[screenItems.size()];
double[] data = new double[screenItems.size()];
int[] widths = new int[screenItems.size()];
int index = 0;
for (EJScreenItemController sItem : screenItems) {
ChartStyle colors = new ChartStyle(220, 220, 220, 0.8f);
EJCoreVisualAttributeProperties attributeProperties = sItem.getItemRenderer().getVisualAttributeProperties();
EJCoreVisualAttributeProperties visualAttribute = ejDataRecord.getItem(sItem.getName()).getVisualAttribute();
if (visualAttribute != null) {
attributeProperties = visualAttribute;
}
if (attributeProperties != null) {
if (attributeProperties.getForegroundColor() != null) {
Color color = attributeProperties.getForegroundColor();
colors = new ChartStyle(color.getRed(), color.getGreen(), color.getBlue(), 0.8f);
}
if (attributeProperties.getBackgroundColor() != null) {
Color color = attributeProperties.getBackgroundColor();
colors.setFillColor(new RGB(color.getRed(), color.getGreen(), color.getBlue()));
}
}
EJCoreMainScreenItemProperties mainScreenItemProperties = (EJCoreMainScreenItemProperties) sItem.getProperties();
styles[index] = (colors);
hidden[index] = (!sItem.isVisible());
widths[index] = (mainScreenItemProperties.getBlockRendererRequiredProperties().getIntProperty(LINE_WIDTH, 1));
Object yvalue = ejDataRecord.getValue(sItem.getName());
double val = 0;
if (yvalue instanceof Number) {
val = ((Number) yvalue).doubleValue();
}
data[index] = (val);
index++;
}
// rowInfo.setHidden(hidden);
rowInfo.setChartStyle(styles);
rowInfo.setBorderWidth(widths);
rowInfo.setAction("_pie_select");
chartRowData.addRow(rowInfo, data);
}
_chartView.load(chartRowData, options);
}
}
Aggregations