Buy me a coffee :)

Wicket - jQuery UI

jQuery UI integration in Wicket 6.x, Wicket 7.x , Wicket 8.x & Wicket 9.x

Donut Chart

Components / Samples

Description

Since

wicket-kendo-ui-6.28.0

Licensing

Kendo UI "Core" is Apache License 2.0 licensed, starting from version 2014.1.416.
Prior to version 2014.1.416, Kendo UI "Web" was licensed under GPLv3.

A pro version - with a commercial license - is also available, it provides additional widgets (see http://docs.telerik.com/kendo-ui/intro/supporting/list-of-widgets)
To be able to use it, you need to change the ResourceReference with kendo.all.min.js

See also

[howto]-change-resource-references

Sources

  • Java
  • HTML
  • CSS
package com.googlecode.wicket.jquery.ui.samples.kendoui.chart;

import java.util.List;

import org.apache.wicket.model.IModel;
import org.apache.wicket.model.LoadableDetachableModel;
import org.apache.wicket.util.lang.Generics;

import com.googlecode.wicket.jquery.core.Options;
import com.googlecode.wicket.jquery.core.utils.ListUtils;
import com.googlecode.wicket.kendo.ui.dataviz.chart.Chart;
import com.googlecode.wicket.kendo.ui.dataviz.chart.series.DonutSeries;
import com.googlecode.wicket.kendo.ui.dataviz.chart.series.DonutSeries.DonutData;
import com.googlecode.wicket.kendo.ui.dataviz.chart.series.Series;

public class DonutChartPage extends AbstractChartPage // NOSONAR
{
	private static final long serialVersionUID = 1L;

	public DonutChartPage()
	{
		// Chart //
		this.add(new Chart<DonutData>("chart", newModel(), newSeries(), newOptions()));
	}

	// statics //

	static Options newOptions()
	{
		Options options = new Options();
		options.set("title", "{ text: 'Sample Donut Chart' }");
		options.set("legend", "{ position: 'top' }");
		options.set("tooltip", "{ visible: true, format: '{0:n0}' }");

		return options;
	}  
	
	static List<Series> newSeries()
	{
		List<Series> series = Generics.newArrayList();
		series.add(new DonutSeries());

		return series;
	}

	static IModel<List<DonutData>> newModel()
	{
		return new LoadableDetachableModel<List<DonutData>>() {

			private static final long serialVersionUID = 1L;

			@Override
			protected List<DonutData> load()
			{
				return randomDonut();
			}
		};
	}

	static List<DonutData> randomDonut()
	{
		List<DonutData> data = Generics.newArrayList();

		for (int i = 0; i < 5; i++)
		{
			String category = "category #" + i;
			Double value = ListUtils.random(5, 20);
			Boolean explode = i == 0; // only first category is exploded

			data.add(new DonutData(category, value, explode));
		}

		return data;
	}
}
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<head>
<wicket:head>
	<title>Wicket Kendo UI: chart (donut)</title>
</wicket:head>
</head>
<body>
<wicket:extend>
	<div id="demo-panel">
		<div wicket:id="chart"></div>
	</div>
</wicket:extend>
</body>
</html>