Search in sources :

Example 1 with ListDataProvider

use of io.jmix.ui.data.impl.ListDataProvider in project jmix-docs by Haulmont.

the class EntityData method onInit.

@Subscribe
protected void onInit(InitEvent event) {
    ListDataProvider dataProvider = new ListDataProvider();
    dataProvider.addItem(new EntityDataItem((Entity) valueDescription(75, "Sky")));
    dataProvider.addItem(new EntityDataItem((Entity) valueDescription(7, "Shady side of pyramid")));
    dataProvider.addItem(new EntityDataItem((Entity) valueDescription(18, "Sunny side of pyramid")));
    chart.setDataProvider(dataProvider);
}
Also used : ListDataProvider(io.jmix.ui.data.impl.ListDataProvider) Entity(io.jmix.core.Entity) EntityDataItem(io.jmix.ui.data.impl.EntityDataItem)

Example 2 with ListDataProvider

use of io.jmix.ui.data.impl.ListDataProvider in project jmix-docs by Haulmont.

the class SerialChartJsonTitleTwo method onInit.

@Subscribe
private void onInit(InitEvent event) {
    ListDataProvider serialChartDataProvider = new ListDataProvider();
    int[] serialChartData = { 5, 7, 6, 9, 7, 8, 5, 6, 4, 6, 5, 7, 4, 5, 3, 4, 2, 0 };
    for (int i = 0; i < serialChartData.length; i++) {
        serialChartDataProvider.addItem(graphData(serialChartData[i]));
    }
    serialChart.setDataProvider(serialChartDataProvider);
}
Also used : ListDataProvider(io.jmix.ui.data.impl.ListDataProvider) Subscribe(io.jmix.ui.screen.Subscribe)

Example 3 with ListDataProvider

use of io.jmix.ui.data.impl.ListDataProvider in project jmix-docs by Haulmont.

the class SerialChartJsonTitle method onInit.

@Subscribe
private void onInit(InitEvent event) {
    ListDataProvider serialChartDataProvider = new ListDataProvider();
    int[] serialChartData = { 5, 7, 6, 9, 7, 8, 5, 6, 4, 6, 5, 7, 4, 5, 3, 4, 2, 0 };
    for (int i = 0; i < serialChartData.length; i++) {
        serialChartDataProvider.addItem(graphData(serialChartData[i]));
    }
    serialChart.setDataProvider(serialChartDataProvider);
    // end::json-title1[]
    // tag::json[]
    serialChart.setNativeJson("{\n" + " \"titles\": [\n" + " {\n" + " \"size\": 15,\n" + " \"text\": \"Chart Title\"\n" + " }\n" + " ]\n" + "}");
// end::json[]
// tag::json-title2[]
}
Also used : ListDataProvider(io.jmix.ui.data.impl.ListDataProvider) Subscribe(io.jmix.ui.screen.Subscribe)

Example 4 with ListDataProvider

use of io.jmix.ui.data.impl.ListDataProvider in project jmix-docs by Haulmont.

the class StackedareaChart method onInit.

@Subscribe
private void onInit(InitEvent event) {
    ListDataProvider dataProvider = new ListDataProvider();
    dataProvider.addItem(transportCount(1994, 1587, 650, 121));
    dataProvider.addItem(transportCount(1995, 1567, 683, 146));
    dataProvider.addItem(transportCount(1996, 1617, 691, 138));
    dataProvider.addItem(transportCount(1997, 1630, 642, 127));
    dataProvider.addItem(transportCount(1998, 1660, 699, 105));
    dataProvider.addItem(transportCount(1999, 1683, 721, 109));
    dataProvider.addItem(transportCount(2000, 1691, 737, 112));
    dataProvider.addItem(transportCount(2001, 1298, 680, 101));
    dataProvider.addItem(transportCount(2002, 1275, 664, 97));
    dataProvider.addItem(transportCount(2003, 1246, 648, 93));
    dataProvider.addItem(transportCount(2004, 1318, 697, 111));
    dataProvider.addItem(transportCount(2005, 1213, 633, 87));
    dataProvider.addItem(transportCount(2006, 1199, 621, 79));
    dataProvider.addItem(transportCount(2007, 1110, 210, 81));
    dataProvider.addItem(transportCount(2008, 1165, 232, 75));
    dataProvider.addItem(transportCount(2009, 1145, 219, 88));
    dataProvider.addItem(transportCount(2010, 1163, 201, 82));
    dataProvider.addItem(transportCount(2011, 1180, 285, 87));
    dataProvider.addItem(transportCount(2012, 1159, 277, 71));
    chart.setDataProvider(dataProvider);
}
Also used : ListDataProvider(io.jmix.ui.data.impl.ListDataProvider) Subscribe(io.jmix.ui.screen.Subscribe)

