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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations