use of org.xwiki.chart.model.ChartModel in project xwiki-platform by xwiki.
the class TableCategoryDatasetBuilderTest method testBuildCategoryDataset.
@Test
public void testBuildCategoryDataset() throws Exception {
String content = "| column 1 | column 2 | column 3 | column 4\n" + "| row 1 | 12 | 13 | 14 \n" + "| row 2 | 22 | 23 | 24 \n";
setUpContentExpectation(content);
getDataSource().buildDataset(content, map("type", "line", "range", "B2-D3"), null);
ChartModel chartModel = getDataSource().getChartModel();
Dataset dataset = chartModel.getDataset();
Assert.assertTrue(dataset instanceof CategoryDataset);
Assert.assertTrue(chartModel.getAxis(0) instanceof CategoryAxis);
Assert.assertTrue(chartModel.getAxis(1) instanceof ValueAxis);
CategoryDataset categoryDataset = (CategoryDataset) dataset;
Assert.assertTrue(categoryDataset.getRowKey(0).equals(" row 1 "));
Assert.assertTrue(categoryDataset.getRowKey(1).equals(" row 2 "));
Assert.assertTrue(categoryDataset.getColumnKey(0).equals(" column 2 "));
Assert.assertTrue(categoryDataset.getColumnKey(1).equals(" column 3 "));
Assert.assertTrue(categoryDataset.getColumnKey(2).equals(" column 4"));
Assert.assertTrue(categoryDataset.getValue(0, 0).intValue() == 12);
Assert.assertTrue(categoryDataset.getValue(0, 1).intValue() == 13);
Assert.assertTrue(categoryDataset.getValue(0, 2).intValue() == 14);
Assert.assertTrue(categoryDataset.getValue(1, 0).intValue() == 22);
Assert.assertTrue(categoryDataset.getValue(1, 1).intValue() == 23);
Assert.assertTrue(categoryDataset.getValue(1, 2).intValue() == 24);
}
use of org.xwiki.chart.model.ChartModel in project xwiki-platform by xwiki.
the class TableCategoryDatasetBuilderTest method testBuildCategoryDatasetColumnsSeries.
@Test
public void testBuildCategoryDatasetColumnsSeries() throws Exception {
String content = "| column 1 | column 2 | column 3 | column 4\n" + "| row 1 | 12 | 13 | 14 \n" + "| row 2 | 22 | 23 | 24 \n";
setUpContentExpectation(content);
getDataSource().buildDataset(content, map("type", "line", "range", "B2-D3", "series", "columns"), null);
ChartModel chartModel = getDataSource().getChartModel();
Dataset dataset = chartModel.getDataset();
Assert.assertTrue(dataset instanceof CategoryDataset);
Assert.assertTrue(chartModel.getAxis(0) instanceof CategoryAxis);
Assert.assertTrue(chartModel.getAxis(1) instanceof ValueAxis);
CategoryDataset categoryDataset = (CategoryDataset) dataset;
Assert.assertTrue(categoryDataset.getColumnKey(0).equals(" row 1 "));
Assert.assertTrue(categoryDataset.getColumnKey(1).equals(" row 2 "));
Assert.assertTrue(categoryDataset.getRowKey(0).equals(" column 2 "));
Assert.assertTrue(categoryDataset.getRowKey(1).equals(" column 3 "));
Assert.assertTrue(categoryDataset.getRowKey(2).equals(" column 4"));
Assert.assertTrue(categoryDataset.getValue(0, 0).intValue() == 12);
Assert.assertTrue(categoryDataset.getValue(1, 0).intValue() == 13);
Assert.assertTrue(categoryDataset.getValue(2, 0).intValue() == 14);
Assert.assertTrue(categoryDataset.getValue(0, 1).intValue() == 22);
Assert.assertTrue(categoryDataset.getValue(1, 1).intValue() == 23);
Assert.assertTrue(categoryDataset.getValue(2, 1).intValue() == 24);
}
use of org.xwiki.chart.model.ChartModel 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")));
}
use of org.xwiki.chart.model.ChartModel 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);
}
use of org.xwiki.chart.model.ChartModel in project xwiki-platform by xwiki.
the class TablePieDatasetBuilderTest method testBuildPieDataset.
@Test
public void testBuildPieDataset() throws Exception {
String content = "| column 1 | column 2 | column 3 | column 4\n" + "| row 1 | 12 | 13 | 14 \n" + "| row 2 | 22 | 23 | 24 \n";
setUpContentExpectation(content);
getDataSource().buildDataset(content, map("type", "pie", "range", "B2-D3"), null);
ChartModel chartModel = getDataSource().getChartModel();
Dataset dataset = chartModel.getDataset();
Assert.assertTrue(dataset instanceof PieDataset);
PieDataset pieDataset = (PieDataset) dataset;
Assert.assertTrue(pieDataset.getKey(0).equals(" row 1 "));
Assert.assertTrue(pieDataset.getKey(1).equals(" row 2 "));
Assert.assertTrue(pieDataset.getValue(0).intValue() == 12);
Assert.assertTrue(pieDataset.getValue(1).intValue() == 22);
}
Aggregations