blob: a6825f9e610e05b6df92345f67f8a80efce370f3 [file] [log] [blame]
To integrate the "Google Chart":https://developers.google.com/chart/ tool into our pages we can use module wicketstuff-googlecharts. To display a chart we must combine the following entities: component Chart, interface IChartData and class ChartProvider, all inside package org.wicketstuff.googlecharts. The following snippet is taken from example page Home:
*HTML:*
{code:html}
...
<h2>Hello World</h2>
<img wicket:id="helloWorld"/>
...
{code}
*Java code:*
{code}
IChartData data = new AbstractChartData(){
public double[][] getData(){
return new double[][] { { 34, 22 } };
}
};
ChartProvider provider = new ChartProvider(new Dimension(250, 100), ChartType.PIE_3D, data);
provider.setPieLabels(new String[] { "Hello", "World" });
add(new Chart("helloWorld", provider));
{code}
*Displayed chart:*
!googlechart.png!
As we can see in the snippet above, component Chart must be used with <img> tag while the input data returned by IChartData must be a two-dimensional array of double values.