Skip to content

Commit f1e4a85

Browse files
committed
Merge branch 'develop' into update-from-template-merged
2 parents 44bfac8 + 15db03e commit f1e4a85

40 files changed

+1339
-34
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 2 additions & 2 deletions
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/vaadin-chartjs-wrapper/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/vaadin-chartjs-wrapper/issues) or [closed](https://github.com/xdev-software/vaadin-chartjs-wrapper/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

Lines changed: 1 addition & 1 deletion
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/vaadin-chartjs-wrapper/issues) or [closed](https://github.com/xdev-software/vaadin-chartjs-wrapper/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

Lines changed: 1 addition & 1 deletion
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/vaadin-chartjs-wrapper/issues) or [closed](https://github.com/xdev-software/vaadin-chartjs-wrapper/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

.run/Run Demo.run.xml

Lines changed: 1 addition & 1 deletion
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.vaadin.Application" />
4-
<module name="template-placeholder-demo" />
4+
<module name="vaadin-chartjs-wrapper-demo" />
55
<option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
66
<extension name="coverage">
77
<pattern>

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# 1.0.0
2+
_Initial stable release_
3+
4+
# 0.x
5+
_Initial preview release for evaluation_

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ Bigger changes may require a complete restart.
4747
* [Vaadin automatically reloads the UI on each restart](https://vaadin.com/docs/latest/configuration/live-reload/spring-boot).<br/>
4848
You can control this behavior with the ``vaadin.devmode.liveReload.enabled`` property (default: ``true``).
4949

50-
## 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)
50+
## Releasing [![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/vaadin-chartjs-wrapper/release.yml?branch=master)](https://github.com/xdev-software/vaadin-chartjs-wrapper/actions/workflows/release.yml)
5151

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

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

README.md

Lines changed: 95 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,108 @@
1-
[![Published on Vaadin Directory](https://img.shields.io/badge/Vaadin%20Directory-published-00b4f0?logo=vaadin)](https://vaadin.com/directory/component/template-placeholder)
2-
[![Latest version](https://img.shields.io/maven-central/v/software.xdev/template-placeholder?logo=apache%20maven)](https://mvnrepository.com/artifact/software.xdev/template-placeholder)
3-
[![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)
1+
[![Published on Vaadin Directory](https://img.shields.io/badge/Vaadin%20Directory-published-00b4f0?logo=vaadin)](https://vaadin.com/directory/component/chartjs-wrapper-for-vaadin)
2+
[![Latest version](https://img.shields.io/maven-central/v/software.xdev/vaadin-chartjs-wrapper?logo=apache%20maven)](https://mvnrepository.com/artifact/software.xdev/vaadin-chartjs-wrapper)
3+
[![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/vaadin-chartjs-wrapper/check-build.yml?branch=develop)](https://github.com/xdev-software/vaadin-chartjs-wrapper/actions/workflows/check-build.yml?query=branch%3Adevelop)
44
![Vaadin 24+](https://img.shields.io/badge/Vaadin%20Platform/Flow-24+-00b4f0)
55

6-
# template-placeholder
7-
A Vaadin Template Repo
6+
# <img src="https://www.chartjs.org/media/logo.svg" height="38" /> Chart.js Wrapper for Vaadin
7+
8+
A [Chart.js](https://www.chartjs.org/) 4+ Wrapper for Vaadin
89

910
![demo](assets/demo.png)
1011

12+
## Usage
13+
14+
For more and detailed usage examples please have a look at [the demo](./vaadin-chartjs-wrapper-demo/src/main/java/software/xdev/vaadin/chartjs/demo/).
15+
16+
### Minimal
17+
18+
```java
19+
// Assumes that this code is in some kind of Vaadin component or view
20+
ChartContainer chart = new ChartContainer();
21+
this.add(chart);
22+
23+
chart.showChart(
24+
"{\"data\":{\"labels\":[\"A\",\"B\"],\"datasets\":[{\"data\":[1,2],\"label\":\"X\"}]},\"type\":\"bar\"}");
25+
26+
// Or utilizing chartjs-java-model
27+
chart.showChart(new BarChart(new BarData()
28+
.addLabels("A", "B")
29+
.addDataset(new BarDataset()
30+
.setLabel("X")
31+
.addData(1)
32+
.addData(2)))
33+
.toJson());
34+
```
35+
36+
### Recommended
37+
38+
1. Use a Java model of Java model of Chart.js's configuration, like [XDEV's chartjs-java-model](https://github.com/xdev-software/chartjs-java-model).<br/>
39+
Otherwise you have to write the JSON yourself.
40+
2. Optionally derive classes for your charts (from e.g. ``ChartContainer``) that also handle the data-to-JSON conversion logic.<br/>
41+
Therefore you can encapsulate the components properly, for example like this: ``FetchFromBackendService.class → Model for chart → ChartContainer.class → Build JSON and show chart``
42+
43+
<details><summary>Here is a example how the code could look (click to expand)</summary>
44+
45+
1. Define a custom chart or use the ``showChart``-method directly.<br/>Example:
46+
```java
47+
public class ExampleChartContainer extends ChartContainer
48+
{
49+
public void show(Data data)
50+
{
51+
BarData data = ...; // Build the bar chart data from the handed over data
52+
this.showChart(new BarChart(data)
53+
.setOptions(new BarOptions()
54+
.setResponsive(true)
55+
.setMaintainAspectRatio(false)
56+
.setPlugins(new Plugins()
57+
.setTitle(new Title()
58+
.setText("Age")
59+
.setDisplay(true))))
60+
.toJson());
61+
}
62+
}
63+
```
64+
2. Add the chart to your view/component:
65+
```java
66+
public class ExampleView extends VerticalLayout
67+
{
68+
private final ExampleChartContainer chart = new ExampleChartContainer();
69+
70+
public ExampleView()
71+
{
72+
this.add(this.chart);
73+
// ...
74+
}
75+
76+
private void loadDataAndShowChart()
77+
{
78+
this.chart.showLoading();
79+
80+
UI ui = UI.getCurrent();
81+
CompletableFuture.runAsync(() -> {
82+
try {
83+
var data = ...; // Load some data from the backend
84+
// You may also convert the data here and call showChart
85+
ui.access(() -> this.chart.show(data));
86+
} catch (Exception ex) {
87+
// Display the error message when loading fails
88+
ui.access(() -> this.chart.showFailed(ex.getMessage()));
89+
}
90+
});
91+
}
92+
}
93+
```
94+
95+
</details>
1196

1297
## Installation
13-
[Installation guide for the latest release](https://github.com/xdev-software/template-placeholder/releases/latest#Installation)
98+
[Installation guide for the latest release](https://github.com/xdev-software/vaadin-chartjs-wrapper/releases/latest#Installation)
1499

15100
### Spring-Boot
16101
* You may have to include ``software/xdev`` inside [``vaadin.allowed-packages``](https://vaadin.com/docs/latest/integrations/spring/configuration#configure-the-scanning-of-packages)
17102

18103
## Run the Demo
19104
* Checkout the repo
20-
* Run ``mvn install && mvn -f template-placeholder-demo spring-boot:run``
105+
* Run ``mvn install && mvn -f vaadin-chartjs-wrapper-demo spring-boot:run``
21106
* Open http://localhost:8080
22107

23108
<details>
@@ -33,4 +118,6 @@ If you need support as soon as possible and you can't wait for any pull request,
33118
See the [contributing guide](./CONTRIBUTING.md) for detailed instructions on how to get started with our project.
34119
35120
## Dependencies and Licenses
36-
View the [license of the current project](LICENSE) or the [summary including all dependencies](https://xdev-software.github.io/template-placeholder/dependencies)
121+
View the [license of the current project](LICENSE) or the [summary including all dependencies](https://xdev-software.github.io/vaadin-chartjs-wrapper/dependencies)
122+
123+
<sub>Disclaimer: This is not an official Chart.js product and not associated</sub>

SECURITY.md

Lines changed: 1 addition & 1 deletion
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/vaadin-chartjs-wrapper/security/advisories/new).

assets/demo.avif

116 KB
Binary file not shown.

assets/demo.png

-4.92 KB
Loading

0 commit comments

Comments
 (0)