Search in sources :

Example 16 with XYseries

use of org.dussan.vaadin.dcharts.base.elements.XYseries in project cia by Hack23.

the class GovernmentBodyChartDataManagerImpl method createMinistryGovernmentBodyHeadcountSummaryChart.

@Override
public void createMinistryGovernmentBodyHeadcountSummaryChart(final AbstractOrderedLayout content, final String name) {
    final Map<Integer, List<GovernmentBodyAnnualSummary>> map = esvApi.getDataPerMinistry(name);
    final List<String> governmentBodyNames = esvApi.getGovernmentBodyNames(name);
    final DataSeries dataSeries = new DataSeries();
    final Series series = new Series();
    for (final String govBodyName : governmentBodyNames) {
        series.addSeries(new XYseries().setLabel(govBodyName));
        dataSeries.newSeries();
        for (final Entry<Integer, List<GovernmentBodyAnnualSummary>> entry : map.entrySet()) {
            final List<GovernmentBodyAnnualSummary> item = entry.getValue();
            final Integer totalHeadcount = item.stream().filter((final GovernmentBodyAnnualSummary p) -> p.getName().equalsIgnoreCase(govBodyName)).mapToInt(GovernmentBodyAnnualSummary::getHeadCount).sum();
            if (entry.getKey() != null && totalHeadcount > 0) {
                dataSeries.add(FIRST_OF_JAN + entry.getKey(), totalHeadcount);
            }
        }
    }
    addChart(content, name + ANNUAL_HEADCOUNT_SUMMARY_ALL_GOVERNMENT_BODIES, new DCharts().setDataSeries(dataSeries).setOptions(getChartOptions().createOptionsXYDateFloatLogYAxisLegendOutside(series)).show(), true);
}
Also used : DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) Series(org.dussan.vaadin.dcharts.options.Series) List(java.util.List) DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) GovernmentBodyAnnualSummary(com.hack23.cia.service.external.esv.api.GovernmentBodyAnnualSummary) DCharts(org.dussan.vaadin.dcharts.DCharts) XYseries(org.dussan.vaadin.dcharts.base.elements.XYseries)

Example 17 with XYseries

use of org.dussan.vaadin.dcharts.base.elements.XYseries in project cia by Hack23.

the class PartyChartDataManagerImpl method createPartyWinnerChart.

@Override
public void createPartyWinnerChart(final AbstractOrderedLayout content) {
    final Map<String, List<ViewRiksdagenVoteDataBallotPartySummaryDaily>> map = getPartyMap();
    final DataSeries dataSeries = new DataSeries();
    final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DD_MMM_YYYY, Locale.ENGLISH);
    final Series series = new Series();
    for (final Entry<String, List<ViewRiksdagenVoteDataBallotPartySummaryDaily>> entry : map.entrySet()) {
        series.addSeries(new XYseries().setLabel(getPartyName(entry.getKey())));
        dataSeries.newSeries();
        final List<ViewRiksdagenVoteDataBallotPartySummaryDaily> list = entry.getValue();
        for (final ViewRiksdagenVoteDataBallotPartySummaryDaily viewRiksdagenVoteDataBallotPartySummaryDaily : list) {
            if (viewRiksdagenVoteDataBallotPartySummaryDaily != null) {
                dataSeries.add(simpleDateFormat.format(viewRiksdagenVoteDataBallotPartySummaryDaily.getEmbeddedId().getVoteDate()), viewRiksdagenVoteDataBallotPartySummaryDaily.getPartyWonPercentage());
            }
        }
    }
    series.addSeries(new XYseries().setLabel(NUMBER_BALLOTS));
    dataSeries.newSeries();
    final List<ViewRiksdagenVoteDataBallotPartySummaryDaily> list = getMaxSizeViewRiksdagenVoteDataBallotPartySummaryDaily();
    for (final ViewRiksdagenVoteDataBallotPartySummaryDaily viewRiksdagenVoteDataBallotPartySummaryDaily : list) {
        if (viewRiksdagenVoteDataBallotPartySummaryDaily != null) {
            dataSeries.add(simpleDateFormat.format(viewRiksdagenVoteDataBallotPartySummaryDaily.getEmbeddedId().getVoteDate()), viewRiksdagenVoteDataBallotPartySummaryDaily.getNumberBallots());
        }
    }
    addChart(content, "Party winner by daily ballot average", new DCharts().setDataSeries(dataSeries).setOptions(getChartOptions().createOptionsXYDateFloatLegendInsideOneColumn(series)).show(), true);
}
Also used : DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) Series(org.dussan.vaadin.dcharts.options.Series) ViewRiksdagenVoteDataBallotPartySummaryDaily(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPartySummaryDaily) ArrayList(java.util.ArrayList) 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) SimpleDateFormat(java.text.SimpleDateFormat)

