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