Skip to content

Commit

Permalink
Merge branch 'develop' into update-from-template-merged
Browse files Browse the repository at this point in the history
  • Loading branch information
xdev-gh-bot committed Dec 16, 2024
2 parents edde4f6 + 1f3c190 commit 457bcd2
Show file tree
Hide file tree
Showing 170 changed files with 13,100 additions and 35 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ body:
attributes:
label: "Checklist"
options:
- label: "I am able to reproduce the bug with the [latest version](https://github.com/xdev-software/template-placeholder/releases/latest)"
- label: "I am able to reproduce the bug with the [latest version](https://github.com/xdev-software/chartjs-java-model/releases/latest)"
required: true
- 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."
- 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."
required: true
- label: "I have taken the time to fill in all the required details. I understand that the bug report will be dismissed otherwise."
required: true
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/enhancement.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ body:
attributes:
label: "Checklist"
options:
- 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."
- 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."
required: true
- label: "I have taken the time to fill in all the required details. I understand that the feature request will be dismissed otherwise."
required: true
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/question.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ body:
attributes:
label: "Checklist"
options:
- 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."
- 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."
required: true
- label: "I have taken the time to fill in all the required details. I understand that the question will be dismissed otherwise."
required: true
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/check-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

strategy:
matrix:
java: [17, 21]
java: [11, 17, 21]
distribution: [temurin]

steps:
Expand All @@ -44,7 +44,8 @@ jobs:
cache: 'maven'

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

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

- name: Upload screenshots of test failures
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-fail-screenshots-${{ matrix.java }}
path: ${{ env.PRIMARY_MAVEN_MODULE }}/target/screenshots
if-no-files-found: ignore

checkstyle:
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' || !startsWith(github.head_ref, 'renovate/') }}
Expand Down
2 changes: 1 addition & 1 deletion .run/Run Demo.run.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run Demo" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" value="software.xdev.Application" />
<module name="template-placeholder-demo" />
<module name="chartjs-java-model-demo" />
<option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
<extension name="coverage">
<pattern>
Expand Down
109 changes: 109 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
## 2.6.0
* Synced ``Doughnut/PieOptions`` from ChartJS source code #293
* Synced ``GridLineConfiguration`` from ChartJS source code / improved Types for more options #289
* Updated dependencies

## 2.5.0
* Synced ``Legend`` from ChartJS source code #285

## 2.4.0
* PointStyle can also contain non-string constants #280
* Use ``CoreInteractionOptions`` for ``Options#interaction`` and ``Options#hover`` #281
* Updated dependencies

## 2.3.1
* Synced ``LineOptions/DataSet`` ``stepped`` and ``tension`` with ChartJS source #262
* Updated dependencies

## 2.3.0
* Update available datasets fields from ChartJS source code #244
* Removed deprecated code

## 2.2.0
* Improve color handling #238
* Change ``Color`` to ``RGBAColor`` as it only handles RGBA
* Change all occurrences of ``Color`` to ``Object`` so that other color models (e.g. HSLA or Hex) can be applied
* Created ``HSLAColor`` that can be used like ``RGBAColor``

## 2.1.0
* Charts no longer check if they are drawable #198
* ChartJS behavior: If a chart can't be drawn it will render a empty canvas
* Deprecated methods: ``Chart#toJsonNative`` and ``Chart#isDrawable``
* Make ``IndexAxis`` available in all options

## 2.0.2
_Same as version 2.1.0 - Version was not incremented correctly_

## 2.0.1
* Restored ``DisplayFormats`` #186

## 2.0.0
* 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)
* The use of ``Color`` for various coloring related options is no longer required.
* It's now possible to use e.g. strings

## 1.5.0
* Added ``JsonIgnore`` to certain fields to help prevent infinite loops #174
* Corrected model for ``Title`` and ``Font`` #175

## 1.4.1
* Use ``Number`` instead of ``BigDecimal`` in some additional places #159 (@aripddev)

## 1.4.0
* Simplify API by using ``Number`` instead of ``BigDecimal``, ``int`` and ``double`` for ``Datapoints`` #154 (@aripddev)

## 1.3.1
* Add subtitle option #141 (@aripddev)
* Add ``PointStyle#rectRounded`` #143 (@aripddev)
* Add ``BubbleDataset#pointStyle`` #144 (@aripddev)
* ``reverse`` property should be on the ``Scale`` object #145
* Added all available properties for ``Legend``

## 1.3.0
* Allows creation of mixed charts #128
* New chart class: ``MixedChart``
* Some classes have been renamed
* ``Data`` -> ``HomogeneousData``
* ``AbstractChart`` -> ``HomogeneousChart``
* Slim down test dependencies

