0

ZK Charts Clear

asked 2014-04-09 18:22:29 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2615 3 8
http://emrpms.blogspot.in...

Hi

I am following this demo http://www.zkoss.org/zkchartsdemo/pie_basic

I want to clear the chart (series) on a button click. Any help

delete flag offensive retag edit

Comments

6 Answers

Sort by ยป oldest newest most voted
0

answered 2014-04-09 18:44:50 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2615 3 8
http://emrpms.blogspot.in...

I try the below code, but no impact

@Command
public void onclear() {
    chart.getChildren().clear();
    chart.getSeries().remove();
    chart.getSeries().clearOptonDataListener();
    chart.getSeries().addPoint(new Point("asdasdasd", 10));
    Messagebox.show("asdsadasdsad");
}
link publish delete flag offensive edit
0

answered 2014-04-10 01:59:35 +0800

hawk gravatar image hawk
2310 1 5
http://hawkphoenix.blogsp... ZK Team

Hi, Series.remove() will remove the series itself from charts component, so it doesn't work. You can try to manipulate model (http://books.zkoss.org/wiki/ZKChartsEssentials/WorkingwithZKCharts/ManipulatingChart_Model) or add another new series to a charts component.

link publish delete flag offensive edit
0

answered 2014-04-10 04:05:08 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2615 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;
    }

}

}

link publish delete flag offensive edit
0

answered 2014-04-10 04:09:59 +0800

cor3000 gravatar image cor3000
4466 2 7
ZK Team

updated 2014-04-10 04:34:57 +0800

There are currently to bugs (ZKCHARTS-2, ZKCHARTS-3) open about model cleanup in ZK Charts. We need to wait until a fix is available. and replace the whole component instead of updating its model.

Robert

link publish delete flag offensive edit

Comments

What do you mean by "replace the whole component instead of updating its model." How we can do that ?

Senthilchettyin ( 2014-04-10 05:20:58 +0800 )edit

e.g. chart.detach(); chart = new Charts(...) + init model; chart.setParent(previous parent) or put the chart into an include and reload the include

cor3000 ( 2014-04-10 05:39:32 +0800 )edit

:). I need to rollback all and better to use any of the old chart like fusion chart in ZK. This is most complicated.

Senthilchettyin ( 2014-04-10 05:57:46 +0800 )edit

ZK Charts are still in Beta status, an we are currently collecting feedback to fix occuring problems before the final release

cor3000 ( 2014-04-10 07:24:50 +0800 )edit

btw the bugs are fixed now and available to test in version <dependency> <groupId>org.zkoss.chart</groupId> <artifactId>zkcharts</artifactId> <version>1.0.0-FL-20140410</version> </dependency>

cor3000 ( 2014-04-10 11:58:31 +0800 )edit
0

answered 2014-04-10 07:43:06 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2615 3 8
http://emrpms.blogspot.in...

updated 2014-04-10 07:45:27 +0800

I am little bit confused on different chart in ZK. What is zhighcharts as per this page

zhightcharts

link publish delete flag offensive edit

Comments

zhighcharts is a personal work done by the author of the small talk. It's not officially supported by ZK.

hawk ( 2014-04-17 01:54:50 +0800 )edit
0

answered 2016-01-22 14:55:52 +0800

dberian gravatar image dberian
1

This worked for me:

@Command
public void onClear() {
    chart.getSeries().setData(new ArrayList<Integer>());
}
link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
2 followers

RSS

Stats

Asked: 2014-04-09 18:22:29 +0800

Seen: 94 times

Last updated: Jan 22 '16

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More