Search in sources :

Example 6 with ListDataProvider

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));
}
Also used : ListDataProvider(io.jmix.ui.data.impl.ListDataProvider) Graph(io.jmix.charts.model.graph.Graph) ChartSerializer(io.jmix.charts.widget.amcharts.serialization.ChartSerializer) ValueAxis(io.jmix.charts.model.axis.ValueAxis) Export(io.jmix.charts.model.export.Export) Cursor(io.jmix.charts.model.cursor.Cursor) Scrollbar(io.jmix.charts.model.Scrollbar) Test(org.junit.jupiter.api.Test)

Example 7 with ListDataProvider

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);
        }
    }
}
Also used : ListDataProvider(io.jmix.ui.data.impl.ListDataProvider) Element(org.dom4j.Element) MapDataItem(io.jmix.ui.data.impl.MapDataItem)

Example 8 with 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;
}
Also used : ListDataProvider(io.jmix.ui.data.impl.ListDataProvider) MapDataItem(io.jmix.ui.data.impl.MapDataItem)

Example 9 with ListDataProvider

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[]
}
Also used : ListDataProvider(io.jmix.ui.data.impl.ListDataProvider) MapDataItem(io.jmix.ui.data.impl.MapDataItem) Subscribe(io.jmix.ui.screen.Subscribe)

Example 10 with ListDataProvider

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);
}
Also used : ListDataProvider(io.jmix.ui.data.impl.ListDataProvider) SimpleDataItem(io.jmix.ui.data.impl.SimpleDataItem) Subscribe(io.jmix.ui.screen.Subscribe)

Aggregations

ListDataProvider (io.jmix.ui.data.impl.ListDataProvider)17 MapDataItem (io.jmix.ui.data.impl.MapDataItem)9 Test (org.junit.jupiter.api.Test)6 Export (io.jmix.charts.model.export.Export)5 Subscribe (io.jmix.ui.screen.Subscribe)5 ChartSerializer (io.jmix.charts.widget.amcharts.serialization.ChartSerializer)4 Scrollbar (io.jmix.charts.model.Scrollbar)3 ValueAxis (io.jmix.charts.model.axis.ValueAxis)3 Cursor (io.jmix.charts.model.cursor.Cursor)3 Graph (io.jmix.charts.model.graph.Graph)3 Element (org.dom4j.Element)3 StockChartGroup (io.jmix.charts.model.chart.impl.StockChartGroup)2 StockPanel (io.jmix.charts.model.chart.impl.StockPanel)2 DataSet (io.jmix.charts.model.dataset.DataSet)2 FieldMapping (io.jmix.charts.model.dataset.FieldMapping)2 Period (io.jmix.charts.model.period.Period)2 PeriodSelector (io.jmix.charts.model.period.PeriodSelector)2 ChartCursorSettings (io.jmix.charts.model.settings.ChartCursorSettings)2 ChartScrollbarSettings (io.jmix.charts.model.settings.ChartScrollbarSettings)2 StockGraph (io.jmix.charts.model.stock.StockGraph)2