Search in sources :

Example 1 with TimeTableXYDataset

use of org.jfree.data.time.TimeTableXYDataset in project cubrid-manager by CUBRID.

the class CombinedBarTimeSeriesChart method createTableSeriesDataset.

/**
	 * Creates a table dataset for series
	 * 
	 * @return Series 2.
	 */
private XYDataset createTableSeriesDataset() {
    timeTableXYCollection = new TimeTableXYDataset();
    for (Map.Entry<String, String> entry : valueMap.entrySet()) {
        String key = entry.getKey();
        timeTableXYCollection.add(new Second(), 0, key);
    }
    return timeTableXYCollection;
}
Also used : TimeTableXYDataset(org.jfree.data.time.TimeTableXYDataset) Second(org.jfree.data.time.Second) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 2 with TimeTableXYDataset

use of org.jfree.data.time.TimeTableXYDataset in project cubrid-manager by CUBRID.

the class CombinedBarTimeSeriesChart method updateFromScratch.

/**
	 * update series chart from scratch
	 * 
	 */
public void updateFromScratch() {
    if (isAreaRender) {
        ((TimeTableXYDataset) seriesdataset).clear();
    } else {
        ((TimeSeriesCollection) seriesdataset).removeAllSeries();
        if (seriesMap != null) {
            seriesMap.clear();
            for (Map.Entry<String, String> entry : valueMap.entrySet()) {
                String key = entry.getKey();
                TimeSeries series = new TimeSeries(key);
                seriesMap.put(key, series);
                ((TimeSeriesCollection) seriesdataset).addSeries(series);
            }
        }
    }
}
Also used : TimeTableXYDataset(org.jfree.data.time.TimeTableXYDataset) TimeSeries(org.jfree.data.time.TimeSeries) TimeSeriesCollection(org.jfree.data.time.TimeSeriesCollection) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 3 with TimeTableXYDataset

use of org.jfree.data.time.TimeTableXYDataset in project xwiki-platform by xwiki.

the class TableTimeTableXYDatasetBuilder method setParameters.

@Override
public void setParameters(Map<String, String> parameters) throws MacroExecutionException {
    String timePeriodTypeString = parameters.get(TIMEPERIOD_TYPE_PARAM);
    if (timePeriodTypeString != null) {
        this.timePeriodType = TimePeriodType.forName(timePeriodTypeString);
        if (this.timePeriodType == null) {
            throw new MacroExecutionException(String.format("Invalid time period type [%s].", timePeriodTypeString));
        }
    }
    dataset = new TimeTableXYDataset(localeConfiguration.getTimeZone(), localeConfiguration.getLocale());
}
Also used : TimeTableXYDataset(org.jfree.data.time.TimeTableXYDataset) MacroExecutionException(org.xwiki.rendering.macro.MacroExecutionException)

Example 4 with TimeTableXYDataset

use of org.jfree.data.time.TimeTableXYDataset in project xwiki-platform by xwiki.

the class TableTimeTableXYBuilderTest method testBuildTimeTableXY.

@Test
public void testBuildTimeTableXY() throws Exception {
    String content = "| Date | column 2 | column 3 | column 4\n" + "| 2012-01-01 10:30:10 | 12 | 13 | 14 \n" + "| 2012-01-01 10:30:20 |  22 | 23 | 24 \n";
    setUpContentExpectation(content);
    getDataSource().buildDataset(content, map("type", "xy_line_and_shape", "dataset", "timetable_xy", "range", "A2-D3", "locale", "en_US", "date_format", "yyyy-MM-dd kk:mm:ss", "domain_axis_type", "date"), null);
    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss", new Locale("en"));
    ChartModel chartModel = getDataSource().getChartModel();
    Assert.assertTrue(chartModel.getDataset() instanceof TimeTableXYDataset);
    Assert.assertTrue(chartModel.getAxis(0) instanceof DateAxis);
    Assert.assertTrue(chartModel.getAxis(1) instanceof ValueAxis);
    TimeTableXYDataset dataset = (TimeTableXYDataset) chartModel.getDataset();
    Assert.assertTrue(dataset.getSeriesCount() == 3);
    Assert.assertTrue(dataset.getSeriesKey(0).equals(" column 2 "));
    Assert.assertTrue(dataset.getSeriesKey(1).equals(" column 3 "));
    Assert.assertTrue(dataset.getSeriesKey(2).equals(" column 4"));
    Assert.assertTrue(dataset.getTimePeriod(0).getStart().equals(new Date(0)));
    Assert.assertTrue(dataset.getTimePeriod(0).getEnd().equals(dateFormat.parse("2012-01-01 10:30:10")));
    Assert.assertTrue(dataset.getTimePeriod(1).getStart().equals(dateFormat.parse("2012-01-01 10:30:10")));
    Assert.assertTrue(dataset.getTimePeriod(1).getEnd().equals(dateFormat.parse("2012-01-01 10:30:20")));
}
Also used : Locale(java.util.Locale) DateAxis(org.jfree.chart.axis.DateAxis) TimeTableXYDataset(org.jfree.data.time.TimeTableXYDataset) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) ValueAxis(org.jfree.chart.axis.ValueAxis) ChartModel(org.xwiki.chart.model.ChartModel) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Test(org.junit.Test)

Example 5 with TimeTableXYDataset

use of org.jfree.data.time.TimeTableXYDataset in project xwiki-platform by xwiki.

the class TableTimeTableXYBuilderTest method testYearInterval.

@Test
public void testYearInterval() throws Exception {
    String content = "| Date | column 2 | column 3 | column 4\n" + "| 1970  | 12 | 13 | 14 \n" + "| 1971 |  22 | 23 | 24 \n";
    setUpContentExpectation(content);
    getDataSource().buildDataset(content, map("type", "xy_line_and_shape", "dataset", "timetable_xy", "range", "A2-D3", "locale", "en_US", "date_format", "yyyy", "domain_axis_type", "date", "time_period", "year"), null);
    ChartModel chartModel = getDataSource().getChartModel();
    Assert.assertTrue(chartModel.getDataset() instanceof TimeTableXYDataset);
    Assert.assertTrue(chartModel.getAxis(0) instanceof DateAxis);
    Assert.assertTrue(chartModel.getAxis(1) instanceof ValueAxis);
}
Also used : DateAxis(org.jfree.chart.axis.DateAxis) TimeTableXYDataset(org.jfree.data.time.TimeTableXYDataset) ValueAxis(org.jfree.chart.axis.ValueAxis) ChartModel(org.xwiki.chart.model.ChartModel) Test(org.junit.Test)

Aggregations

TimeTableXYDataset (org.jfree.data.time.TimeTableXYDataset)6 Map (java.util.Map)3 TreeMap (java.util.TreeMap)3 DateAxis (org.jfree.chart.axis.DateAxis)2 ValueAxis (org.jfree.chart.axis.ValueAxis)2 Second (org.jfree.data.time.Second)2 Test (org.junit.Test)2 ChartModel (org.xwiki.chart.model.ChartModel)2 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 Locale (java.util.Locale)1 TimeSeries (org.jfree.data.time.TimeSeries)1 TimeSeriesCollection (org.jfree.data.time.TimeSeriesCollection)1 MacroExecutionException (org.xwiki.rendering.macro.MacroExecutionException)1