I’m trying to use a Gauge Chart to report the performance of a KPI using a value collection datasource. Unfortunately, it seems like the same chart with the same vaues is being displayed on all KPI’s that I select.
What am I doing wrong?
This is what I have:
ProjectkpiEdit.xml
<valueCollectionDatasource id="kpiGaugeDs">
<query>
<![CDATA[select k.baseline as baseline, k.target as target, k.actual+k.baseline as actuals
from ppm$KPI k]]>
</query>
<properties>
<property datatype="int"
name="baseline"/>
<property datatype="int"
name="target"/>
<property datatype="int"
name="actuals"/>
</properties>
</valueCollectionDatasource>
<chart:gaugeChart id="gaugeChart"
datasource="kpiGaugeDs"
height="300px">
<chart:axes>
<chart:axis id="gaugeChartAxis"
axisAlpha="1"
axisColor="BROWN"
axisThickness="3"
bottomTextYOffset="-20"
tickAlpha="0.5"
tickColor="BROWN">
<!-- valueInterval="100"-->
</chart:axis>
</chart:axes>
<chart:arrows>
<!--chart:arrow color="" -->
<chart:arrow/>
</chart:arrows>
<chart:export/>
</chart:gaugeChart>'''
ProjectkpiEdit.java;
@public class ProjectkpiEdit extends AbstractEditor<KPI> {
@Inject
private CollectionDatasource<KeyValueEntity, Object> kpiGaugeDs;
@Inject
private AngularGaugeChart gaugeChart;
@Override
protected void postInit() {
super.postInit();
kpiGaugeDs.refresh();
KeyValueEntity value = kpiGaugeDs.getItems().iterator().next();
Integer startValue = (Integer)value.getValue("baseline");
Integer endValue = (Integer)value.getValue("target");
Integer actuals = (Integer)value.getValue("actuals");
String bottomText = String.valueOf((Integer)value.getValue("actuals"));
gaugeChart.getAxes().get(0).setStartValue(Double.valueOf(startValue));
gaugeChart.getAxes().get(0).setEndValue(Double.valueOf(endValue));
gaugeChart.getAxes().get(0).setBottomText(bottomText+"/"+endValue);
gaugeChart.getArrows().get(0).setValue(Double.valueOf(actuals)>Double.valueOf(endValue)?Double.valueOf(endValue):Double.valueOf(actuals));
}'''
kpi.java
@Column(name = "INDICATOR_")
protected String indicator;
@Column(name = "MEASURE")
protected String measure;
@Column(name = "WEIGHT")
protected Integer weight;
@Column(name = "BASELINE")
protected Integer baseline;
@Column(name = "TARGET")
protected Integer target;
@Column(name = "BUDGET")
protected Double budget = 0.0;
@Column(name = "COST")
protected Double cost = 0.0;
@Column(name = "ACTUAL")
protected Integer actual = 0;'''