Search in sources :

Example 1 with Legend

use of io.jmix.charts.model.legend.Legend in project jmix by jmix-framework.

the class ChartsSerializationTest method testPieChart.

@Test
public void testPieChart() throws IOException, URISyntaxException {
    DataProvider dataProvider = new ListDataProvider();
    dataProvider.addItem(new MapDataItem(ParamsMap.of("id", "1", "country", "Czech Republic", "litres", 256.9)));
    dataProvider.addItem(new MapDataItem(ParamsMap.of("id", "2", "country", "Ireland", "litres", 131.1)));
    dataProvider.addItem(new MapDataItem(ParamsMap.of("id", "3", "country", "Germany", "litres", 115.8)));
    dataProvider.addItem(new MapDataItem(ParamsMap.of("id", "4", "country", "Australia", "litres", 109.9)));
    dataProvider.addItem(new MapDataItem(ParamsMap.of("id", "5", "country", "Austria", "litres", 108.3)));
    dataProvider.addItem(new MapDataItem(ParamsMap.of("id", "6", "country", "UK", "litres", 65.0)));
    dataProvider.addItem(new MapDataItem(ParamsMap.of("id", "7", "country", "Belgium", "litres", 40.0)));
    AbstractChart chart = new PieChartModelImpl().setDataProvider(dataProvider).setDepth3D(15).setAngle(30).setValueField("litres").setTitleField("country").setBalloonText("[[title]] - [[percents]]%").setLegend(new Legend().setMarkerType(MarkerType.CIRCLE).setPosition(LegendPosition.RIGHT).setMarginRight(80).setAutoMargins(false)).setExport(new Export());
    ChartSerializer serializer = getTestSerializer();
    String json = serializer.serialize(chart);
    String expected = readFile("PieChart.json");
    assertEquals(prettyJson(expected), prettyJson(json));
}
Also used : ListDataProvider(io.jmix.ui.data.impl.ListDataProvider) DataProvider(io.jmix.ui.data.DataProvider) ListDataProvider(io.jmix.ui.data.impl.ListDataProvider) Legend(io.jmix.charts.model.legend.Legend) ChartSerializer(io.jmix.charts.widget.amcharts.serialization.ChartSerializer) Export(io.jmix.charts.model.export.Export) MapDataItem(io.jmix.ui.data.impl.MapDataItem) Test(org.junit.jupiter.api.Test)

Aggregations

Export (io.jmix.charts.model.export.Export)1 Legend (io.jmix.charts.model.legend.Legend)1 ChartSerializer (io.jmix.charts.widget.amcharts.serialization.ChartSerializer)1 DataProvider (io.jmix.ui.data.DataProvider)1 ListDataProvider (io.jmix.ui.data.impl.ListDataProvider)1 MapDataItem (io.jmix.ui.data.impl.MapDataItem)1 Test (org.junit.jupiter.api.Test)1