Example 5 with ListDataProvider

use of io.jmix.ui.data.impl.ListDataProvider in project jmix by jmix-framework.

the class ChartsSerializationTest method testSerialChart.

@Test
public void testSerialChart() throws IOException, URISyntaxException, ParseException {
    DataProvider dataProvider = new ListDataProvider();
    dataProvider.addItem(new MapDataItem(ParamsMap.of("id", "1", "date", "2012-07-27", "value", 13)));
    dataProvider.addItem(new MapDataItem(ParamsMap.of("id", "2", "date", "2012-07-28", "value", 11)));
    dataProvider.addItem(new MapDataItem(ParamsMap.of("id", "3", "date", "2012-07-29", "value", 15)));
    dataProvider.addItem(new MapDataItem(ParamsMap.of("id", "4", "date", "2012-07-30", "value", 16)));
    dataProvider.addItem(new MapDataItem(ParamsMap.of("id", "5", "date", "2012-07-31", "value", 18)));
    dataProvider.addItem(new MapDataItem(ParamsMap.of("id", "6", "date", "2012-08-01", "value", 13)));
    dataProvider.addItem(new MapDataItem(ParamsMap.of("id", "7", "date", "2012-08-02", "value", 22)));
    dataProvider.addItem(new MapDataItem(ParamsMap.of("id", "8", "date", "2012-08-03", "value", 23)));
    dataProvider.addItem(new MapDataItem(ParamsMap.of("id", "9", "date", "2012-08-04", "value", 20)));
    dataProvider.addItem(new MapDataItem(ParamsMap.of("id", "10", "date", "2012-08-05", "value", 17)));
    dataProvider.addItem(new MapDataItem(ParamsMap.of("id", "11", "date", "2012-08-06", "value", 16)));
    dataProvider.addItem(new MapDataItem(ParamsMap.of("id", "12", "date", "2012-08-07", "value", 18)));
    dataProvider.addItem(new MapDataItem(ParamsMap.of("id", "13", "date", "2012-08-08", "value", 21)));
    dataProvider.addItem(new MapDataItem(ParamsMap.of("id", "14", "date", "2012-08-09", "value", 26)));
    dataProvider.addItem(new MapDataItem(ParamsMap.of("id", "15", "date", "2012-08-10", "value", 24)));
    dataProvider.addItem(new MapDataItem(ParamsMap.of("id", "16", "date", "2012-08-11", "value", 29)));
    AbstractChart chart = new SerialChartModelImpl().setCategoryField("date").setDataProvider(dataProvider).addValueAxes(new ValueAxis().setAxisAlpha(0.0).setPosition(Position.LEFT)).addGraphs(new Graph().setId("g1").setBullet(BulletType.ROUND).setBulletBorderAlpha(1.0).setBulletColor(Color.WHITE).setBulletSize(5).setHideBulletsCount(50).setLineThickness(2).setTitle("Red line").setValueField("value")).setCategoryAxis(new CategoryAxis().setDashLength(1).setMinorGridEnabled(true).setPosition(Position.TOP)).setChartScrollbar(new Scrollbar().setGraph("g1").setScrollbarHeight(30)).setChartCursor(new Cursor().setCursorPosition(CursorPosition.MOUSE).setPan(true)).setExport(new Export());
    ChartSerializer serializer = getTestSerializer();
    String json = serializer.serialize(chart);
    String expected = readFile("SerialChart.json");
    assertEquals(prettyJson(expected), prettyJson(json));
}
Also used : ListDataProvider(io.jmix.ui.data.impl.ListDataProvider) ChartSerializer(io.jmix.charts.widget.amcharts.serialization.ChartSerializer) Cursor(io.jmix.charts.model.cursor.Cursor) ListDataProvider(io.jmix.ui.data.impl.ListDataProvider) DataProvider(io.jmix.ui.data.DataProvider) Graph(io.jmix.charts.model.graph.Graph) CategoryAxis(io.jmix.charts.model.axis.CategoryAxis) ValueAxis(io.jmix.charts.model.axis.ValueAxis) Export(io.jmix.charts.model.export.Export) MapDataItem(io.jmix.ui.data.impl.MapDataItem) Scrollbar(io.jmix.charts.model.Scrollbar) Test(org.junit.jupiter.api.Test)

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