MVVM Pattern

From Documentation

You still can work with Charts in MVVM pattern with some exceptional usages.

Get Charts

Get a Charts by wireComponents(), please refer to MVVM Reference / Wire Components

public class ShiftViewModel {
    Charts chart;

    public void doAfterCompose(@ContextParam(ContextType.VIEW) Component view) throws Exception {
        Selectors.wireComponents(view, this, false);
        // initial series data
        // hide some unnecessary options

Get ChartsEvent

Because you usually need ChartsEvent API, you can get it by @ContextParam like:

    public void shiftPoint(@ContextParam(ContextType.TRIGGER_EVENT) ChartsEvent event) {
        // retrieve the point object.
        Point point = event.getPoint();
        // shift the point by updating its x value.
        point.setX(point.getX().intValue() + random() / 10);

< Get Complete Source Code of This Book >

Last Update : 2022/01/18

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.