https://github.com/xdev-software/chartjs-java-model
Provides Java models for Chart.js
https://github.com/xdev-software/chartjs-java-model
chartjs charts java model
Last synced: 14 days ago
JSON representation
Provides Java models for Chart.js
- Host: GitHub
- URL: https://github.com/xdev-software/chartjs-java-model
- Owner: xdev-software
- License: apache-2.0
- Created: 2023-04-28T07:39:51.000Z (over 2 years ago)
- Default Branch: develop
- Last Pushed: 2025-04-28T04:11:49.000Z (6 months ago)
- Last Synced: 2025-04-28T04:25:43.974Z (6 months ago)
- Topics: chartjs, charts, java, model
- Language: Java
- Homepage:
- Size: 3.29 MB
- Stars: 21
- Watchers: 3
- Forks: 6
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
- awesome - chartjs-java-model
README
[](https://mvnrepository.com/artifact/software.xdev/chartjs-java-model)
[](https://github.com/xdev-software/chartjs-java-model/actions/workflows/check-build.yml?query=branch%3Adevelop)
[](https://www.chartjs.org/docs/latest/)
#
chartjs-java-model
Provides Java models for [Chart.js](https://www.chartjs.org/) so that e.g. a Java Server can build a chart and then instruct a JavaScript client what needs to be shown.
This repo extends the abandoned [Chart.java](https://github.com/mdewilde/chart) and adds support for Chart.js Version 4+.
> [!NOTE]
> We try our best to implement the ChartJS v4 API however there are a lot of configuration options.
> Therefore some parts might still be missing or use the outdated v2 API from the original repo.
> If you think you found a missing or incorrect API please open an issue and/or provide a pull request.
## Usage
Configuring a chart is straight forward and follows a builder like pattern:
```java
new BarChart(new BarData()
.addLabels("A", "B")
.addDataset(new BarDataset()
.setLabel("X")
.addData(1)
.addData(2)))
.toJson(); // Do something with the json like sending it to the client
```
If you need more examples:
* Have a look at the [demo](./chartjs-java-model-demo/)
* or checkout how we do it in our [tests](./chartjs-java-model/src/test/java/software/xdev/chartjs/model/)
* there are also [screenshots](./chartjs-java-model/src/test/resources/screenshotReferences/) available
## Installation
[Installation guide for the latest release](https://github.com/xdev-software/chartjs-java-model/releases/latest#Installation)
#### Compatibility with Chart.js
| Chart.js | ``chartjs-java-model`` version |
| --- | --- |
| 4.x | ``1+`` |
#### Integrations
* Vaadin - You can utilize the library in combination with our [Chart.js Wrapper for Vaadin](https://github.com/xdev-software/vaadin-chartjs-wrapper)
* [Primefaces's Charts](https://showcase.primefaces.org/ui/chart/bar.xhtml)
## Support
If you need support as soon as possible and you can't wait for any pull request, feel free to use [our support](https://xdev.software/en/services/support).
## Contributing
See the [contributing guide](./CONTRIBUTING.md) for detailed instructions on how to get started with our project.
## Dependencies and Licenses
View the [license of the current project](LICENSE) or the [summary including all dependencies](https://xdev-software.github.io/chartjs-java-model/dependencies)
## Acknowledgment
* To all [contributors](https://github.com/xdev-software/chartjs-java-model/graphs/contributors) that helped to improve this library
* Especially to the devs at [PrimeTek/PrimeFaces](https://www.primefaces.org/) that regularly provide feedback and PRs
Disclaimer: This is not an official Chart.js product and not associated