0

ZK Charts Customization with MVVM

asked 2015-04-06 08:56:25 +0800

MarkLauw gravatar image MarkLauw
1

How can I bind the Charts object in my zul using MVVM approach? Most of the examples available are using MVC approach. There is only one example using MVVM (http:// www.zkoss.org/ zkchartsdemo/ category_model), but it doesn't show how to do customization on the labels.

private Charts chart;

Currently I can only bind its CategoryModel.

<charts model="@bind(vm.chartsModel)" />

public ChartsModel getChartsModel() {
    return chart.getModel();
}

I need to bind the chart object so that the following customizations (eg. set Y axis label) are reflected in the UI:

    chart.setTitle("Sample Chart");

    AxisLabels xLabels = chart.getXAxis().getLabels();
    xLabels.setRotation(-45);
    xLabels.setAlign("right");
    xLabels.setStyle("fontSize: '13px'; fontFamily: 'Verdana, sans-serif'");


    chart.getYAxis().setMin(0);
    chart.getYAxis().setTitle("'Population (millions)");

    chart.getLegend().setEnabled(false);

    chart.getTooltip().setPointFormat(
            "Population in 2008: <b>{point.y:.1f} millions</b>");

    DataLabels dataLabels = chart.getSeries().getDataLabels();
    dataLabels.setEnabled(true);
    dataLabels.setRotation(-90);
    dataLabels.setColor("#FFFFFF");
    dataLabels.setAlign("right");
    dataLabels.setX(4);
    dataLabels.setY(10);

    dataLabels.setStyle(
            "fontSize: '13px'; fontFamily: 'Verdana, sans-serif'; textShadow: '0 0 3px black'");

Thanks.

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-04-06 08:56:25 +0800

Seen: 36 times

Last updated: Apr 06 '15

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