diff --git a/addon/src/main/java/com/vaadin/addon/charts/client/ui/HighchartWidget.java b/addon/src/main/java/com/vaadin/addon/charts/client/ui/HighchartWidget.java
index 8f01bcea7..7fcaf2dc8 100644
--- a/addon/src/main/java/com/vaadin/addon/charts/client/ui/HighchartWidget.java
+++ b/addon/src/main/java/com/vaadin/addon/charts/client/ui/HighchartWidget.java
@@ -21,13 +21,16 @@
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Document;
+import com.google.gwt.user.client.ui.HasEnabled;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.addon.charts.client.HighchartsScriptLoader;
import com.vaadin.client.BrowserInfo;
+import com.vaadin.client.StyleConstants;
-public class HighchartWidget extends Widget {
+public class HighchartWidget extends Widget implements HasEnabled {
private HighchartJsOverlay jsOverlay;
+ private boolean enabled;
public HighchartWidget() {
HighchartsScriptLoader.ensureInjected();
@@ -207,4 +210,17 @@ public int getXAxisIndex(HighchartAxis axis) {
public int getNumberOfSeries() {
return jsOverlay.getSeries().length();
}
+
+ @Override
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ @Override
+ public void setEnabled(boolean enabled) {
+ if (this.enabled != enabled) {
+ this.enabled = enabled;
+ setStyleName(StyleConstants.DISABLED, !enabled);
+ }
+ }
}
diff --git a/addon/src/main/resources/com/vaadin/addon/charts/Widgetset.gwt.xml b/addon/src/main/resources/com/vaadin/addon/charts/Widgetset.gwt.xml
index f0a7214d9..2b050dce0 100644
--- a/addon/src/main/resources/com/vaadin/addon/charts/Widgetset.gwt.xml
+++ b/addon/src/main/resources/com/vaadin/addon/charts/Widgetset.gwt.xml
@@ -26,4 +26,6 @@
+
+
diff --git a/addon/src/main/resources/com/vaadin/addon/charts/public/charts/styles.css b/addon/src/main/resources/com/vaadin/addon/charts/public/charts/styles.css
new file mode 100644
index 000000000..b8abc9c55
--- /dev/null
+++ b/addon/src/main/resources/com/vaadin/addon/charts/public/charts/styles.css
@@ -0,0 +1,6 @@
+.v-disabled {
+ .vaadin-chart {
+ pointer-events: none;
+ opacity: 70%;
+ }
+}
diff --git a/examples/src/main/java/com/vaadin/addon/charts/examples/columnandbar/BarWithDisabledState.java b/examples/src/main/java/com/vaadin/addon/charts/examples/columnandbar/BarWithDisabledState.java
new file mode 100644
index 000000000..9e94027ba
--- /dev/null
+++ b/examples/src/main/java/com/vaadin/addon/charts/examples/columnandbar/BarWithDisabledState.java
@@ -0,0 +1,29 @@
+package com.vaadin.addon.charts.examples.columnandbar;
+
+import com.vaadin.addon.charts.examples.SkipFromDemo;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Component;
+
+@SuppressWarnings("serial")
+@SkipFromDemo
+public class BarWithDisabledState extends BasicBarNoTitle {
+
+ private Component chart;
+
+ @Override
+ protected Component getChart() {
+ chart = super.getChart();
+ chart.setId("bar-with-disabled-state");
+
+ return chart;
+ }
+
+ @Override
+ protected void setup() {
+ super.setup();
+
+ Button button = new Button("toggle enabled", e -> chart.setEnabled(!chart.isEnabled()));
+ button.setId("disable-button");
+ addComponent(button);
+ }
+}
diff --git a/integration-tests/src/test/java/com/vaadin/addon/charts/testbenchtests/BarWithDisabledStateTBTest.java b/integration-tests/src/test/java/com/vaadin/addon/charts/testbenchtests/BarWithDisabledStateTBTest.java
new file mode 100644
index 000000000..0fbb45963
--- /dev/null
+++ b/integration-tests/src/test/java/com/vaadin/addon/charts/testbenchtests/BarWithDisabledStateTBTest.java
@@ -0,0 +1,47 @@
+package com.vaadin.addon.charts.testbenchtests;
+
+import java.io.IOException;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.addon.charts.examples.columnandbar.BarWithDisabledState;
+import com.vaadin.client.StyleConstants;
+import com.vaadin.testbench.elements.ButtonElement;
+
+public class BarWithDisabledStateTBTest extends AbstractParallelTest {
+
+ @Test
+ public void test() throws IOException, AssertionError {
+ driver.get(getTestUrl());
+
+ waitForVaadin();
+
+ WebElement chart = findElement(By.id("bar-with-disabled-state"));
+
+ ButtonElement disableButton = $(ButtonElement.class).id("disable-button");
+ disableButton.click();
+ waitForVaadin();
+
+ Assert.assertTrue(chart.getAttribute("class").contains(StyleConstants.DISABLED));
+
+ disableButton.click();
+ waitForVaadin();
+
+ Assert.assertFalse(chart.getAttribute("class").contains(StyleConstants.DISABLED));
+
+ }
+
+ @Override
+ protected String getTestViewName() {
+ return BarWithDisabledState.class.getSimpleName();
+ }
+
+ @Override
+ protected String getPackageName() {
+ return "columnandbar";
+ }
+
+}