Search in sources :

Example 6 with RelativePeriods

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);
}
Also used : RelativePeriods(org.hisp.dhis.period.RelativePeriods) Period(org.hisp.dhis.period.Period) Chart(org.hisp.dhis.chart.Chart) BaseChart(org.hisp.dhis.chart.BaseChart) JFreeChart(org.jfree.chart.JFreeChart)

Example 7 with RelativePeriods

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);
}
Also used : RelativePeriods(org.hisp.dhis.period.RelativePeriods) DataSet(org.hisp.dhis.dataset.DataSet) ReportingRate(org.hisp.dhis.common.ReportingRate)

Aggregations

RelativePeriods (org.hisp.dhis.period.RelativePeriods)7 Period (org.hisp.dhis.period.Period)6 BaseChart (org.hisp.dhis.chart.BaseChart)2 Chart (org.hisp.dhis.chart.Chart)2 ReportingRate (org.hisp.dhis.common.ReportingRate)2 DataSet (org.hisp.dhis.dataset.DataSet)2 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)2 JFreeChart (org.jfree.chart.JFreeChart)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 List (java.util.List)1 Calendar (org.hisp.dhis.calendar.Calendar)1 DateTimeUnit (org.hisp.dhis.calendar.DateTimeUnit)1 BaseDimensionalObject (org.hisp.dhis.common.BaseDimensionalObject)1 BaseIdentifiableObject (org.hisp.dhis.common.BaseIdentifiableObject)1 DataDimensionItem (org.hisp.dhis.common.DataDimensionItem)1 DimensionType (org.hisp.dhis.common.DimensionType)1 DimensionalItemObject (org.hisp.dhis.common.DimensionalItemObject)1 DimensionalObject (org.hisp.dhis.common.DimensionalObject)1 UniqueArrayList (org.hisp.dhis.commons.collection.UniqueArrayList)1