Search in sources :

Example 21 with DCharts

use of org.dussan.vaadin.dcharts.DCharts in project cia by Hack23.

the class WorldIndicatorChartDataManagerImpl method createIndicatorChart.

@Override
public void createIndicatorChart(final AbstractOrderedLayout content, final List<WorldBankData> list, final ViewWorldbankIndicatorDataCountrySummary summary) {
    final Map<Country, List<WorldBankData>> countryIndicatorsMap = list.stream().collect(Collectors.groupingBy(WorldBankData::getCountry, Collectors.toList()));
    final Series series = new Series();
    final DataSeries dataSeries = new DataSeries();
    for (final Entry<Country, List<WorldBankData>> entry : countryIndicatorsMap.entrySet()) {
        series.addSeries(new XYseries().setLabel(entry.getKey().getValue()));
        dataSeries.newSeries();
        for (final WorldBankData item : entry.getValue()) {
            if (item != null && item.getYearDate() != null && item.getDataValue() != null && !item.getDataValue().isEmpty()) {
                dataSeries.add(item.getYearDate() + "-01-01", Float.valueOf(item.getDataValue()));
            }
        }
    }
    addChart(content, summary.getIndicatorName(), new DCharts().setDataSeries(dataSeries).setOptions(getChartOptions().createOptionsCountryLineChart(series)).show(), false);
}
Also used : DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) Series(org.dussan.vaadin.dcharts.options.Series) WorldBankData(com.hack23.cia.model.external.worldbank.data.impl.WorldBankData) Country(com.hack23.cia.model.external.worldbank.data.impl.Country) List(java.util.List) DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) DCharts(org.dussan.vaadin.dcharts.DCharts) XYseries(org.dussan.vaadin.dcharts.base.elements.XYseries)

Aggregations

DCharts (org.dussan.vaadin.dcharts.DCharts)21 DataSeries (org.dussan.vaadin.dcharts.data.DataSeries)19 Series (org.dussan.vaadin.dcharts.options.Series)18 XYseries (org.dussan.vaadin.dcharts.base.elements.XYseries)16 List (java.util.List)13 SimpleDateFormat (java.text.SimpleDateFormat)12 ViewRiksdagenVoteDataBallotPartySummaryDaily (com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPartySummaryDaily)3 DataContainer (com.hack23.cia.service.api.DataContainer)3 AbstractOrderedLayout (com.vaadin.ui.AbstractOrderedLayout)3 Locale (java.util.Locale)3 Map (java.util.Map)3 Entry (java.util.Map.Entry)3 Objects (java.util.Objects)3 Collectors (java.util.stream.Collectors)3 Service (org.springframework.stereotype.Service)3 ViewRiksdagenCommitteeDecisionTypeDailySummary (com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeDecisionTypeDailySummary)2 GovernmentBodyAnnualSummary (com.hack23.cia.service.external.esv.api.GovernmentBodyAnnualSummary)2 Label (com.vaadin.ui.Label)2 ArrayList (java.util.ArrayList)2 StringUtils (org.apache.commons.lang.StringUtils)2