From 80f331d16c54a3ef688a485f65453f0061cb99da Mon Sep 17 00:00:00 2001 From: Willem Verstraeten Date: Fri, 26 Nov 2021 13:37:44 +0100 Subject: [PATCH 1/2] feat: allow setting global options #2335 --- .../flow/component/charts/ChartOptions.java | 26 ++++++++++++++++ .../ChartOptionsJSONSerializationTest.java | 31 +++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/vaadin-charts-flow-parent/vaadin-charts-flow/src/main/java/com/vaadin/flow/component/charts/ChartOptions.java b/vaadin-charts-flow-parent/vaadin-charts-flow/src/main/java/com/vaadin/flow/component/charts/ChartOptions.java index 49c85fc5a04..3cc439272d6 100644 --- a/vaadin-charts-flow-parent/vaadin-charts-flow/src/main/java/com/vaadin/flow/component/charts/ChartOptions.java +++ b/vaadin-charts-flow-parent/vaadin-charts-flow/src/main/java/com/vaadin/flow/component/charts/ChartOptions.java @@ -8,6 +8,7 @@ import com.vaadin.flow.component.UI; import com.vaadin.flow.component.HasComponents; import com.vaadin.flow.component.charts.model.AbstractConfigurationObject; +import com.vaadin.flow.component.charts.model.Global; import com.vaadin.flow.component.charts.model.Lang; import com.vaadin.flow.component.charts.model.style.Theme; import com.vaadin.flow.component.charts.util.ChartSerialization; @@ -27,6 +28,7 @@ public class ChartOptions extends AbstractConfigurationObject { @JsonUnwrapped private Theme theme; private Lang lang; + private Global global; private transient JreJsonFactory jsonFactory; protected ChartOptions() { @@ -96,6 +98,30 @@ public void setTheme(Theme theme) { updateOptions(); } + /** + * Returns the {@link Global} in use or {@code null} if no global configuration + * has been set. + * + * @return the {@link Global} in use or {@code null}. + */ + public Global getGlobal() { + return global; + } + + /** + * Changes the Global params of all charts. + *

+ * Note that if the view is already drawn, all existing {@link Chart}s will + * be redrawn. + * + * @param global + */ + public void setGlobal(Global global) { + this.global = global; + updateOptions(); + } + + /** * Returns a ChartOptions instance for the given UI. If a ChartOptions * extension has not yet been added, a new one is created and added. diff --git a/vaadin-charts-flow-parent/vaadin-charts-flow/src/test/java/com/vaadin/flow/component/charts/ChartOptionsJSONSerializationTest.java b/vaadin-charts-flow-parent/vaadin-charts-flow/src/test/java/com/vaadin/flow/component/charts/ChartOptionsJSONSerializationTest.java index 1c5500f82f2..bc4c82651cc 100644 --- a/vaadin-charts-flow-parent/vaadin-charts-flow/src/test/java/com/vaadin/flow/component/charts/ChartOptionsJSONSerializationTest.java +++ b/vaadin-charts-flow-parent/vaadin-charts-flow/src/test/java/com/vaadin/flow/component/charts/ChartOptionsJSONSerializationTest.java @@ -14,6 +14,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.vaadin.flow.component.UI; +import com.vaadin.flow.component.charts.model.Global; import com.vaadin.flow.component.charts.model.Lang; import com.vaadin.flow.component.charts.util.ChartSerialization; @@ -84,4 +85,34 @@ public void toJSON_LangWithFinnishLocale_LocaleSerialized_Days() Assert.assertArrayEquals(fiDays, chartOptions.getLang().getWeekdays()); } + + @Test + public void toJSON_GlobalWithoutUTC() + throws IOException { + final Global noUTC = new Global(); + noUTC.setUseUTC(false); + + options.setGlobal(noUTC); + String json = toJSON(options); + + ObjectMapper om = ChartSerialization.createObjectMapper(); + ChartOptions chartOptions = om.readValue(json, ChartOptions.class); + + Assert.assertFalse(chartOptions.getGlobal().getUseUTC()); + } + + @Test + public void toJSON_GlobalWithUTC() + throws IOException { + final Global withUTC = new Global(); + withUTC.setUseUTC(true); + + options.setGlobal(withUTC); + String json = toJSON(options); + + ObjectMapper om = ChartSerialization.createObjectMapper(); + ChartOptions chartOptions = om.readValue(json, ChartOptions.class); + + Assert.assertTrue(chartOptions.getGlobal().getUseUTC()); + } } \ No newline at end of file From 495b8829ffd0f1cb4e39674856c9862c01638ca7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 May 2022 09:55:00 +0000 Subject: [PATCH 2/2] chore: bump maven-gpg-plugin from 1.6 to 3.0.1 Bumps [maven-gpg-plugin](https://github.com/apache/maven-gpg-plugin) from 1.6 to 3.0.1. - [Release notes](https://github.com/apache/maven-gpg-plugin/releases) - [Commits](https://github.com/apache/maven-gpg-plugin/compare/maven-gpg-plugin-1.6...maven-gpg-plugin-3.0.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-gpg-plugin dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index acba6af31f6..4e09ac83c51 100644 --- a/pom.xml +++ b/pom.xml @@ -452,7 +452,7 @@ maven-gpg-plugin - 1.6 + 3.0.1 maven-install-plugin