This project combines Apache Wicket and Chart.js. It provides all charts from Chart.js within Apache Wicket. It's completely open source and free to use (also in commercial projects). Create beautiful charts and graphs in your Wicket project using only Java if you like. Customize every JavaScript and CSS details if you need to.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
This project uses Java version 11 minimum
Include wicket-chartjs in your pom.xml
<dependency>
<groupId>de.martinspielmann.wicket</groupId>
<artifactId>wicket-chartjs</artifactId>
<version>${wicket-chartjs.version}</version>
</dependency>
- Add your data to a chart model:
LoadableDetachableModel<Bar> model = LoadableDetachableModel.of(() -> {
Bar bar = new Bar();
bar.getData().getLabels().addAll(TextLabel.of("January", "February", "March", "April", "May", "June", "July"));
BarDataset barDataSet = new BarDataset();
barDataSet.setLabel("My First dataset");
barDataSet.setData(new Data(NumberDataValue.of(0, 10, 5, 2.5, 20, 30, 45)));
bar.getData().getDatasets().add(barDataSet);
return bar;
})
- Create a chart panel:
add(new BarChartPanel("bar", model));
- Add the panel to your HTML markup:
<div wicket:id="bar"></div>
That was it :) That's your first Chart in Java with wicket-chartjs.
- Maven - Software project management and comprehension tool
- Wicket - Wicket is an open source, component oriented, serverside, Java web application framework
- Chart.js - Simple yet flexible JavaScript charting for designers & developers
This is stil lwork in progress and not yet feature complete. If you find any problem, don't hesitate to create an issue or PR.
I use SemVer for versioning. For the versions available, see the tags on this repository.
See the list of contributors who participated in this project.
This project is licensed under the Apache License - see the LICENSE file for details