Search in sources :

Example 6 with DCharts

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

the class DocumentChartDataManagerImpl method createDocumentTypeChart.

@Override
public void createDocumentTypeChart(final AbstractOrderedLayout content) {
    final Map<String, List<ViewRiksdagenDocumentTypeDailySummary>> map = getDocumentTypeMap();
    final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DD_MMM_YYYY, Locale.ENGLISH);
    final SimpleDateFormat parseInputDateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);
    final DataSeries dataSeries = new DataSeries();
    final Series series = new Series();
    for (final Entry<String, List<ViewRiksdagenDocumentTypeDailySummary>> entry : map.entrySet()) {
        if (entry.getKey() != null && !EMPTY_STRING.equals(entry.getKey())) {
            addDataSeries(simpleDateFormat, parseInputDateFormat, dataSeries, series, entry);
        }
    }
    addChart(content, "Document type", 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) List(java.util.List) DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) DCharts(org.dussan.vaadin.dcharts.DCharts) SimpleDateFormat(java.text.SimpleDateFormat)

Example 7 with DCharts

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

the class GovernmentBodyChartDataManagerImpl method createMinistryGovernmentBodyHeadcountSummaryChart.

@Override
public void createMinistryGovernmentBodyHeadcountSummaryChart(final AbstractOrderedLayout content) {
    final Map<Integer, List<GovernmentBodyAnnualSummary>> map = esvApi.getData();
    final List<String> ministryNames = esvApi.getMinistryNames();
    final DataSeries dataSeries = new DataSeries();
    final Series series = new Series();
    for (final String ministryName : ministryNames) {
        series.addSeries(new XYseries().setLabel(ministryName));
        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.getMinistry().equalsIgnoreCase(ministryName)).mapToInt(GovernmentBodyAnnualSummary::getHeadCount).sum();
            if (entry.getKey() != null && totalHeadcount > 0) {
                dataSeries.add(FIRST_OF_JAN + entry.getKey(), totalHeadcount);
            }
        }
    }
    addChart(content, ANNUAL_HEADCOUNT_ALL_MINISTRIES, 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 8 with DCharts

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

the class PartyChartDataManagerImpl method createPartyLineChart.

@Override
public void createPartyLineChart(final AbstractOrderedLayout content, final String partyId) {
    final List<ViewRiksdagenVoteDataBallotPartySummaryDaily> list = getViewRiksdagenVoteDataBallotPartySummaryDaily(partyId);
    final Series series = new Series().addSeries(new XYseries().setLabel(PARTY_WON)).addSeries(new XYseries().setLabel(PARTY_ABSENT));
    final DataSeries dataSeries = new DataSeries().newSeries();
    final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DD_MMM_YYYY, Locale.ENGLISH);
    if (list != null) {
        for (final ViewRiksdagenVoteDataBallotPartySummaryDaily viewRiksdagenVoteDataBallotPartySummaryDaily : list) {
            if (viewRiksdagenVoteDataBallotPartySummaryDaily != null) {
                dataSeries.add(simpleDateFormat.format(viewRiksdagenVoteDataBallotPartySummaryDaily.getEmbeddedId().getVoteDate()), viewRiksdagenVoteDataBallotPartySummaryDaily.getPartyWonPercentage());
            }
        }
        dataSeries.newSeries();
        for (final ViewRiksdagenVoteDataBallotPartySummaryDaily viewRiksdagenVoteDataBallotPartySummaryDaily : list) {
            if (viewRiksdagenVoteDataBallotPartySummaryDaily != null) {
                dataSeries.add(simpleDateFormat.format(viewRiksdagenVoteDataBallotPartySummaryDaily.getEmbeddedId().getVoteDate()), viewRiksdagenVoteDataBallotPartySummaryDaily.getPartyPercentageAbsent());
            }
        }
    }
    addChart(content, "Party result by", new DCharts().setDataSeries(dataSeries).setOptions(getChartOptions().createOptionsPartyLineChart(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) 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 9 with DCharts

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

the class PartyChartDataManagerImpl method createPartyBallotChart.

/**
 * Creates the party ballot chart.
 *
 * @param dataValueCalculator
 *            the data value calculator
 * @return the d charts
 */
private void createPartyBallotChart(final AbstractOrderedLayout content, final DataValueCalculator dataValueCalculator) {
    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()) {
        if (!"-".equals(entry.getKey())) {
            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()), dataValueCalculator.getDataValue(viewRiksdagenVoteDataBallotPartySummaryDaily));
                }
            }
        }
    }
    addChart(content, "Party ballot chart", 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 10 with DCharts

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

the class PartyDocumentChartDataManagerImpl method createDocumentHistoryPartyChart.

@Override
public void createDocumentHistoryPartyChart(final AbstractOrderedLayout content, final String org) {
    final DataSeries dataSeries = new DataSeries();
    final Series series = new Series();
    final Map<String, List<ViewRiksdagenPartyDocumentDailySummary>> allMap = getViewRiksdagenPartyDocumentDailySummaryMap();
    final List<ViewRiksdagenPartyDocumentDailySummary> itemList = allMap.get(org.toUpperCase(Locale.ENGLISH).replace(UNDER_SCORE, EMPTY_STRING).trim());
    if (itemList != null) {
        final Map<String, List<ViewRiksdagenPartyDocumentDailySummary>> map = itemList.parallelStream().filter(Objects::nonNull).collect(Collectors.groupingBy(t -> StringUtils.defaultIfBlank(t.getEmbeddedId().getDocumentType(), NO_INFO)));
        addDocumentHistoryByPartyData(dataSeries, series, map);
    }
    addChart(content, DOCUMENT_HISTORY_PARTY, new DCharts().setDataSeries(dataSeries).setOptions(getChartOptions().createOptionsXYDateFloatLegendInsideOneColumn(series)).show(), true);
}
Also used : DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) StringUtils(org.apache.commons.lang.StringUtils) Logger(org.slf4j.Logger) LoggerFactory(org.slf4j.LoggerFactory) SimpleDateFormat(java.text.SimpleDateFormat) RiksdagenDocumentPartySummaryEmbeddedId(com.hack23.cia.model.internal.application.data.document.impl.RiksdagenDocumentPartySummaryEmbeddedId) Collectors(java.util.stream.Collectors) PartyDocumentChartDataManager(com.hack23.cia.web.impl.ui.application.views.common.chartfactory.api.PartyDocumentChartDataManager) Objects(java.util.Objects) DCharts(org.dussan.vaadin.dcharts.DCharts) DataContainer(com.hack23.cia.service.api.DataContainer) List(java.util.List) Locale(java.util.Locale) Service(org.springframework.stereotype.Service) Map(java.util.Map) Series(org.dussan.vaadin.dcharts.options.Series) ViewRiksdagenPartyDocumentDailySummary(com.hack23.cia.model.internal.application.data.document.impl.ViewRiksdagenPartyDocumentDailySummary) Entry(java.util.Map.Entry) XYseries(org.dussan.vaadin.dcharts.base.elements.XYseries) AbstractOrderedLayout(com.vaadin.ui.AbstractOrderedLayout) DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) Series(org.dussan.vaadin.dcharts.options.Series) ViewRiksdagenPartyDocumentDailySummary(com.hack23.cia.model.internal.application.data.document.impl.ViewRiksdagenPartyDocumentDailySummary) DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) List(java.util.List) DCharts(org.dussan.vaadin.dcharts.DCharts)

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