Skip to content
caalador edited this page Jun 5, 2014 · 5 revisions

Info

Periodic is a component for visualizing recurring data.

The graph is given the maximum value that will be found in the data items e.g. if working with monthly occurrences it would be 31 or with hours in a day then the given value would be 24.

Features

Custom items

The base add-on contains 2 item types PeriodicItem and Split. PeriodicItem contains data for one item instance and is drawn to given length and gets the added label.

Split is used to create a visual split (vertical line) with text (inside line not as a bottom label) and contains no data.

A PeriodicItem: and a Split:

Server Side

To create your own items all you need to do on the server side if you want to have a periodic data item is to implement the Periodical interface. If the item only wants to be drawn then no server side extensions or implementations are needed.

Client Side

On the client side there are 3 interfaces that can be implemented.

To not have the component evaluate the custom item as any Vaadin component the widget should implement the PeriodicPaintable interface.

To get drag events to position the component the PeriodicMovable interface should be implemented.

Then if the component is a periodic data item then the PeriodicalItem interface should be implemented.

Periodical Item label

The periodical item label is perhaps best drawn and positioned with:

    context.save();
    context.setFont("bold 11px Courier New");
    
    double textWidth = context.measureText(label).getWidth();
    context.beginPath();
    context.fillText(label, position - (textWidth / 2), height + (low ? 21 : 12));
    context.closePath();
    context.restore();

Data estimation

When having enough data (basically 3 or more periods) the component can when given an Estimate.class implementation fill in empty future items with estimated occurrences.

The existing estimators are Mean and Median that just take the mean or median value of the "empty" and "actual" data in the given set.

Estimation can be much more flexible and targeted for data as the Estimator implementation is given the "actual" data as a int list in the order they come up and the same for the "empty" data. Also the whole dataset is collected for the estimator to use as a EstimateData list that contains the DataType and the length of the data and is in the order they appear.

Estimation is done with the command periodic.estimateOccurrences(Median.class);

Clone this wiki locally