0

How to use ChartModel like Chart

asked 2015-03-26 08:31:25 +0800

pippo15 gravatar image pippo15
1

I'm use ZK and i have a problem with Charts.

Well, first i have 2 different types of charts:

  1. Charts that load on page load
  2. Charts that load only after click

For first time of Chart i use this sequence of actions:

<window apply="mypath.graphes.LineLabelsComposer">
    <charts id="chart1" type="line" title="Graph1"/>
    <charts id="chart2" type="line" title="Graph2"/>
</window>

In LineLabelsComposer.java in method doCompose i made this:

chart1.setModel(LineLabelsData.setCategoryModel());
chart1.getYAxis().getTitle().setText("Values1");
chart1.getTooltip().setEnabled(false);   

LinePlotOptions linePlotOptions = chart1.getPlotData().getPlotOptions().getLine();
linePlotOptions.setEnableMouseTracking(false);
linePlotOptions.getDataLabels().setEnabled(true);

chart2.setModel(LineLabelsData.setCategoryModel2());
chart2.getYAxis().getTitle().setText("Values2");
chart2.getTooltip().setEnabled(false);    

LinePlotOptions linePlotOptions2 = chart2.getPlotData().getPlotOptions().getLine();
linePlotOptions2.setEnableMouseTracking(false);
linePlotOptions2.getDataLabels().setEnabled(true);

In this case it works all perfectely! When the page is load the graph was built.

No problem.

The problem is in the second case.

Now i have a page with a button. When i click on the button (and not before!) the graph will be built!

The graph was built correctely for the data. The problem is that it's impossible to modify some settings of graph. These are my actions:

<window apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('mypath.bean.UserViewModel')">
<div>
<datebox id="in2" value ="@bind(vm.date1)"/>
<datebox id="in3" value ="@bind(vm.date2)"/>
<button id="cerca" onClick="@command('getModel')" label="Cerca" />
</div>
<charts model="@bind(vm.chart)" type="line" width="550" title="New Value"/>

</window>

This is method getModel:

private ChartsModel chart;
@Command
    @NotifyChange("chart")
    public ChartsModel viewGraph(@BindingParam("self") Group self){

        String a = self.getLabel();
        UserServiceImpl usr = new UserServiceImpl();
        chart = usr.viewGraph(a);
        return chart;

    }

Then this is viewGraph:

public ChartsModel viewGraph(String data) {
        // TODO Auto-generated method stub
        chart = new Charts();
        chart.setModel(LineLabelsData.setCategoryModel(data));      
        chart.getYAxis().getTitle().setText("Text"); 
        chart.getTooltip().setEnabled(false);
        LinePlotOptions linePlotOptions =
                chart.getPlotData().getPlotOptions().getLine();
        linePlotOptions.setEnableMouseTracking(false);
        linePlotOptions.getDataLabels().setEnabled(true);

        return chart.getModel();

    }

The problem is that for example chart.getYAxis().getTitle().setText("Text"); does not work. And so other modified.

There are some other method to do second thing?

delete flag offensive retag edit
Be the first one to answer this question!
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
1 follower

RSS

Stats

Asked: 2015-03-26 08:31:25 +0800

Seen: 4 times

Last updated: Mar 26 '15

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