use of org.hisp.dhis.period.RelativePeriods in project dhis2-core by dhis2.
the class DefaultChartService method getJFreeOrganisationUnitChart.
@Override
public JFreeChart getJFreeOrganisationUnitChart(Indicator indicator, OrganisationUnit parent, boolean title, I18nFormat format) {
List<Period> periods = periodService.reloadPeriods(new RelativePeriods().setThisYear(true).getRelativePeriods(format, true));
Chart chart = new Chart();
if (title) {
chart.setName(indicator.getName());
}
chart.setType(ChartType.COLUMN);
chart.setDimensions(DimensionalObject.DATA_X_DIM_ID, DimensionalObject.ORGUNIT_DIM_ID, DimensionalObject.PERIOD_DIM_ID);
chart.setHideLegend(true);
chart.addDataDimensionItem(indicator);
chart.setPeriods(periods);
chart.setOrganisationUnits(parent.getSortedChildren());
chart.setHideSubtitle(title);
chart.setFormat(format);
return getJFreeChart(chart);
}
use of org.hisp.dhis.period.RelativePeriods in project dhis2-core by dhis2.
the class ReportTableStoreTest method setUpTest.
@Override
public void setUpTest() throws Exception {
dataElements = new ArrayList<>();
indicators = new ArrayList<>();
reportingRates = new ArrayList<>();
periods = new ArrayList<>();
units = new ArrayList<>();
indicatorType = createIndicatorType('A');
indicatorService.addIndicatorType(indicatorType);
periodType = PeriodType.getPeriodTypeByName(MonthlyPeriodType.NAME);
dataElementA = createDataElement('A');
dataElementB = createDataElement('B');
dataElementService.addDataElement(dataElementA);
dataElementService.addDataElement(dataElementB);
dataElements.add(dataElementA);
dataElements.add(dataElementB);
indicatorA = createIndicator('A', indicatorType);
indicatorB = createIndicator('B', indicatorType);
indicatorService.addIndicator(indicatorA);
indicatorService.addIndicator(indicatorB);
indicators.add(indicatorA);
indicators.add(indicatorB);
DataSet dataSetA = createDataSet('A', periodType);
DataSet dataSetB = createDataSet('B', periodType);
dataSetService.addDataSet(dataSetA);
dataSetService.addDataSet(dataSetB);
reportingRateA = new ReportingRate(dataSetA);
reportingRateB = new ReportingRate(dataSetB);
reportingRates.add(reportingRateA);
reportingRates.add(reportingRateB);
periodA = createPeriod(periodType, getDate(2000, 1, 1), getDate(2000, 1, 31));
periodB = createPeriod(periodType, getDate(2000, 2, 1), getDate(2000, 2, 28));
periodService.addPeriod(periodA);
periodService.addPeriod(periodB);
periods.add(periodA);
periods.add(periodB);
unitA = createOrganisationUnit('A');
unitB = createOrganisationUnit('B');
organisationUnitService.addOrganisationUnit(unitA);
organisationUnitService.addOrganisationUnit(unitB);
units.add(unitA);
units.add(unitB);
relativesA = new RelativePeriods();
relativesA.setLastMonth(true);
relativesA.setThisYear(true);
relativesB = new RelativePeriods();
relativesB.setLastMonth(true);
relativesB.setThisYear(true);
relativesC = new RelativePeriods();
relativesC.setLastMonth(true);
relativesC.setThisYear(true);
}
Aggregations