1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| IlvChartInteractor highlight = new IlvChartHighlightInteractor() {
protected IlvDisplayPoint pickData(IlvChartDataPicker picker) {
IlvDisplayPoint dp = super.pickData (picker);
if(dp != null) {
IlvDataRenderingHint hint = new IlvDefaultDataRenderingHint(new IlvStyle(Color.GREEN));
dp.getRenderer().setRenderingHint(dp.getDataSet(), dp.getIndex(), hint);
String asset = dp.getDataSet().getDataLabel(dp.getIndex());
int otherPointIdx = 0;
if(this.getChart().getDataSource().getDataSetCount()>1) { // si il y a 2 nuages de points
// cherche l'indice du point jumeau dans l'autre dataset
for(int i = 0 ; i < this.getChart().getDataSource().getDataSet(1).getDataCount() ; ++i) {
String otherAsset = this.getChart().getDataSource().getDataSet(1).getDataLabel(i);
if(asset.contains(otherAsset))
otherPointIdx = i;
}
// NE MARCHE PAS
IlvDisplayPoint otherPoint = this.getChart().getDisplayItems(picker).get(otherPointIdx);
otherPoint.getRenderer().setRenderingHint(otherPoint.getDataSet(), otherPointIdx, hint);
setHighlightedPoint(otherPoint);
}
System.out.println(dp);
return dp;
} else {
return null;
}
}
};
_chart.addInteractor(highlight); |
Partager