Skip to content

Commit 3f21609

Browse files
committed
Merge branch 'develop' into update-from-template-merged
2 parents cf59a66 + fd030cf commit 3f21609

File tree

170 files changed

+12697
-35
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

170 files changed

+12697
-35
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ body:
1515
attributes:
1616
label: "Checklist"
1717
options:
18-
- label: "I am able to reproduce the bug with the [latest version](https://github.com/xdev-software/template-placeholder/releases/latest)"
18+
- label: "I am able to reproduce the bug with the [latest version](https://github.com/xdev-software/chartjs-java-model/releases/latest)"
1919
required: true
20-
- label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/template-placeholder/issues) or [closed](https://github.com/xdev-software/template-placeholder/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
20+
- label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/chartjs-java-model/issues) or [closed](https://github.com/xdev-software/chartjs-java-model/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
2121
required: true
2222
- label: "I have taken the time to fill in all the required details. I understand that the bug report will be dismissed otherwise."
2323
required: true

.github/ISSUE_TEMPLATE/enhancement.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ body:
1313
attributes:
1414
label: "Checklist"
1515
options:
16-
- label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/template-placeholder/issues) or [closed](https://github.com/xdev-software/template-placeholder/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
16+
- label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/chartjs-java-model/issues) or [closed](https://github.com/xdev-software/chartjs-java-model/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
1717
required: true
1818
- label: "I have taken the time to fill in all the required details. I understand that the feature request will be dismissed otherwise."
1919
required: true

.github/ISSUE_TEMPLATE/question.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ body:
1212
attributes:
1313
label: "Checklist"
1414
options:
15-
- label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/template-placeholder/issues) or [closed](https://github.com/xdev-software/template-placeholder/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
15+
- label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/chartjs-java-model/issues) or [closed](https://github.com/xdev-software/chartjs-java-model/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
1616
required: true
1717
- label: "I have taken the time to fill in all the required details. I understand that the question will be dismissed otherwise."
1818
required: true

.github/workflows/check-build.yml

+11-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030

3131
strategy:
3232
matrix:
33-
java: [17, 21]
33+
java: [11, 17, 21]
3434
distribution: [temurin]
3535

3636
steps:
@@ -44,7 +44,8 @@ jobs:
4444
cache: 'maven'
4545

4646
- name: Build with Maven
47-
run: ./mvnw -B clean package
47+
# Java 17 is required for tests
48+
run: ./mvnw -B clean package ${{ matrix.java >=17 && '-P run-integration-tests' || '-Dmaven.test.skip=true' }}
4849

4950
- name: Check for uncommited changes
5051
run: |
@@ -71,6 +72,14 @@ jobs:
7172
path: ${{ env.DEMO_MAVEN_MODULE }}/target/${{ env.DEMO_MAVEN_MODULE }}.jar
7273
if-no-files-found: error
7374

75+
- name: Upload screenshots of test failures
76+
if: failure()
77+
uses: actions/upload-artifact@v4
78+
with:
79+
name: test-fail-screenshots-${{ matrix.java }}
80+
path: ${{ env.PRIMARY_MAVEN_MODULE }}/target/screenshots
81+
if-no-files-found: ignore
82+
7483
checkstyle:
7584
runs-on: ubuntu-latest
7685
if: ${{ github.event_name != 'pull_request' || !startsWith(github.head_ref, 'renovate/') }}

.run/Run Demo.run.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<component name="ProjectRunConfigurationManager">
22
<configuration default="false" name="Run Demo" type="Application" factoryName="Application">
33
<option name="MAIN_CLASS_NAME" value="software.xdev.Application" />
4-
<module name="template-placeholder-demo" />
4+
<module name="chartjs-java-model-demo" />
55
<option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
66
<extension name="coverage">
77
<pattern>

CHANGELOG.md

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
## 2.8.0
2+
* Synced ``TooltipOptions`` from ChartJS source code #330
3+
4+
## 2.7.0
5+
* ``Title``: Make it possible to set custom padding and multi-line text #316
6+
7+
## 2.6.0
8+
* Synced ``Doughnut/PieOptions`` from ChartJS source code #293
9+
* Synced ``GridLineConfiguration`` from ChartJS source code / improved Types for more options #289
10+
* Updated dependencies
11+
12+
## 2.5.0
13+
* Synced ``Legend`` from ChartJS source code #285
14+
15+
## 2.4.0
16+
* PointStyle can also contain non-string constants #280
17+
* Use ``CoreInteractionOptions`` for ``Options#interaction`` and ``Options#hover`` #281
18+
* Updated dependencies
19+
20+
## 2.3.1
21+
* Synced ``LineOptions/DataSet`` ``stepped`` and ``tension`` with ChartJS source #262
22+
* Updated dependencies
23+
24+
## 2.3.0
25+
* Update available datasets fields from ChartJS source code #244
26+
* Removed deprecated code
27+
28+
## 2.2.0
29+
* Improve color handling #238
30+
* Change ``Color`` to ``RGBAColor`` as it only handles RGBA
31+
* Change all occurrences of ``Color`` to ``Object`` so that other color models (e.g. HSLA or Hex) can be applied
32+
* Created ``HSLAColor`` that can be used like ``RGBAColor``
33+
34+
## 2.1.0
35+
* Charts no longer check if they are drawable #198
36+
* ChartJS behavior: If a chart can't be drawn it will render a empty canvas
37+
* Deprecated methods: ``Chart#toJsonNative`` and ``Chart#isDrawable``
38+
* Make ``IndexAxis`` available in all options
39+
40+
## 2.0.2
41+
_Same as version 2.1.0 - Version was not incremented correctly_
42+
43+
## 2.0.1
44+
* Restored ``DisplayFormats`` #186
45+
46+
## 2.0.0
47+
* Scales have been reworked and are now nearly identical to the [types defined in ChartJS](https://github.com/chartjs/Chart.js/blob/v4.4.3/src/types/index.d.ts)
48+
* The use of ``Color`` for various coloring related options is no longer required.
49+
* It's now possible to use e.g. strings
50+
51+
## 1.5.0
52+
* Added ``JsonIgnore`` to certain fields to help prevent infinite loops #174
53+
* Corrected model for ``Title`` and ``Font`` #175
54+
55+
## 1.4.1
56+
* Use ``Number`` instead of ``BigDecimal`` in some additional places #159 (@aripddev)
57+
58+
## 1.4.0
59+
* Simplify API by using ``Number`` instead of ``BigDecimal``, ``int`` and ``double`` for ``Datapoints`` #154 (@aripddev)
60+
61+
## 1.3.1
62+
* Add subtitle option #141 (@aripddev)
63+
* Add ``PointStyle#rectRounded`` #143 (@aripddev)
64+
* Add ``BubbleDataset#pointStyle`` #144 (@aripddev)
65+
* ``reverse`` property should be on the ``Scale`` object #145
66+
* Added all available properties for ``Legend``
67+
68+
## 1.3.0
69+
* Allows creation of mixed charts #128
70+
* New chart class: ``MixedChart``
71+
* Some classes have been renamed
72+
* ``Data`` -> ``HomogeneousData``
73+
* ``AbstractChart`` -> ``HomogeneousChart``
74+
* Slim down test dependencies
75+
76+
## 1.2.0
77+
* Add TimeScale and TimeTicks to allow building linear time charts #90 (@astappiev)
78+
* Add options for the [Zoom plugin](https://www.chartjs.org/chartjs-plugin-zoom/latest/) #117 (@astappiev)
79+
* Updated dependencies
80+
81+
## 1.1.3
82+
* Add ``toJsonNative`` method which doesn't run the ``isDrawable`` check #91
83+
84+
## 1.1.2
85+
* ⚠️ GroupId changed from ``com.xdev-software`` to ``software.xdev``
86+
87+
## 1.1.1
88+
* ``AngleLines#lineWidth`` now uses ``BigDecimal`` #76
89+
* Updated dependencies
90+
91+
## 1.1.0
92+
* Added support for more [data structures](https://www.chartjs.org/docs/4.4.0/general/data-structures.html) inside ``Dataset#data``
93+
* ``Dataset#data`` can now contain ``Object``s
94+
95+
## 1.0.2
96+
* Support Java 11
97+
* Updated dependencies
98+
99+
## 1.0.1
100+
* Added support for [stacked bar chart with groups](https://www.chartjs.org/docs/4.4.0/samples/bar/stacked-groups.html) (@dlemaignent)
101+
102+
## 1.0.0
103+
Initial release
104+
105+
Support for Chart.js v4
106+
107+
Noteworthy changes compared to [Chart.java](https://github.com/mdewilde/chart):
108+
* Changed the package to ``software.xdev.chartjs.model``
109+
* All charts (e.g. ``BarChart``, ``LineChart``, ...) are now inside the ``charts`` package
110+
* Breaking API changes due to compatibility with Chart.js v4; You may checkout the migration guides
111+
* [3.x Migration Guide](https://www.chartjs.org/docs/4.3.0/migration/v3-migration.html)
112+
* [4.x Migration Guide](https://www.chartjs.org/docs/4.3.0/migration/v4-migration.html)
113+
* JSON is no longer pretty printed by default due to performance reasons
114+
* Implemented integration tests
115+
* Requires Java 17

CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ You should have the following things installed:
3434
* Ensure that the JDK/Java-Version is correct
3535

3636

37-
## Releasing [![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/template-placeholder/release.yml?branch=master)](https://github.com/xdev-software/template-placeholder/actions/workflows/release.yml)
37+
## Releasing [![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/chartjs-java-model/release.yml?branch=master)](https://github.com/xdev-software/chartjs-java-model/actions/workflows/release.yml)
3838

3939
Before releasing:
40-
* Consider doing a [test-deployment](https://github.com/xdev-software/template-placeholder/actions/workflows/test-deploy.yml?query=branch%3Adevelop) before actually releasing.
40+
* Consider doing a [test-deployment](https://github.com/xdev-software/chartjs-java-model/actions/workflows/test-deploy.yml?query=branch%3Adevelop) before actually releasing.
4141
* Check the [changelog](CHANGELOG.md)
4242

4343
If the ``develop`` is ready for release, create a pull request to the ``master``-Branch and merge the changes

LICENSE

+1
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@
187187
identification within third-party archives.
188188

189189
Copyright 2024 XDEV Software
190+
Copyright 2020 Marceau Dewilde
190191

191192
Licensed under the Apache License, Version 2.0 (the "License");
192193
you may not use this file except in compliance with the License.

README.md

+25-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
1-
[![Latest version](https://img.shields.io/maven-central/v/software.xdev/template-placeholder?logo=apache%20maven)](https://mvnrepository.com/artifact/software.xdev/template-placeholder)
2-
[![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/template-placeholder/check-build.yml?branch=develop)](https://github.com/xdev-software/template-placeholder/actions/workflows/check-build.yml?query=branch%3Adevelop)
3-
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=xdev-software_template-placeholder&metric=alert_status)](https://sonarcloud.io/dashboard?id=xdev-software_template-placeholder)
1+
[![Latest version](https://img.shields.io/maven-central/v/software.xdev/chartjs-java-model?logo=apache%20maven)](https://mvnrepository.com/artifact/software.xdev/chartjs-java-model)
2+
[![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/chartjs-java-model/check-build.yml?branch=develop)](https://github.com/xdev-software/chartjs-java-model/actions/workflows/check-build.yml?query=branch%3Adevelop)
3+
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=xdev-software_chartjs-java-model&metric=alert_status)](https://sonarcloud.io/dashboard?id=xdev-software_chartjs-java-model)
4+
[![ChartJS Documentation](https://img.shields.io/badge/Chart.js-documentation-ff6384?logo=Chart.js)](https://www.chartjs.org/docs/latest/)
45

5-
# template-placeholder
6+
# <img src="https://www.chartjs.org/media/logo.svg" height="38" /> chartjs-java-model
7+
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.
68

9+
This repo extends the abandoned [Chart.java](https://github.com/mdewilde/chart) and adds support for Chart.js Version 4+.
10+
11+
> [!NOTE]
12+
> We try our best to implement the ChartJS v4 API however there are a lot of configuration options.<br/>
13+
> Therefore some parts migth still be missing or use the outdated v2 API from the original repo.<br/>
14+
> If you think you found a missing or incorrect API please open an issue and/or provide a pull request.
715
816
## Installation
9-
[Installation guide for the latest release](https://github.com/xdev-software/template-placeholder/releases/latest#Installation)
17+
[Installation guide for the latest release](https://github.com/xdev-software/chartjs-java-model/releases/latest#Installation)
18+
19+
#### Compatibility with Chart.js
20+
| Chart.js | ``chartjs-java-model`` version |
21+
| --- | --- |
22+
| 4.x | ``1+`` |
1023

1124
## Support
1225
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).
@@ -15,4 +28,10 @@ If you need support as soon as possible and you can't wait for any pull request,
1528
See the [contributing guide](./CONTRIBUTING.md) for detailed instructions on how to get started with our project.
1629

1730
## Dependencies and Licenses
18-
View the [license of the current project](LICENSE) or the [summary including all dependencies](https://xdev-software.github.io/template-placeholder/dependencies)
31+
View the [license of the current project](LICENSE) or the [summary including all dependencies](https://xdev-software.github.io/chartjs-java-model/dependencies)
32+
33+
## Acknowledgment
34+
* To all [contributors](https://github.com/xdev-software/chartjs-java-model/graphs/contributors) that helped to improve this library
35+
* Especially to the devs at [PrimeTek/PrimeFaces](https://www.primefaces.org/) that regularly provide feedback and PRs
36+
37+
<sub>Disclaimer: This is not an official ChartJS product and not associated</sub>

SECURITY.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
## Reporting a Vulnerability
44

5-
Please report a security vulnerability [on GitHub Security Advisories](https://github.com/xdev-software/template-placeholder/security/advisories/new).
5+
Please report a security vulnerability [on GitHub Security Advisories](https://github.com/xdev-software/chartjs-java-model/security/advisories/new).

template-placeholder-demo/pom.xml renamed to chartjs-java-model-demo/pom.xml

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66

77
<parent>
88
<groupId>software.xdev</groupId>
9-
<artifactId>template-placeholder-root</artifactId>
10-
<version>1.0.0-SNAPSHOT</version>
9+
<artifactId>chartjs-java-model-root</artifactId>
10+
<version>2.8.1-SNAPSHOT</version>
1111
</parent>
1212

13-
<artifactId>template-placeholder-demo</artifactId>
14-
<version>1.0.0-SNAPSHOT</version>
13+
<artifactId>chartjs-java-model-demo</artifactId>
14+
<version>2.8.1-SNAPSHOT</version>
1515
<packaging>jar</packaging>
1616

1717
<organization>
@@ -20,7 +20,7 @@
2020
</organization>
2121

2222
<properties>
23-
<javaVersion>17</javaVersion>
23+
<javaVersion>11</javaVersion>
2424
<maven.compiler.release>${javaVersion}</maven.compiler.release>
2525

2626
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -32,7 +32,7 @@
3232
<dependencies>
3333
<dependency>
3434
<groupId>software.xdev</groupId>
35-
<artifactId>template-placeholder</artifactId>
35+
<artifactId>chartjs-java-model</artifactId>
3636
<version>${project.version}</version>
3737
</dependency>
3838
</dependencies>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package software.xdev;
2+
3+
import java.awt.Desktop;
4+
import java.io.IOException;
5+
import java.io.UncheckedIOException;
6+
import java.nio.file.Files;
7+
import java.nio.file.Path;
8+
9+
import software.xdev.chartjs.model.charts.BarChart;
10+
import software.xdev.chartjs.model.charts.Chart;
11+
import software.xdev.chartjs.model.data.BarData;
12+
import software.xdev.chartjs.model.dataset.BarDataset;
13+
import software.xdev.chartjs.model.options.BarOptions;
14+
15+
16+
public final class Application
17+
{
18+
private Application()
19+
{
20+
}
21+
22+
public static void main(final String[] args)
23+
{
24+
final BarData data = new BarData();
25+
data.addLabels("A", "B", "C");
26+
data.addDataset(new BarDataset()
27+
.setLabel("Dataset1")
28+
.setData(1, 3, 2));
29+
30+
createAndOpenTestFile(new BarChart()
31+
.setData(data)
32+
.setOptions(new BarOptions()));
33+
}
34+
35+
@SuppressWarnings("java:S5443") // Only a demo nothing sensitive is here
36+
private static void createAndOpenTestFile(final Chart<?, ?, ?> chart)
37+
{
38+
try
39+
{
40+
final Path tmp = Files.createTempFile("chart_test_", ".html");
41+
42+
Files.writeString(
43+
tmp,
44+
String.format("<!DOCTYPE html>\n"
45+
+ "<html lang='en'>\n"
46+
+ "\t<head>\n"
47+
+ "\t\t<meta charset='UTF-8'>\n"
48+
+ "\t\t<script src=\"https://cdn.jsdelivr.net/npm/[email protected]/dist/chart.umd.js\"></script>\n"
49+
+ "\t</head>\n"
50+
+ "\t<body>\n"
51+
+ "\t\t<canvas id='c' style='border:1px solid #555;'></canvas>\n"
52+
+ "\t\t<script>\n"
53+
+ "\t\t\tnew Chart(document.getElementById('c').getContext('2d'), %s);\n"
54+
+ "\t\t</script>\n"
55+
+ "\t</body>\n"
56+
+ "</html>", chart.toJson())
57+
);
58+
59+
Desktop.getDesktop().browse(tmp.toUri());
60+
}
61+
catch(final IOException e)
62+
{
63+
throw new UncheckedIOException(e);
64+
}
65+
}
66+
}

0 commit comments

Comments
 (0)