answered
2014-04-10 04:05:08 +0800
Senthilchettyin
2623 ● 3 ● 8
http://emrpms.blogspot.in...
Hi Hawk
I changed code to MVVM and still have the same problem. Second time, it does not clear the series, instead of that it is adding to the previous one.
Look at the Video
Video Demo
Here is the ZUL Code
<charts id="chart" type="pie" model="@bind(vm.model)" title="Charges By Provider" />
VM
package com.product.webapp.charts;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import org.zkoss.bind.BindUtils;
import org.zkoss.bind.annotation.AfterCompose;
import org.zkoss.bind.annotation.BindingParam;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.ContextParam;
import org.zkoss.bind.annotation.ContextType;
import org.zkoss.bind.annotation.NotifyChange;
import org.zkoss.chart.Charts;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.select.Selectors;
import org.zkoss.zk.ui.select.annotation.Wire;
import org.zkoss.zk.ui.select.annotation.WireVariable;
import org.zkoss.zkplus.spring.SpringUtil;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.SimpleSingleValueCategoryModel;
import org.zkoss.zul.SingleValueCategoryModel;
import org.zkoss.zul.Textbox;
import org.zkoss.zul.Window;
import com.product.business.customentity.BillingConditions;
import com.product.business.service.BillingReportService;
import com.product.domain.Location;
import com.product.webapp.utilities.FHSessionUtil;
import com.product.webapp.utilities.ShowWindow;
public class ChartProviderChargesVM {
@Wire("#chartprovidercharges")
private Window win;
@Wire("#chartmainlayout")
private Borderlayout borderLayout;
@Wire
private Charts chart;
@WireVariable
private BillingReportService billingReportService;
private List<SummaryData> dataList = new ArrayList<SummaryData>();
private BillingConditions billingCond = new BillingConditions();
private SummaryData selectedData;
private BigDecimal totalBilledAmount = BigDecimal.ZERO;
private Long totalClaims = 0L;
private SingleValueCategoryModel model;
public SingleValueCategoryModel getModel() {
return model;
}
public BillingConditions getBillingCond() {
return billingCond;
}
public void setBillingCond(BillingConditions billingCond) {
this.billingCond = billingCond;
}
public BigDecimal getTotalBilledAmount() {
return totalBilledAmount;
}
public void setTotalBilledAmount(BigDecimal totalBilledAmount) {
this.totalBilledAmount = totalBilledAmount;
}
public Long getTotalClaims() {
return totalClaims;
}
public void setTotalClaims(Long totalClaims) {
this.totalClaims = totalClaims;
}
public SummaryData getSelectedData() {
return selectedData;
}
public void setSelectedData(SummaryData selectedData) {
this.selectedData = selectedData;
}
public List<SummaryData> getDataList() {
return dataList;
}
public void setDataList(List<SummaryData> dataList) {
this.dataList = dataList;
}
@AfterCompose
public void initSetup(@ContextParam(ContextType.VIEW) Component view) {
Selectors.wireComponents(view, this, false);
billingReportService = (BillingReportService) SpringUtil
.getBean("BillingReportService");
billingCond.setPracticeID((long) 3);
Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_MONTH, 1);
this.billingCond.setChargeSummaryType("visitProviderCode");
this.billingCond.setFromDOS(cal.getTime());
this.billingCond.setToDOS(new Date());
this.billingCond.setProviderType("B");
onApplyCondition();
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Command
public void onApplyCondition() {
billingCond.setPracticeID(FHSessionUtil.getCurrentPractice().getID());
List<Object> results = billingReportService
.getChargesSummary(billingCond);
dataList = new ArrayList<SummaryData>();
this.totalBilledAmount = BigDecimal.ZERO;
this.totalClaims = 0L;
if (results.size() == 0) {
model = new SimpleSingleValueCategoryModel();
BindUtils.postNotifyChange(null, null, this, "*");
return;
}
model = new SimpleSingleValueCategoryModel();
for (Iterator it = results.iterator(); it.hasNext();) {
Object[] row = (Object[]) it.next();
dataList.add(new SummaryData((String) row[0], (Long) row[1],
(BigDecimal) row[2]));
model.setValue((String) row[0], (BigDecimal) row[2]);
totalBilledAmount = totalBilledAmount.add((BigDecimal) row[2]);
totalClaims = totalClaims + (Long) row[1];
}
BindUtils.postNotifyChange(null, null, this, "*");
}
@Command
public void OnLookUp(@BindingParam("type") String type) {
if (type.equalsIgnoreCase("Location"))
ShowWindow.showLocationLookup(win);
}
@Command
public void onFocusLookupValues(@BindingParam("target") Textbox target) {
target.select();
}
@Command
@NotifyChange("billingCond")
public void onSelectLocationLookup(
@BindingParam("selectedRecord") Location location) {
if (location != null)
this.billingCond.setLocationCode(location.getCode());
}
@Command
@NotifyChange("billingCond")
public void onClearLookupValues(@BindingParam("type") String type) {
if (type.equalsIgnoreCase("Location"))
this.billingCond.setLocationCode(null);
}
public class SummaryData {
private String data;
private Long count;
private BigDecimal billingAmount;
public SummaryData(String data, Long count, BigDecimal billingAmount) {
this.data = data;
this.count = count;
this.billingAmount = billingAmount;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
public Long getCount() {
return count;
}
public void setCount(Long count) {
this.count = count;
}
public BigDecimal getBillingAmount() {
return billingAmount;
}
public void setBillingAmount(BigDecimal billingAmount) {
this.billingAmount = billingAmount;
}
}
}