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 a43947b61198763f590c90c5780e13f3aab56f7b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 May 2022 09:54:35 +0000 Subject: [PATCH 2/2] chore: bump ci-sauce from 1.155 to 1.156 Bumps [ci-sauce](https://github.com/saucelabs/ci-sauce) from 1.155 to 1.156. - [Release notes](https://github.com/saucelabs/ci-sauce/releases) - [Changelog](https://github.com/saucelabs/ci-sauce/blob/master/CHANGELOG.md) - [Commits](https://github.com/saucelabs/ci-sauce/compare/ci-sauce-1.155...ci-sauce-1.156) --- updated-dependencies: - dependency-name: com.saucelabs:ci-sauce dependency-type: direct:development update-type: version-update:semver-minor ... 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..e0c20c13fad 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,7 @@ false false 2.1.25 - 1.155 + 1.156 --tunnel-identifier ${maven.build.timestamp} http://www.apache.org/licenses/LICENSE-2.0 default