https://github.com/mdewilde/chart
Java library for use with Chart.js javascript library
https://github.com/mdewilde/chart
Last synced: 6 months ago
JSON representation
Java library for use with Chart.js javascript library
- Host: GitHub
- URL: https://github.com/mdewilde/chart
- Owner: mdewilde
- License: apache-2.0
- Created: 2015-06-18T19:59:40.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2023-08-06T17:21:39.000Z (over 2 years ago)
- Last Synced: 2025-04-30T11:04:13.985Z (7 months ago)
- Language: Java
- Homepage:
- Size: 600 KB
- Stars: 113
- Watchers: 15
- Forks: 43
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- Changelog: changelog
- License: LICENSE.txt
Awesome Lists containing this project
- awesome - chart.java
README
# Chart.java
[](https://search.maven.org/artifact/be.ceau/chart) [](https://javadoc.io/doc/be.ceau/chart) [](https://www.apache.org/licenses/LICENSE-2.0.txt)
Chart.java enables integration with the excellent [Chart.js](http://www.chartjs.org/) library from within a Java application.
### Usage example
In Java:
```Java
BarDataset dataset = new BarDataset()
.setLabel("sample chart")
.setData(65, 59, 80, 81, 56, 55, 40)
.addBackgroundColors(Color.RED, Color.GREEN, Color.BLUE, Color.YELLOW, Color.ORANGE, Color.GRAY, Color.BLACK)
.setBorderWidth(2);
BarData data = new BarData()
.addLabels("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday")
.addDataset(dataset);
return new BarChart(data).toJson();
```
In JavaScript:
```JavaScript
var ctx = document.getElementById('canvasId');
new Chart(ctx, json);
```
### Compatibility
Chart.js | Chart.java
------------ | -------------
1.x | 0.9.x
2.x | 2.x
### Test
See example charts by running the included unit tests:
```XML
mvn clean compile test
```
### Javadoc
Browse this project's javadoc at [javadoc.io](https://javadoc.io/doc/be.ceau/chart).
### Maven Central
Include this project directly from Maven Central
```XML
be.ceau
chart
2.6.0
```
### Download
Downloads for this project at [Maven Central](https://repo1.maven.org/maven2/be/ceau/chart/).
### Other resources
The [docs for Chart.js](http://www.chartjs.org/docs/) are a helpful source of info on what's possible and how to achieve it.
### GnuPG public key
Verify signature files with my [GnuPG public key](https://www.ceau.be/pubkey.gpg).
### License
Chart.java is licensed under [the Apache 2.0 license](https://www.apache.org/licenses/LICENSE-2.0.txt).