use of io.jmix.ui.data.impl.ListDataProvider in project jmix by jmix-framework.
the class ChartsSerializationTest method testGanttChart.
@Test
public void testGanttChart() throws ParseException, IOException, URISyntaxException {
ListDataProvider dataProvider = new ListDataProvider();
dataProvider.addItem(taskSpan("1", "John", segment("s1", 7, 2, "#7B742C", "Task #1"), segment("s2", null, 2, "#7E585F", "Task #2"), segment("s3", null, 2, "#CF794A", "Task #3")));
dataProvider.addItem(taskSpan("2", "Smith", segment("s4", 10, 2, "#7E585F", "Task #2"), segment("s5", null, 1, "#CF794A", "Task #3"), segment("s6", null, 4, "#7B742C", "Task #1")));
dataProvider.addItem(taskSpan("3", "Ben", segment("s7", 12, 2, "#7E585F", "Task #2"), segment("s8", 16, 2, "#FFE4C4", "Task #4")));
dataProvider.addItem(taskSpan("4", "Mike", segment("s9", 9, 6, "#7B742C", "Task #1"), segment("s10", null, 4, "#7E585F", "Task #2")));
dataProvider.addItem(taskSpan("5", "Lenny", segment("s11", 8, 1, "#CF794A", "Task #3"), segment("s12", null, 4, "#7B742C", "Task #1")));
dataProvider.addItem(taskSpan("6", "Scott", segment("s13", 15, 3, "#7E585F", "Task #2")));
dataProvider.addItem(taskSpan("7", "Julia", segment("s14", 9, 2, "#7B742C", "Task #1"), segment("s15", null, 1, "#7E585F", "Task #2"), segment("s16", null, 8, "#CF794A", "Task #3")));
dataProvider.addItem(taskSpan("8", "Bob", segment("s17", 9, 8, "#7E585F", "Task #2"), segment("s18", null, 7, "#CF794A", "Task #3")));
dataProvider.addItem(taskSpan("9", "Kendra", segment("s19", 11, 8, "#7E585F", "Task #2"), segment("s20", 16, 2, "#FFE4C4", "Task #4")));
dataProvider.addItem(taskSpan("9", "Tom", segment("s21", 9, 4, "#7B742C", "Task #1"), segment("s22", null, 3, "#7E585F", "Task #2"), segment("s23", null, 5, "#CF794A", "Task #3")));
dataProvider.addItem(taskSpan("10", "Kyle", segment("s24", 6, 3, "#7E585F", "Task #2")));
dataProvider.addItem(taskSpan("11", "Anita", segment("s25", 12, 2, "#7E585F", "Task #2"), segment("s26", 16, 2, "#FFE4C4", "Task #4")));
dataProvider.addItem(taskSpan("12", "Jack", segment("s27", 8, 10, "#7B742C", "Task #1"), segment("s28", null, 2, "#7E585F", "Task #2")));
dataProvider.addItem(taskSpan("13", "Kim", segment("s29", 12, 2, "#7E585F", "Task #2"), segment("s30", null, 3, "#CF794A", "Task #3")));
dataProvider.addItem(taskSpan("14", "Aaron", segment("s31", 18, 2, "#7E585F", "Task #2"), segment("s32", null, 2, "#FFE4C4", "Task #4")));
dataProvider.addItem(taskSpan("15", "Alan", segment("s33", 17, 2, "#7B742C", "Task #1"), segment("s34", null, 2, "#7E585F", "Task #2"), segment("s35", null, 2, "#CF794A", "Task #3")));
dataProvider.addItem(taskSpan("16", "Ruth", segment("s36", 13, 2, "#7E585F", "Task #2"), segment("s37", null, 1, "#CF794A", "Task #3"), segment("s38", null, 4, "#7B742C", "Task #1")));
dataProvider.addItem(taskSpan("17", "Simon", segment("s39", 10, 3, "#7E585F", "Task #2"), segment("s40", 17, 4, "#FFE4C4", "Task #4")));
AbstractChart chart = new GanttChartModelImpl().setDataProvider(dataProvider).setTheme(ChartTheme.LIGHT).setMarginRight(70).setPeriod(DatePeriod.HOURS).setBalloonDateFormat("JJ:NN").setColumnWidth(0.5).setBrightnessStep(10).setRotate(true).setCategoryField("category").setSegmentsField("segments").setStartDate(df.parse("2015-01-01")).setColorField("color").setStartField("start").setEndField("end").setDurationField("duration").addAdditionalSegmentFields("task").setGraph(new Graph().setFillAlphas(1.0).setBalloonText("[[task]]: [[open]] [[value]]")).setValueAxis(new ValueAxis().setType(ValueAxisType.DATE).setMinimum(7.0).setMaximum(31.0)).setChartScrollbar(new Scrollbar()).setChartCursor(new Cursor().setValueBalloonsEnabled(false).setCursorAlpha(0.1).setValueLineBalloonEnabled(true).setValueLineEnabled(true).setFullWidth(true)).setExport(new Export());
ChartSerializer serializer = getTestSerializer();
String json = serializer.serialize(chart);
String expected = readFile("GanttChart.json");
assertEquals(prettyJson(expected), prettyJson(json));
}
use of io.jmix.ui.data.impl.ListDataProvider in project jmix by jmix-framework.
the class ChartModelLoader method loadChartData.
protected void loadChartData(ChartModel chart, Element element) {
Element dataElement = element.element("data");
if (dataElement != null) {
ListDataProvider listDataProvider = new ListDataProvider();
for (Object item : dataElement.elements("item")) {
Element itemElement = (Element) item;
MapDataItem dataItem = new MapDataItem();
for (Element property : itemElement.elements("property")) {
loadDataItem(property, dataItem);
}
listDataProvider.addItem(dataItem);
chart.setDataProvider(listDataProvider);
}
}
}
use of io.jmix.ui.data.impl.ListDataProvider in project jmix-docs by Haulmont.
the class PieChartExample method initDataProvider.
private DataProvider initDataProvider() {
ListDataProvider dataProvider = new ListDataProvider();
dataProvider.addItem(new MapDataItem(ImmutableMap.of("value", 75, "description", "Sky")));
dataProvider.addItem(new MapDataItem(ImmutableMap.of("value", 7, "description", "Shady side of pyramid")));
dataProvider.addItem(new MapDataItem(ImmutableMap.of("value", 18, "description", "Sunny side of pyramid")));
return dataProvider;
}
use of io.jmix.ui.data.impl.ListDataProvider in project jmix-docs by Haulmont.
the class MapDataItemScreen method onInit.
@Subscribe
protected void onInit(InitEvent event) {
ListDataProvider dataProvider = new ListDataProvider();
dataProvider.addItem(new MapDataItem(ImmutableMap.of("value", 75, "description", "Sky")));
dataProvider.addItem(new MapDataItem(ImmutableMap.of("value", 7, "description", "Shady side of pyramid")));
dataProvider.addItem(new MapDataItem(ImmutableMap.of("value", 18, "description", "Sunny side of pyramid")));
chart.setDataProvider(dataProvider);
// end::map-data-item[]
}
use of io.jmix.ui.data.impl.ListDataProvider in project jmix-docs by Haulmont.
the class SimpleDataItemScreen method onInit.
@Subscribe
protected void onInit(InitEvent event) {
ListDataProvider dataProvider = new ListDataProvider();
dataProvider.addItem(new SimpleDataItem(new ValueDescription(75, "Sky")));
dataProvider.addItem(new SimpleDataItem(new ValueDescription(7, "Shady side of pyramid")));
dataProvider.addItem(new SimpleDataItem(new ValueDescription(18, "Sunny side of pyramid")));
chart.setDataProvider(dataProvider);
}
Aggregations