Example 18 with XYseries

use of org.dussan.vaadin.dcharts.base.elements.XYseries in project cia by Hack23.

the class PartyDocumentChartDataManagerImpl method addDocumentHistoryByPartyData.

/**
 * Adds the document history by party data.
 *
 * @param dataSeries
 *            the data series
 * @param series
 *            the series
 * @param map
 *            the map
 */
private static void addDocumentHistoryByPartyData(final DataSeries dataSeries, final Series series, final Map<String, List<ViewRiksdagenPartyDocumentDailySummary>> map) {
    final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DD_MMM_YYYY, Locale.ENGLISH);
    for (final Entry<String, List<ViewRiksdagenPartyDocumentDailySummary>> entry : map.entrySet()) {
        series.addSeries(new XYseries().setLabel(entry.getKey()));
        dataSeries.newSeries();
        if (entry.getValue() != null) {
            for (final ViewRiksdagenPartyDocumentDailySummary item : entry.getValue()) {
                if (item != null) {
                    dataSeries.add(simpleDateFormat.format(item.getEmbeddedId().getPublicDate()), item.getTotal());
                }
            }
        } else {
            LOGGER.info(LOG_MSG_MISSING_DATA_FOR_KEY, entry);
        }
    }
}
Also used : ViewRiksdagenPartyDocumentDailySummary(com.hack23.cia.model.internal.application.data.document.impl.ViewRiksdagenPartyDocumentDailySummary) List(java.util.List) XYseries(org.dussan.vaadin.dcharts.base.elements.XYseries) SimpleDateFormat(java.text.SimpleDateFormat)

Example 19 with XYseries

use of org.dussan.vaadin.dcharts.base.elements.XYseries 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

XYseries (org.dussan.vaadin.dcharts.base.elements.XYseries)19 DCharts (org.dussan.vaadin.dcharts.DCharts)13 DataSeries (org.dussan.vaadin.dcharts.data.DataSeries)13 Series (org.dussan.vaadin.dcharts.options.Series)13 List (java.util.List)11 SimpleDateFormat (java.text.SimpleDateFormat)9 ViewRiksdagenVoteDataBallotPartySummaryDaily (com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPartySummaryDaily)3 GovernmentBodyAnnualSummary (com.hack23.cia.service.external.esv.api.GovernmentBodyAnnualSummary)2 ParseException (java.text.ParseException)2 ArrayList (java.util.ArrayList)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 Country (com.hack23.cia.model.external.worldbank.data.impl.Country)1 WorldBankData (com.hack23.cia.model.external.worldbank.data.impl.WorldBankData)1 ViewRiksdagenCommitteeDecisionTypeDailySummary (com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeDecisionTypeDailySummary)1 ViewRiksdagenCommitteeDecisionTypeOrgDailySummary (com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeDecisionTypeOrgDailySummary)1 ViewRiksdagenVoteDataBallotPartySummary (com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPartySummary)1 ViewRiksdagenVoteDataBallotPoliticianSummaryDaily (com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPoliticianSummaryDaily)1 ViewRiksdagenDocumentTypeDailySummary (com.hack23.cia.model.internal.application.data.document.impl.ViewRiksdagenDocumentTypeDailySummary)1 ViewRiksdagenOrgDocumentDailySummary (com.hack23.cia.model.internal.application.data.document.impl.ViewRiksdagenOrgDocumentDailySummary)1 ViewRiksdagenPartyDocumentDailySummary (com.hack23.cia.model.internal.application.data.document.impl.ViewRiksdagenPartyDocumentDailySummary)1