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 ea2ab889a48a5c91bfca4758a6aa03a5e573bb1f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 May 2022 09:54:47 +0000 Subject: [PATCH 2/2] chore: bump jetty-maven-plugin from 9.4.46.v20220331 to 11.0.9 Bumps [jetty-maven-plugin](https://github.com/eclipse/jetty.project) from 9.4.46.v20220331 to 11.0.9. - [Release notes](https://github.com/eclipse/jetty.project/releases) - [Commits](https://github.com/eclipse/jetty.project/compare/jetty-9.4.46.v20220331...jetty-11.0.9) --- updated-dependencies: - dependency-name: org.eclipse.jetty:jetty-maven-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..667d5f566d8 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ UTF-8 UTF-8 - 9.4.46.v20220331 + 11.0.9 8080 9999 2.22.2