PDA

View Full Version : GXT : RadarChart in a form binded to a store



mask_hot
27 Jul 2010, 3:41 AM
Hi,
I made a form with 6 spinnerField.
I have a RadarChart in my Form which represents the data od the 6 spinnerField.
I'd like to update the chart when a spinnerField value is changed.

For the moment I did an updateChart function like this :


void updateChart(){
ChartModel cm = new ChartModel("Profil", "font-size: 12px; text-align: left;");
cm.setBackgroundColour("#f0f0f0");
RadarAxis ra = new RadarAxis();
ra.setMax(100);
ra.setStroke(2);
ra.setColour("#A1D4B5");
ra.setGridColour("#C0DEBF");
ra.setSpokeLabels("ATT", "TEC", "PUI", "DEF", "PHY", "VIT");
cm.setRadarAxis(ra);
AreaChart area = new AreaChart();
area.setFillAlpha(0.3f);
area.setColour("#ff9900");
area.setFillColour("#ff6600");
area.setLoop(true);
System.out.println("updateChart");
System.out.println("ATT "+sfATT.getValue());
area.addValues(sfATT.getValue());
area.addValues(sfTEC.getValue());
area.addValues(sfPUI.getValue());
area.addValues(sfDEF.getValue());
area.addValues(sfPHY.getValue());
area.addValues(sfVIT.getValue());
cm.addChartConfig(area);

chart.setChartModel(cm);

}


And I add for each spinnerField a listener to the Events.Change which calls the updateChart function.

It works but I think it's not very elegant. In fact, the Events.Change for the spinnerField seems to be more the Blur event (the chart is updated when I "blur" from a spinnerField and if I use the spin arrows, the Change event is not fired.
I'd like to bind the radarChart to the store which contains the record binded by the form.
I saw I have to use something like the DataProvider but I'm not sure it can be use with radarChart.

Any suggestions?

sven
27 Jul 2010, 5:13 AM
I dont think you want to update the chart everytime the spinnervalues changes.

The chagne event fires onblur as on other fields too.

mask_hot
27 Jul 2010, 5:46 AM
I'm doubting it could be costful but it would be "real-time"-like and nice :)

Ok for the change event, I keep it in mind.

sven
27 Jul 2010, 5:48 AM
set fireChangeEventonSetValue to true, spinning calls setvalue and so should update it asap. But i dont suggest to do it

mask_hot
27 Jul 2010, 6:30 AM
it works well!
here is a screenshot of my form.