Search in sources :

Example 16 with DCharts

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

the class DecisionChartDataManagerImpl method createDecisionTypeChart.

@Override
public void createDecisionTypeChart(final AbstractOrderedLayout content, final String org) {
    final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DD_MMM_YYYY, Locale.ENGLISH);
    final DataSeries dataSeries = new DataSeries();
    final Series series = new Series();
    final Map<String, List<ViewRiksdagenCommitteeDecisionTypeOrgDailySummary>> allMap = getCommitteeDecisionTypeOrgMap();
    final List<ViewRiksdagenCommitteeDecisionTypeOrgDailySummary> itemList = allMap.get(org.toUpperCase(Locale.ENGLISH).replace(UNDER_SCORE, EMPTY_STRING).trim());
    if (itemList != null) {
        final Map<String, List<ViewRiksdagenCommitteeDecisionTypeOrgDailySummary>> map = itemList.parallelStream().filter(t -> t != null && t.getEmbeddedId().getDecisionDate() != null).collect(Collectors.groupingBy(t -> t.getEmbeddedId().getDecisionType()));
        addDecisionTypeByOrgData(simpleDateFormat, dataSeries, series, map);
    }
    addChart(content, "Org Decision type daily summary", new DCharts().setDataSeries(dataSeries).setOptions(getChartOptions().createOptionsXYDateFloatLegendInsideOneColumn(series)).show(), true);
}
Also used : DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) GregorianCalendar(java.util.GregorianCalendar) Date(java.util.Date) SimpleDateFormat(java.text.SimpleDateFormat) Collectors(java.util.stream.Collectors) DecisionChartDataManager(com.hack23.cia.web.impl.ui.application.views.common.chartfactory.api.DecisionChartDataManager) ViewRiksdagenCommitteeDecisionTypeOrgDailySummary(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeDecisionTypeOrgDailySummary) Objects(java.util.Objects) RiksdagenCommitteeDecisionTypeOrgSummaryEmbeddedId(com.hack23.cia.model.internal.application.data.committee.impl.RiksdagenCommitteeDecisionTypeOrgSummaryEmbeddedId) DCharts(org.dussan.vaadin.dcharts.DCharts) DataContainer(com.hack23.cia.service.api.DataContainer) List(java.util.List) Calendar(java.util.Calendar) ViewRiksdagenCommitteeDecisionTypeDailySummary(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeDecisionTypeDailySummary) RiksdagenCommitteeDecisionTypeSummaryEmbeddedId(com.hack23.cia.model.internal.application.data.committee.impl.RiksdagenCommitteeDecisionTypeSummaryEmbeddedId) Locale(java.util.Locale) Service(org.springframework.stereotype.Service) Map(java.util.Map) Series(org.dussan.vaadin.dcharts.options.Series) 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) ViewRiksdagenCommitteeDecisionTypeOrgDailySummary(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeDecisionTypeOrgDailySummary) DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) List(java.util.List) DCharts(org.dussan.vaadin.dcharts.DCharts) SimpleDateFormat(java.text.SimpleDateFormat)

Example 17 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 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 18 with DCharts

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

the class OrgDocumentChartDataManagerImpl method createDocumentHistoryChartByOrg.

@Override
public void createDocumentHistoryChartByOrg(final AbstractOrderedLayout content, final String org) {
    final String searchOrg = org.toUpperCase(Locale.ENGLISH).replace(UNDER_SCORE, EMPTY_STRING).replace(MINUS_SIGN, EMPTY_STRING).trim();
    final DataSeries dataSeries = new DataSeries();
    final Series series = new Series();
    final Map<String, List<ViewRiksdagenOrgDocumentDailySummary>> allMap = getViewRiksdagenOrgDocumentDailySummaryMap();
    final List<ViewRiksdagenOrgDocumentDailySummary> itemList = allMap.get(searchOrg);
    if (itemList != null) {
        addDocumentHistoryByOrgData(dataSeries, series, itemList);
    }
    addChart(content, DOCUMENT_HISTORY_BY_ORG, 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) DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) List(java.util.List) DCharts(org.dussan.vaadin.dcharts.DCharts) ViewRiksdagenOrgDocumentDailySummary(com.hack23.cia.model.internal.application.data.document.impl.ViewRiksdagenOrgDocumentDailySummary)

Example 19 with DCharts

use of org.dussan.vaadin.dcharts.DCharts 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 20 with DCharts

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

the class PersonDocumentChartDataManagerImpl method createPersonDocumentHistoryChart.

@Override
public void createPersonDocumentHistoryChart(final AbstractOrderedLayout content, final String personId) {
    final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DD_MMM_YYYY, Locale.ENGLISH);
    final DataSeries dataSeries = new DataSeries();
    final Series series = new Series();
    final Map<String, List<ViewRiksdagenPoliticianDocumentDailySummary>> allMap = getViewRiksdagenPoliticianDocumentDailySummaryMap();
    final List<ViewRiksdagenPoliticianDocumentDailySummary> itemList = allMap.get(personId.toUpperCase(Locale.ENGLISH).replace(UNDER_SCORE, EMPTY_STRING).trim());
    if (itemList != null) {
        final Map<String, List<ViewRiksdagenPoliticianDocumentDailySummary>> map = itemList.parallelStream().filter(Objects::nonNull).collect(Collectors.groupingBy(t -> StringUtils.defaultIfBlank(t.getEmbeddedId().getDocumentType(), NO_INFO)));
        addDocumentHistoryByPersonData(simpleDateFormat, dataSeries, series, map);
    }
    addChart(content, DOCUMENT_HISTORY, 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) PersonDocumentChartDataManager(com.hack23.cia.web.impl.ui.application.views.common.chartfactory.api.PersonDocumentChartDataManager) LoggerFactory(org.slf4j.LoggerFactory) SimpleDateFormat(java.text.SimpleDateFormat) ViewRiksdagenPoliticianDocumentDailySummary(com.hack23.cia.model.internal.application.data.document.impl.ViewRiksdagenPoliticianDocumentDailySummary) Collectors(java.util.stream.Collectors) RiksdagenDocumentPersonSummaryEmbeddedId(com.hack23.cia.model.internal.application.data.document.impl.RiksdagenDocumentPersonSummaryEmbeddedId) 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) 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) DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) List(java.util.List) DCharts(org.dussan.vaadin.dcharts.DCharts) SimpleDateFormat(java.text.SimpleDateFormat) ViewRiksdagenPoliticianDocumentDailySummary(com.hack23.cia.model.internal.application.data.document.impl.ViewRiksdagenPoliticianDocumentDailySummary)

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