HighCharts-GXT/GWT Project The official HighCharts-GWT/GXT adapters blog

Managing series

In order to offer the maximum flexibility to handle charts two possible ways are offered to insert data inside series.

The former manages data in a more Java oriented fashion.
The latter method is more generic and better fits the underlaying javascript representation, so it is suggested to users skilled with HighCharts-JS API.

a) Using API to add Series to the highchart

The following example creates a chart having five series and each series has a different type according to the types declared in the array type.

final String types[] = new String[] {

final HighChart hc = new HighChart(null, "spline");
for (int i = 0 ; i < 5 ; i++) {
  SeriesType series = new SeriesType("line #" + (i+1));
  series.setType(types[i % types.length]);
  for (int j = 0; j < 5; j++) {
   series.addEntry(new SeriesType.SeriesDataEntry(com.google.gwt.user.client.Random.nextInt(500)));

b) Using path expressions for adding Series

final HighChart hc = new HighChart(null, "spline");
List<Map<String, Object>> series = new Vector<Map<String,Object>>();
// Series are handled as maps with entries for type, data, etc...
// (see http://www.highcharts.com/ref/#series for available options).
Map<String, Object> series1 = new HashMap<String, Object>();
series1.put("type", "area");
series1.put("data", new int[] {4,5,2,10});

Map<String, Object> series2 = new HashMap<String, Object>();
series2.put("type", "line");
series2.put("data", new int[] {14,53,0,7});


try {
  hc.setOption(new OptionPath("/series"), series);
} catch (Exception e) {
 // Handle exception