OhlcChart
OhlcChart is created with a OhlcChartModel.
Source
<p:ohlcChart id="sample" value="#{chartBean.ohlcModel}"
title="Sample Ohlc Chart" style="width:400px;height:300px" yaxisLabel="Price Change $K / Unit" xaxisLabel="Year" />
<p:ohlcChart id="candleStick" value="#{chartBean.ohlcModel2}" candleStick="true" yaxisLabel="Index Value" xaxisLabel="Sector"
title="Ohlc Chart with Candle Stick" style="width:400px;height:300px" />
package org.primefaces.examples.view;
import java.io.Serializable;
import org.primefaces.model.chart.OhlcChartModel;
import org.primefaces.model.chart.OhlcCharSeries;
public class ChartBean implements Serializable {
private OhlcChartModel ohlcModel;
private OhlcChartModel ohlcModel2;
public ChartBean() {
createOhlcModel();
createOhlcModel2();
}
private void createOhlcModel(){
ohlcModel = new OhlcChartModel();
ohlcModel.add(new OhlcChartSeries(2007, 143.82, 144.56, 136.04, 136.97));
ohlcModel.add(new OhlcChartSeries(2008, 138.7, 139.68, 135.18, 135.4));
ohlcModel.add(new OhlcChartSeries(2009, 143.46, 144.66, 139.79, 140.02));
ohlcModel.add(new OhlcChartSeries(2010, 140.67, 143.56, 132.88, 142.44));
ohlcModel.add(new OhlcChartSeries(2011, 136.01, 139.5, 134.53, 139.48));
ohlcModel.add(new OhlcChartSeries(2012, 124.76, 135.9, 124.55, 135.81));
ohlcModel.add(new OhlcChartSeries(2012, 123.73, 129.31, 121.57, 122.5));
}
private void createOhlcModel2() {
ohlcModel2 = new OhlcChartModel();
for( int i=1 ; i < 41 ; i++)
ohlcModel2.add(new OhlcChartSeries(i,
Math.random() * 80 + 80,
Math.random() * 50 + 110,
Math.random() * 20 + 80,
Math.random() * 80 + 80));
}
}
