O'Reilly logo

Ext GWT 2.0 Beginner's Guide by Daniel Vaughan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - creating PieChart data

  1. In FeedChart, add the following prepareData method. This is not part of the chart itself, but takes a list of items and counts the number of occurrences of each day to provide the data for use in the chart:
    private HashMap<String, Integer> prepareData(List<Item> items) {
    HashMap<String, Integer> days = new HashMap<String, Integer>();
    for (Item item : items) {
    DateTimeFormat fmt = DateTimeFormat.getFormat("EEEE");
    String day = fmt.format(item.getPubDate());
    Integer dayOccurance = days.get(day);
    if (dayOccurance == null) {
    days.put(day, 1);
    } else {
    days.put(day, ++dayOccurance);
    }
    }
    return days;
    }
    
  2. Create a new method named createChartModelData that takes a list of items as a parameter and returns a ChartModel: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required