## 1.2.0
* Add TimeScale and TimeTicks to allow building linear time charts #90 (@astappiev)
* Add options for the [Zoom plugin](https://www.chartjs.org/chartjs-plugin-zoom/latest/) #117 (@astappiev)
* Updated dependencies

## 1.1.3
* Add ``toJsonNative`` method which doesn't run the ``isDrawable`` check #91

## 1.1.2
* ⚠️ GroupId changed from ``com.xdev-software`` to ``software.xdev``

## 1.1.1
* ``AngleLines#lineWidth`` now uses ``BigDecimal`` #76
* Updated dependencies

## 1.1.0
* Added support for more [data structures](https://www.chartjs.org/docs/4.4.0/general/data-structures.html) inside ``Dataset#data``
* ``Dataset#data`` can now contain ``Object``s

## 1.0.2
* Support Java 11
* Updated dependencies

## 1.0.1
* Added support for [stacked bar chart with groups](https://www.chartjs.org/docs/4.4.0/samples/bar/stacked-groups.html) (@dlemaignent)

## 1.0.0
Initial release

Support for Chart.js v4

Noteworthy changes compared to [Chart.java](https://github.com/mdewilde/chart):
* Changed the package to ``software.xdev.chartjs.model``
* All charts (e.g. ``BarChart``, ``LineChart``, ...) are now inside the ``charts`` package
* Breaking API changes due to compatibility with Chart.js v4; You may checkout the migration guides
* [3.x Migration Guide](https://www.chartjs.org/docs/4.3.0/migration/v3-migration.html)
* [4.x Migration Guide](https://www.chartjs.org/docs/4.3.0/migration/v4-migration.html)
* JSON is no longer pretty printed by default due to performance reasons
* Implemented integration tests
* Requires Java 17
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ You should have the following things installed:
* Ensure that the JDK/Java-Version is correct


## 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)
## 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)

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

If the ``develop`` is ready for release, create a pull request to the ``master``-Branch and merge the changes
Expand Down
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@
identification within third-party archives.

Copyright 2024 XDEV Software
Copyright 2020 Marceau Dewilde

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
31 changes: 25 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
[![Latest version](https://img.shields.io/maven-central/v/software.xdev/template-placeholder?logo=apache%20maven)](https://mvnrepository.com/artifact/software.xdev/template-placeholder)
[![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)
[![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)
[![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)
[![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)
[![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)
[![ChartJS Documentation](https://img.shields.io/badge/Chart.js-documentation-ff6384?logo=Chart.js)](https://www.chartjs.org/docs/latest/)

# template-placeholder
# <img src="https://www.chartjs.org/media/logo.svg" height="38" /> 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.<br/>
> Therefore some parts migth still be missing or use the outdated v2 API from the original repo.<br/>
> If you think you found a missing or incorrect API please open an issue and/or provide a pull request.
## Installation
[Installation guide for the latest release](https://github.com/xdev-software/template-placeholder/releases/latest#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+`` |

## 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).
Expand All @@ -15,4 +28,10 @@ If you need support as soon as possible and you can't wait for any pull request,
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/template-placeholder/dependencies)
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

<sub>Disclaimer: This is not an official ChartJS product and not associated</sub>
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

## Reporting a Vulnerability

Please report a security vulnerability [on GitHub Security Advisories](https://github.com/xdev-software/template-placeholder/security/advisories/new).
Please report a security vulnerability [on GitHub Security Advisories](https://github.com/xdev-software/chartjs-java-model/security/advisories/new).
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

<parent>
<groupId>software.xdev</groupId>
<artifactId>template-placeholder-root</artifactId>
<version>1.0.0-SNAPSHOT</version>
<artifactId>chartjs-java-model-root</artifactId>
<version>2.6.1-SNAPSHOT</version>
</parent>

<artifactId>template-placeholder-demo</artifactId>
<version>1.0.0-SNAPSHOT</version>
<artifactId>chartjs-java-model-demo</artifactId>
<version>2.6.1-SNAPSHOT</version>
<packaging>jar</packaging>

<organization>
Expand All @@ -20,7 +20,7 @@
</organization>

<properties>
<javaVersion>17</javaVersion>
<javaVersion>11</javaVersion>
<maven.compiler.release>${javaVersion}</maven.compiler.release>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand All @@ -32,7 +32,7 @@
<dependencies>
<dependency>
<groupId>software.xdev</groupId>
<artifactId>template-placeholder</artifactId>
<artifactId>chartjs-java-model</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package software.xdev;

import java.awt.Desktop;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.Path;

import software.xdev.chartjs.model.charts.BarChart;
import software.xdev.chartjs.model.charts.Chart;
import software.xdev.chartjs.model.data.BarData;
import software.xdev.chartjs.model.dataset.BarDataset;
import software.xdev.chartjs.model.options.BarOptions;


public final class Application
{
private Application()
{
}

public static void main(final String[] args)
{
final BarData data = new BarData();
data.addLabels("A", "B", "C");
data.addDataset(new BarDataset()
.setLabel("Dataset1")
.setData(1, 3, 2));

createAndOpenTestFile(new BarChart()
.setData(data)
.setOptions(new BarOptions()));
}

@SuppressWarnings("java:S5443") // Only a demo nothing sensitive is here
private static void createAndOpenTestFile(final Chart<?, ?, ?> chart)
{
try
{
final Path tmp = Files.createTempFile("chart_test_", ".html");

Files.writeString(
tmp,
String.format("<!DOCTYPE html>\n"
+ "<html lang='en'>\n"
+ "\t<head>\n"
+ "\t\t<meta charset='UTF-8'>\n"
+ "\t\t<script src=\"https://cdn.jsdelivr.net/npm/[email protected]/dist/chart.umd.js\"></script>\n"
+ "\t</head>\n"
+ "\t<body>\n"
+ "\t\t<canvas id='c' style='border:1px solid #555;'></canvas>\n"
+ "\t\t<script>\n"
+ "\t\t\tnew Chart(document.getElementById('c').getContext('2d'), %s);\n"
+ "\t\t</script>\n"
+ "\t</body>\n"
+ "</html>", chart.toJson())
);

Desktop.getDesktop().browse(tmp.toUri());
}
catch(final IOException e)
{
throw new UncheckedIOException(e);
}
}
}
Loading

0 comments on commit 457bcd2

Please sign in to comment.