Hi
I am trying to use a chart but i dont see any chart object in the palette. Pls see the image. Is there any specific configuration that i have to do before using it?
Glad that I found what i had to do i.e. check the chart module in project properties.
However, After I have added the suggested codes, I am getting an exception (attached) while opening the Mechanic from the menu.
Here is the codes I have used
in Mechanic-brows.xml
<layout expand="mechanicsTable"
spacing="true">
<chart:pieChart id="ratingChart"
height="200px"
titleField="mechanic"
valueField="ordersCount"
width="100%">
<chart:legend position="LEFT"/>
</chart:pieChart>
<filter id="filter"
applyTo="mechanicsTable"
/*
* Copyright (c) 2016 sales
*/
package com.inteacc.sales.gui.mechanic;
import com.haulmont.charts.gui.amcharts.model.data.DataItem;
import com.haulmont.charts.gui.amcharts.model.data.ListDataProvider;
import com.haulmont.charts.gui.amcharts.model.data.MapDataItem;
import com.haulmont.charts.gui.components.charts.Chart;
import com.haulmont.chile.core.model.utils.InstanceUtils;
import com.haulmont.cuba.gui.components.AbstractLookup;
import com.inteacc.sales.entity.Mechanic;
import com.inteacc.sales.service.OrderService;
import javax.inject.Inject;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @author mortoza
*/
public class MechanicBrowse extends AbstractLookup {
@Inject
private Chart ratingChart;
@Inject
private OrderService orderService;
@Override
public void init(Map<String, Object> params){
super.init(params);
Map<Mechanic, Long> stats =
orderService.getMechanicOrdersStats();
List<DataItem> chartItems = new ArrayList<>();
for (Map.Entry<Mechanic, Long> entry : stats.entrySet()) {
MapDataItem dataItem = new MapDataItem();
dataItem.add("mechanic",
InstanceUtils.getInstanceName(entry.getKey()));
dataItem.add("ordersCount", entry.getValue());
chartItems.add(dataItem);
}
ratingChart.getConfiguration()
.setDataProvider(new ListDataProvider(chartItems));
}
}
Please restart the application server.
If the problem remains, attach the full stack trace (press Details in the exception dialog) and the screen XML here.