You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2018/06/01 15:29:14 UTC
[4/6] syncope git commit: Replace the (apparently now unsupported)
wicket-chartjs
Replace the (apparently now unsupported) wicket-chartjs
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/e78f91e2
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/e78f91e2
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/e78f91e2
Branch: refs/heads/master
Commit: e78f91e24b5a2860fd49e3d70dd7abcf8e12913d
Parents: 17830e5
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Fri Jun 1 16:49:10 2018 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Fri Jun 1 17:26:51 2018 +0200
----------------------------------------------------------------------
client/console/pom.xml | 8 +-
.../syncope/client/console/chartjs/Bar.java | 45 ++
.../client/console/chartjs/BarChartData.java | 30 +
.../client/console/chartjs/BarChartOptions.java | 157 +++++
.../client/console/chartjs/BarDataSet.java | 48 ++
.../client/console/chartjs/BaseDataSet.java | 93 +++
.../syncope/client/console/chartjs/Chart.java | 38 ++
.../client/console/chartjs/ChartData.java | 47 ++
.../client/console/chartjs/ChartJSBehavior.java | 49 ++
.../client/console/chartjs/ChartJSPanel.java | 80 +++
.../client/console/chartjs/ChartOptions.java | 641 +++++++++++++++++++
.../client/console/chartjs/DataSetChart.java | 44 ++
.../client/console/chartjs/Doughnut.java | 49 ++
.../console/chartjs/DoughnutChartData.java | 52 ++
.../console/chartjs/DoughnutChartOptions.java | 49 ++
.../client/console/chartjs/DoughnutDataSet.java | 38 ++
.../syncope/client/console/chartjs/Line.java | 40 ++
.../client/console/chartjs/LineChartData.java | 30 +
.../console/chartjs/LineChartOptions.java | 227 +++++++
.../client/console/chartjs/LineDataSet.java | 43 ++
.../client/console/chartjs/PieChartOptions.java | 145 +++++
.../console/chartjs/PointColorDataSet.java | 80 +++
.../client/console/chartjs/SimpleChart.java | 43 ++
.../chartjs/SimpleColorValueChartData.java | 52 ++
.../console/widgets/AnyByRealmWidget.java | 55 +-
.../console/widgets/CompletenessWidget.java | 13 +-
.../console/widgets/LabeledBarDataSet.java | 42 --
.../widgets/LabeledDoughnutChartData.java | 46 --
.../client/console/widgets/LoadWidget.java | 34 +-
.../console/widgets/UsersByStatusWidget.java | 12 +-
.../client/console/chartjs/ChartJSPanel.html | 23 +
.../syncope/client/console/pages/Dashboard.html | 11 +
.../pushpull/AbstractPushResultHandler.java | 14 +-
.../console/widgets/CamelMetricsWidget.java | 17 +-
pom.xml | 24 +-
35 files changed, 2231 insertions(+), 188 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/e78f91e2/client/console/pom.xml
----------------------------------------------------------------------
diff --git a/client/console/pom.xml b/client/console/pom.xml
index 0843ab6..d3103e9 100644
--- a/client/console/pom.xml
+++ b/client/console/pom.xml
@@ -94,10 +94,6 @@ under the License.
<groupId>de.agilecoders.wicket</groupId>
<artifactId>wicket-bootstrap-extensions</artifactId>
</dependency>
- <dependency>
- <groupId>com.pingunaut</groupId>
- <artifactId>wicket-chartjs</artifactId>
- </dependency>
<dependency>
<groupId>org.apache.syncope.client</groupId>
@@ -140,6 +136,10 @@ under the License.
<artifactId>jsplumb</artifactId>
</dependency>
<dependency>
+ <groupId>org.webjars.bower</groupId>
+ <artifactId>chart.js</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery-cookie</artifactId>
</dependency>
http://git-wip-us.apache.org/repos/asf/syncope/blob/e78f91e2/client/console/src/main/java/org/apache/syncope/client/console/chartjs/Bar.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/chartjs/Bar.java b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/Bar.java
new file mode 100644
index 0000000..0d3089b
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/Bar.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.chartjs;
+
+/**
+ * Provides a simple implementation of chart.js bar chart.
+ *
+ * @see <a href="http://www.chartjs.org/docs/#barChart">chart.js docs</a>
+ */
+public class Bar extends DataSetChart<BarChartData<BarDataSet>, BarChartOptions, BarDataSet> {
+
+ private static final long serialVersionUID = -332976997065056554L;
+
+ @Override
+ public BarChartOptions getOptions() {
+ if (options == null) {
+ options = new BarChartOptions();
+ }
+ return options;
+ }
+
+ @Override
+ public BarChartData<BarDataSet> getData() {
+ if (data == null) {
+ data = new BarChartData<>();
+ }
+ return data;
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/e78f91e2/client/console/src/main/java/org/apache/syncope/client/console/chartjs/BarChartData.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/chartjs/BarChartData.java b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/BarChartData.java
new file mode 100644
index 0000000..45608a4
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/BarChartData.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.chartjs;
+
+/**
+ * Provides chart data used by bar charts.
+ *
+ * @param <T> the generic type of it's dataset
+ */
+public class BarChartData<T extends BaseDataSet> extends ChartData<T> {
+
+ private static final long serialVersionUID = 9057475640743455047L;
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/e78f91e2/client/console/src/main/java/org/apache/syncope/client/console/chartjs/BarChartOptions.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/chartjs/BarChartOptions.java b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/BarChartOptions.java
new file mode 100644
index 0000000..6616f2a
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/BarChartOptions.java
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.chartjs;
+
+/**
+ * Provides options, that are available for {@link Bar}.
+ */
+public class BarChartOptions extends ChartOptions {
+
+ private static final long serialVersionUID = -5356780831848556616L;
+
+ /**
+ * Whether to show horizontal lines (except X axis).
+ */
+ private Boolean scaleShowHorizontalLines = true;
+
+ /**
+ * Whether to show vertical lines (except Y axis).
+ */
+ private Boolean scaleShowVerticalLines = true;
+
+ /**
+ * A legend template.
+ */
+ private String legendTemplate = "<ul class=\"<%=name.toLowerCase()%>-legend\">"
+ + "<% for (var i=0; i<datasets.length; i++){%><li>"
+ + "<span style=\"background-color:<%=datasets[i].fillColor%>\"></span>"
+ + "<%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>";
+
+ /**
+ * The bar show stroke.
+ */
+ private Boolean barShowStroke;
+
+ /**
+ * The bar stroke width.
+ */
+ private Integer barStrokeWidth;
+
+ /** The bar value spacing. */
+ private Integer barValueSpacing;
+
+ /** The bar dataset spacing. */
+ private Integer barDatasetSpacing;
+
+ public Boolean getScaleShowHorizontalLines() {
+ return scaleShowHorizontalLines;
+ }
+
+ public void setScaleShowHorizontalLines(final Boolean scaleShowHorizontalLines) {
+ this.scaleShowHorizontalLines = scaleShowHorizontalLines;
+ }
+
+ public Boolean getScaleShowVerticalLines() {
+ return scaleShowVerticalLines;
+ }
+
+ public void setScaleShowVerticalLines(final Boolean scaleShowVerticalLines) {
+ this.scaleShowVerticalLines = scaleShowVerticalLines;
+ }
+
+ public String getLegendTemplate() {
+ return legendTemplate;
+ }
+
+ public void setLegendTemplate(final String legendTemplate) {
+ this.legendTemplate = legendTemplate;
+ }
+
+ /**
+ * Gets the bar show stroke.
+ *
+ * @return the bar show stroke
+ */
+ public Boolean getBarShowStroke() {
+ return barShowStroke;
+ }
+
+ /**
+ * Sets the bar show stroke.
+ *
+ * @param barShowStroke the new bar show stroke (default is true).
+ */
+ public void setBarShowStroke(final Boolean barShowStroke) {
+ this.barShowStroke = barShowStroke;
+ }
+
+ /**
+ * Gets the bar stroke width.
+ *
+ * @return the bar stroke width
+ */
+ public Integer getBarStrokeWidth() {
+ return barStrokeWidth;
+ }
+
+ /**
+ * Sets the bar stroke width.
+ *
+ * @param barStrokeWidth the new bar stroke width (default is 2).
+ */
+ public void setBarStrokeWidth(final Integer barStrokeWidth) {
+ this.barStrokeWidth = barStrokeWidth;
+ }
+
+ /**
+ * Gets the bar value spacing.
+ *
+ * @return the bar value spacing
+ */
+ public Integer getBarValueSpacing() {
+ return barValueSpacing;
+ }
+
+ /**
+ * Sets the bar value spacing.
+ *
+ * @param barValueSpacing the spacing between each of the X value sets (default is 5)
+ */
+ public void setBarValueSpacing(final Integer barValueSpacing) {
+ this.barValueSpacing = barValueSpacing;
+ }
+
+ /**
+ * Gets the bar dataset spacing.
+ *
+ * @return the bar dataset spacing
+ */
+ public Integer getBarDatasetSpacing() {
+ return barDatasetSpacing;
+ }
+
+ /**
+ * Sets the bar dataset spacing.
+ *
+ * @param barDatasetSpacing the spacing between data sets within X values (default is 1).
+ */
+ public void setBarDatasetSpacing(final Integer barDatasetSpacing) {
+ this.barDatasetSpacing = barDatasetSpacing;
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/e78f91e2/client/console/src/main/java/org/apache/syncope/client/console/chartjs/BarDataSet.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/chartjs/BarDataSet.java b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/BarDataSet.java
new file mode 100644
index 0000000..f561c44
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/BarDataSet.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.chartjs;
+
+import java.util.List;
+
+/**
+ * Provides all information needed for {@link BarChartData}.
+ */
+public class BarDataSet extends BaseDataSet {
+
+ private static final long serialVersionUID = 3095383371272813559L;
+
+ private String label;
+
+ /**
+ * Instantiates a new bar data set.
+ *
+ * @param data the values
+ */
+ public BarDataSet(final List<? extends Number> data) {
+ super(data);
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(final String label) {
+ this.label = label;
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/e78f91e2/client/console/src/main/java/org/apache/syncope/client/console/chartjs/BaseDataSet.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/chartjs/BaseDataSet.java b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/BaseDataSet.java
new file mode 100644
index 0000000..f4cbba8
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/BaseDataSet.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.chartjs;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * Provides the simplest kind of a dataset.
+ * Besides the list of data itself, it contains default values for fill - and stroke color.
+ */
+public abstract class BaseDataSet implements Serializable {
+
+ private static final long serialVersionUID = 1581171902504828797L;
+
+ /** The fill color. */
+ private String fillColor = "rgba(220,220,220,0.5)";
+
+ /** The stroke color. */
+ private String strokeColor = "rgba(220,220,220,1)";
+
+ /** The data. */
+ private final List<? extends Number> data;
+
+ /**
+ * Instantiates a new abstract base data set.
+ *
+ * @param data the data values
+ */
+ public BaseDataSet(final List<? extends Number> data) {
+ this.data = data;
+ }
+
+ /**
+ * Gets the fill color.
+ *
+ * @return the fill color
+ */
+ public String getFillColor() {
+ return fillColor;
+ }
+
+ /**
+ * Sets the fill color.
+ *
+ * @param fillColor the fill color
+ * @return the abstract base data set
+ */
+ public BaseDataSet setFillColor(final String fillColor) {
+ this.fillColor = fillColor;
+ return this;
+ }
+
+ /**
+ * Gets the stroke color.
+ *
+ * @return the stroke color
+ */
+ public String getStrokeColor() {
+ return strokeColor;
+ }
+
+ /**
+ * Sets the stroke color.
+ *
+ * @param strokeColor the stroke color
+ * @return the abstract base data set
+ */
+ public BaseDataSet setStrokeColor(final String strokeColor) {
+ this.strokeColor = strokeColor;
+ return this;
+ }
+
+ public List<? extends Number> getData() {
+ return data;
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/e78f91e2/client/console/src/main/java/org/apache/syncope/client/console/chartjs/Chart.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/chartjs/Chart.java b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/Chart.java
new file mode 100644
index 0000000..435b6dd
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/Chart.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.chartjs;
+
+import java.io.Serializable;
+
+/**
+ * Provides chart options and a pojo-json mapper to communicate with javascript.
+ *
+ * @param <O> the generic type of options
+ */
+public abstract class Chart<O extends ChartOptions> implements Serializable {
+
+ private static final long serialVersionUID = 4733939203616971674L;
+
+ /** The options. */
+ protected O options;
+
+ public O getOptions() {
+ return options;
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/e78f91e2/client/console/src/main/java/org/apache/syncope/client/console/chartjs/ChartData.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/chartjs/ChartData.java b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/ChartData.java
new file mode 100644
index 0000000..33510c9
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/ChartData.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.chartjs;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Provides labels and datasets.
+ *
+ * @param <T> the dataset type
+ */
+abstract class ChartData<T extends BaseDataSet> implements Serializable {
+
+ private static final long serialVersionUID = -5230056951310645070L;
+
+ /** The labels. */
+ private final List<String> labels = new ArrayList<>();
+
+ /** The datasets. */
+ private final List<T> datasets = new ArrayList<>();
+
+ public List<String> getLabels() {
+ return labels;
+ }
+
+ public List<T> getDatasets() {
+ return datasets;
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/e78f91e2/client/console/src/main/java/org/apache/syncope/client/console/chartjs/ChartJSBehavior.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/chartjs/ChartJSBehavior.java b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/ChartJSBehavior.java
new file mode 100644
index 0000000..5ca88cb
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/ChartJSBehavior.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.chartjs;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.markup.head.IHeaderResponse;
+import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
+
+/**
+ * Builds the bridge between wicket and chart.js' javascript.
+ */
+public class ChartJSBehavior extends AbstractDefaultAjaxBehavior {
+
+ private static final long serialVersionUID = 5935294904099227859L;
+
+ @Override
+ protected void respond(final AjaxRequestTarget target) {
+ }
+
+ @Override
+ public void renderHead(final Component component, final IHeaderResponse response) {
+ super.renderHead(component, response);
+
+ response.render(OnDomReadyHeaderItem.forScript(
+ "WicketCharts['" + component.getMarkupId() + "']=buildChart('" + component.getMarkupId() + "');"));
+
+ if (component.getParent() instanceof ChartJSPanel) {
+ response.render(OnDomReadyHeaderItem.forScript(((ChartJSPanel) component.getParent()).generateChart()));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/e78f91e2/client/console/src/main/java/org/apache/syncope/client/console/chartjs/ChartJSPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/chartjs/ChartJSPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/ChartJSPanel.java
new file mode 100644
index 0000000..a06c6c3
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/ChartJSPanel.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.chartjs;
+
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.model.IModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ChartJSPanel extends Panel {
+
+ private static final long serialVersionUID = -3844680585650585253L;
+
+ private static final Logger LOG = LoggerFactory.getLogger(ChartJSPanel.class);
+
+ private static final ObjectMapper MAPPER = new ObjectMapper().setSerializationInclusion(Include.NON_NULL);
+
+ private final IModel<? extends Chart<?>> model;
+
+ private final WebMarkupContainer container;
+
+ public ChartJSPanel(
+ final String id,
+ final IModel<? extends Chart<?>> model) {
+
+ super(id, model);
+
+ this.model = model;
+ this.container = new WebMarkupContainer("chart");
+ }
+
+ @Override
+ protected void onInitialize() {
+ super.onInitialize();
+ add(container);
+ container.setOutputMarkupId(true);
+ container.add(new ChartJSBehavior());
+ }
+
+ public Chart<?> getChart() {
+ return model.getObject();
+ }
+
+ public String generateChart() {
+ String dataString = null;
+ String optionString = null;
+ try {
+ Object data = (model.getObject() instanceof SimpleChart)
+ ? ((SimpleChart) model.getObject()).getData()
+ : ((DataSetChart) model.getObject()).getData();
+ dataString = MAPPER.writeValueAsString(data);
+ optionString = MAPPER.writeValueAsString(model.getObject().getOptions());
+ } catch (JsonProcessingException e) {
+ LOG.error("Unexpected error during JSON serialization", e);
+ }
+
+ return "var " + container.getMarkupId() + " = WicketCharts['" + container.getMarkupId() + "']."
+ + model.getObject().getClass().getSimpleName() + "(" + dataString + ", " + optionString + ");";
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/e78f91e2/client/console/src/main/java/org/apache/syncope/client/console/chartjs/ChartOptions.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/chartjs/ChartOptions.java b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/ChartOptions.java
new file mode 100644
index 0000000..942f683
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/ChartOptions.java
@@ -0,0 +1,641 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.chartjs;
+
+import com.fasterxml.jackson.annotation.JsonRawValue;
+
+import java.io.Serializable;
+
+/**
+ * Provides some basic options, that are available for all kinds of charts.
+ */
+public abstract class ChartOptions implements Serializable {
+
+ private static final long serialVersionUID = 2401861279216541412L;
+
+ /** The animation. */
+ private Boolean animation;
+
+ /** The animation steps. */
+ private Integer animationSteps;
+
+ /** The animation easing. */
+ private String animationEasing;
+
+ /** The on animation complete. */
+ private String onAnimationComplete;
+
+ @JsonRawValue
+ private String customTooltips;
+
+ private Boolean showScale;
+
+ /** The scale override. */
+ private Boolean scaleOverride;
+
+ // ** The next three are required if scaleOverride is true **
+ /** The scale steps. */
+ private Integer scaleSteps;
+
+ /** The scale step width. */
+ private Integer scaleStepWidth;
+
+ /** The scale start value. */
+ private Integer scaleStartValue;
+
+ /** The scale line color. */
+ private String scaleLineColor;
+
+ /** The scale line width. */
+ private Integer scaleLineWidth;
+
+ /** The scale show labels. */
+ private Boolean scaleShowLabels;
+
+ /** The scale label. */
+ private String scaleLabel;
+
+ /** The scale font family. */
+ private String scaleFontFamily;
+
+ /** The scale font size. */
+ private Integer scaleFontSize;
+
+ /** The scale font style. */
+ private String scaleFontStyle;
+
+ /** The scale font color. */
+ private String scaleFontColor;
+
+ private Boolean scaleIntegersOnly;
+
+ private Boolean scaleBeginAtZero;
+
+ private Boolean responsive;
+
+ private Boolean maintainAspectRatio;
+
+ private Boolean showTooltips;
+
+ private String[] tooltipEvents = new String[] { "mousemove", "touchstart", "touchmove" };
+
+ private String tooltipFillColor;
+
+ private String tooltipFontFamily;
+
+ private Integer tooltipFontSize;
+
+ private String tooltipFontStyle;
+
+ private String tooltipFontColor;
+
+ private String tooltipTitleFontFamily;
+
+ private Integer tooltipTitleFontSize;
+
+ private String tooltipTitleFontStyle;
+
+ private String tooltipTitleFontColor;
+
+ private Integer tooltipYPadding;
+
+ private Integer tooltipXPadding;
+
+ private Integer tooltipCaretSize;
+
+ private Integer tooltipCornerRadius;
+
+ private Integer tooltipXOffset;
+
+ private String tooltipTemplate;
+
+ private String multiTooltipTemplate;
+
+ @JsonRawValue
+ private String onAnimationProgress;
+
+ public String getCustomTooltips() {
+ return customTooltips;
+ }
+
+ public void setCustomTooltips(final String customTooltips) {
+ this.customTooltips = customTooltips;
+ }
+
+ /**
+ * Gets the animation.
+ *
+ * @return the animation
+ */
+ public Boolean getAnimation() {
+ return animation;
+ }
+
+ /**
+ * Sets the animation.
+ *
+ * @param animation decides whether to animate the chart (default is true)
+ */
+ public void setAnimation(final Boolean animation) {
+ this.animation = animation;
+ }
+
+ /**
+ * Gets the animation steps.
+ *
+ * @return the animation steps
+ */
+ public Integer getAnimationSteps() {
+ return animationSteps;
+ }
+
+ /**
+ * Sets the animation steps.
+ *
+ * @param animationSteps the number of animation steps (default is 60)
+ */
+ public void setAnimationSteps(final Integer animationSteps) {
+ this.animationSteps = animationSteps;
+ }
+
+ /**
+ * Gets the animation easing.
+ *
+ * @return the animation easing
+ */
+ public String getAnimationEasing() {
+ return animationEasing;
+ }
+
+ /**
+ * Sets the animation easing.
+ *
+ * @param animationEasing the animation easing effect (default is "easeOutQuart")
+ */
+ public void setAnimationEasing(final String animationEasing) {
+ this.animationEasing = animationEasing;
+ }
+
+ /**
+ * Gets the javascript function that fires on animation complete.
+ *
+ * @return the onAnimationComplete javascript function
+ */
+ public String getOnAnimationComplete() {
+ return onAnimationComplete;
+ }
+
+ /**
+ * Sets the onAnimationComplete javascript function.
+ *
+ * @param onAnimationComplete a function, that fires when the animation is complete
+ */
+ public void setOnAnimationComplete(final String onAnimationComplete) {
+ this.onAnimationComplete = onAnimationComplete;
+ }
+
+ /**
+ * Gets the scale override.
+ *
+ * @return the scale override
+ */
+ public Boolean getScaleOverride() {
+ return scaleOverride;
+ }
+
+ /**
+ * Sets the scale override.
+ *
+ * @param scaleOverride decides if you want to override with a hard coded scale
+ */
+ public void setScaleOverride(final Boolean scaleOverride) {
+ this.scaleOverride = scaleOverride;
+ }
+
+ /**
+ * Gets the scale steps.
+ *
+ * @return the scale steps
+ */
+ public Integer getScaleSteps() {
+ return scaleSteps;
+ }
+
+ /**
+ * Sets the scale steps.
+ *
+ * @param scaleSteps the number of steps in a hard coded scale (required if scaleOverride == true, default is null).
+ */
+ public void setScaleSteps(final Integer scaleSteps) {
+ this.scaleSteps = scaleSteps;
+ }
+
+ /**
+ * Gets the scale step width.
+ *
+ * @return the scale step width
+ */
+ public Integer getScaleStepWidth() {
+ return scaleStepWidth;
+ }
+
+ /**
+ * Sets the scale step width.
+ *
+ * @param scaleStepWidth the value jump in the hard coded scale (required if scaleOverride == true, default is
+ * null).
+ */
+ public void setScaleStepWidth(final Integer scaleStepWidth) {
+ this.scaleStepWidth = scaleStepWidth;
+ }
+
+ /**
+ * Gets the scale start value.
+ *
+ * @return the scale start value
+ */
+ public Integer getScaleStartValue() {
+ return scaleStartValue;
+ }
+
+ /**
+ * Sets the scale start value.
+ *
+ * @param scaleStartValue the scale starting value (required if scaleOverride == true, default is null).
+ */
+ public void setScaleStartValue(final Integer scaleStartValue) {
+ this.scaleStartValue = scaleStartValue;
+ }
+
+ /**
+ * Gets the scale line color.
+ *
+ * @return the scale line color
+ */
+ public String getScaleLineColor() {
+ return scaleLineColor;
+ }
+
+ /**
+ * Sets the scale line color.
+ *
+ * @param scaleLineColor
+ * color of the scale line
+ */
+ public void setScaleLineColor(final String scaleLineColor) {
+ this.scaleLineColor = scaleLineColor;
+ }
+
+ /**
+ * Gets the scale line width.
+ *
+ * @return the scale line width
+ */
+ public Integer getScaleLineWidth() {
+ return scaleLineWidth;
+ }
+
+ /**
+ * Sets the scale line width.
+ *
+ * @param scaleLineWidth the pixel width of the scale line
+ */
+ public void setScaleLineWidth(final Integer scaleLineWidth) {
+ this.scaleLineWidth = scaleLineWidth;
+ }
+
+ /**
+ * Gets the scale show labels.
+ *
+ * @return the scale show labels
+ */
+ public Boolean getScaleShowLabels() {
+ return scaleShowLabels;
+ }
+
+ /**
+ * Sets the scale show labels.
+ *
+ * @param scaleShowLabels decides whether to show labels on the scale
+ */
+ public void setScaleShowLabels(final Boolean scaleShowLabels) {
+ this.scaleShowLabels = scaleShowLabels;
+ }
+
+ /**
+ * Gets the scale label.
+ *
+ * @return the scale label
+ */
+ public String getScaleLabel() {
+ return scaleLabel;
+ }
+
+ /**
+ * Sets the scale label.
+ *
+ * @param scaleLabel an interpolated js string that can access value.
+ */
+ public void setScaleLabel(final String scaleLabel) {
+ this.scaleLabel = scaleLabel;
+ }
+
+ /**
+ * Gets the scale font family.
+ *
+ * @return the scale font family
+ */
+ public String getScaleFontFamily() {
+ return scaleFontFamily;
+ }
+
+ /**
+ * Sets the scale font family.
+ *
+ * @param scaleFontFamily scale label font declaration for the scale label (default is
+ * "'Arial'").
+ */
+ public void setScaleFontFamily(final String scaleFontFamily) {
+ this.scaleFontFamily = scaleFontFamily;
+ }
+
+ /**
+ * Gets the scale font size.
+ *
+ * @return the scale font size
+ */
+ public Integer getScaleFontSize() {
+ return scaleFontSize;
+ }
+
+ /**
+ * Sets the scale font size.
+ *
+ * @param scaleFontSize the scale label font size in pixels
+ */
+ public void setScaleFontSize(final Integer scaleFontSize) {
+ this.scaleFontSize = scaleFontSize;
+ }
+
+ /**
+ * Gets the scale font style.
+ *
+ * @return the scale font style
+ */
+ public String getScaleFontStyle() {
+ return scaleFontStyle;
+ }
+
+ /**
+ * Sets the scale font style.
+ *
+ * @param scaleFontStyle the scale label font weight style (default is "normal").
+ */
+ public void setScaleFontStyle(final String scaleFontStyle) {
+ this.scaleFontStyle = scaleFontStyle;
+ }
+
+ /**
+ * Gets the scale font color.
+ *
+ * @return the scale font color
+ */
+ public String getScaleFontColor() {
+ return scaleFontColor;
+ }
+
+ /**
+ * Sets the scale font color.
+ *
+ * @param scaleFontColor the scale label font color (default is "#666").
+ */
+ public void setScaleFontColor(final String scaleFontColor) {
+ this.scaleFontColor = scaleFontColor;
+ }
+
+ public Boolean getShowScale() {
+ return showScale;
+ }
+
+ public void setShowScale(final Boolean showScale) {
+ this.showScale = showScale;
+ }
+
+ public Boolean getScaleIntegersOnly() {
+ return scaleIntegersOnly;
+ }
+
+ public void setScaleIntegersOnly(final Boolean scaleIntegersOnly) {
+ this.scaleIntegersOnly = scaleIntegersOnly;
+ }
+
+ public Boolean getScaleBeginAtZero() {
+ return scaleBeginAtZero;
+ }
+
+ public void setScaleBeginAtZero(final Boolean scaleBeginAtZero) {
+ this.scaleBeginAtZero = scaleBeginAtZero;
+ }
+
+ public Boolean getResponsive() {
+ return responsive;
+ }
+
+ public void setResponsive(final Boolean responsive) {
+ this.responsive = responsive;
+ }
+
+ public Boolean getMaintainAspectRatio() {
+ return maintainAspectRatio;
+ }
+
+ public void setMaintainAspectRatio(final Boolean maintainAspectRatio) {
+ this.maintainAspectRatio = maintainAspectRatio;
+ }
+
+ public Boolean getShowTooltips() {
+ return showTooltips;
+ }
+
+ public void setShowTooltips(final Boolean showTooltips) {
+ this.showTooltips = showTooltips;
+ }
+
+ public String[] getTooltipEvents() {
+ return tooltipEvents;
+ }
+
+ public void setTooltipEvents(final String[] tooltipEvents) {
+ this.tooltipEvents = tooltipEvents;
+ }
+
+ public String getTooltipFillColor() {
+ return tooltipFillColor;
+ }
+
+ public void setTooltipFillColor(final String tooltipFillColor) {
+ this.tooltipFillColor = tooltipFillColor;
+ }
+
+ public String getTooltipFontFamily() {
+ return tooltipFontFamily;
+ }
+
+ public void setTooltipFontFamily(final String tooltipFontFamily) {
+ this.tooltipFontFamily = tooltipFontFamily;
+ }
+
+ public Integer getTooltipFontSize() {
+ return tooltipFontSize;
+ }
+
+ public void setTooltipFontSize(final Integer tooltipFontSize) {
+ this.tooltipFontSize = tooltipFontSize;
+ }
+
+ public String getTooltipFontStyle() {
+ return tooltipFontStyle;
+ }
+
+ public void setTooltipFontStyle(final String tooltipFontStyle) {
+ this.tooltipFontStyle = tooltipFontStyle;
+ }
+
+ public String getTooltipFontColor() {
+ return tooltipFontColor;
+ }
+
+ public void setTooltipFontColor(final String tooltipFontColor) {
+ this.tooltipFontColor = tooltipFontColor;
+ }
+
+ public String getTooltipTitleFontFamily() {
+ return tooltipTitleFontFamily;
+ }
+
+ public void setTooltipTitleFontFamily(final String tooltipTitleFontFamily) {
+ this.tooltipTitleFontFamily = tooltipTitleFontFamily;
+ }
+
+ public Integer getTooltipTitleFontSize() {
+ return tooltipTitleFontSize;
+ }
+
+ public void setTooltipTitleFontSize(final Integer tooltipTitleFontSize) {
+ this.tooltipTitleFontSize = tooltipTitleFontSize;
+ }
+
+ public String getTooltipTitleFontStyle() {
+ return tooltipTitleFontStyle;
+ }
+
+ public void setTooltipTitleFontStyle(final String tooltipTitleFontStyle) {
+ this.tooltipTitleFontStyle = tooltipTitleFontStyle;
+ }
+
+ public String getTooltipTitleFontColor() {
+ return tooltipTitleFontColor;
+ }
+
+ public void setTooltipTitleFontColor(final String tooltipTitleFontColor) {
+ this.tooltipTitleFontColor = tooltipTitleFontColor;
+ }
+
+ public Integer getTooltipYPadding() {
+ return tooltipYPadding;
+ }
+
+ public void setTooltipYPadding(final Integer tooltipYPadding) {
+ this.tooltipYPadding = tooltipYPadding;
+ }
+
+ public Integer getTooltipXPadding() {
+ return tooltipXPadding;
+ }
+
+ public void setTooltipXPadding(final Integer tooltipXPadding) {
+ this.tooltipXPadding = tooltipXPadding;
+ }
+
+ public Integer getTooltipCaretSize() {
+ return tooltipCaretSize;
+ }
+
+ public void setTooltipCaretSize(final Integer tooltipCaretSize) {
+ this.tooltipCaretSize = tooltipCaretSize;
+ }
+
+ public Integer getTooltipCornerRadius() {
+ return tooltipCornerRadius;
+ }
+
+ public void setTooltipCornerRadius(final Integer tooltipCornerRadius) {
+ this.tooltipCornerRadius = tooltipCornerRadius;
+ }
+
+ public Integer getTooltipXOffset() {
+ return tooltipXOffset;
+ }
+
+ public void setTooltipXOffset(final Integer tooltipXOffset) {
+ this.tooltipXOffset = tooltipXOffset;
+ }
+
+ public String getTooltipTemplate() {
+ return tooltipTemplate;
+ }
+
+ public void setTooltipTemplate(final String tooltipTemplate) {
+ this.tooltipTemplate = tooltipTemplate;
+ }
+
+ public String getMultiTooltipTemplate() {
+ return multiTooltipTemplate;
+ }
+
+ public void setMultiTooltipTemplate(final String multiTooltipTemplate) {
+ this.multiTooltipTemplate = multiTooltipTemplate;
+ }
+
+ public String getOnAnimationProgress() {
+ return onAnimationProgress;
+ }
+
+ public void setOnAnimationProgress(final String onAnimationProgress) {
+ this.onAnimationProgress = onAnimationProgress;
+ }
+
+ /**
+ * Tests whether this chart is responsive or not.
+ *
+ * @return true if its responsive, false otherwise.
+ */
+ public boolean isResponsive() {
+ return responsive;
+ }
+
+ /**
+ * Sets the responsive option for this chart.
+ *
+ * @param responsive the responsive option value.
+ */
+ public void setResponsive(final boolean responsive) {
+ this.responsive = responsive;
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/e78f91e2/client/console/src/main/java/org/apache/syncope/client/console/chartjs/DataSetChart.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/chartjs/DataSetChart.java b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/DataSetChart.java
new file mode 100644
index 0000000..cc4d896
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/DataSetChart.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.chartjs;
+
+/**
+ * Provides chart data and options.
+ *
+ * @param <D> the generic type of chart data
+ * @param <O> the generic type of chart options
+ * @param <S> the generic type of a chart data set
+ */
+abstract class DataSetChart<
+ D extends ChartData<S>, O extends ChartOptions, S extends BaseDataSet>
+ extends Chart<O> {
+
+ private static final long serialVersionUID = 999846601210465414L;
+
+ /** The data. */
+ protected D data;
+
+ public D getData() {
+ return data;
+ }
+
+ public void setData(final D data) {
+ this.data = data;
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/e78f91e2/client/console/src/main/java/org/apache/syncope/client/console/chartjs/Doughnut.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/chartjs/Doughnut.java b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/Doughnut.java
new file mode 100644
index 0000000..6121093
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/Doughnut.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.chartjs;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Provides a simple implementation of chart.js doughnut chart.
+ *
+ * @see <a href="http://www.chartjs.org/docs/#doughnutChart">chart.js docs</a>
+ */
+public class Doughnut extends SimpleChart<DoughnutChartData, DoughnutChartOptions> implements Serializable {
+
+ private static final long serialVersionUID = -6898362145345731457L;
+
+ @Override
+ public DoughnutChartOptions getOptions() {
+ if (options == null) {
+ options = new DoughnutChartOptions();
+ }
+ return options;
+ }
+
+ @Override
+ public List<DoughnutChartData> getData() {
+ if (data == null) {
+ data = new ArrayList<>();
+ }
+ return data;
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/e78f91e2/client/console/src/main/java/org/apache/syncope/client/console/chartjs/DoughnutChartData.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/chartjs/DoughnutChartData.java b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/DoughnutChartData.java
new file mode 100644
index 0000000..5403785
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/DoughnutChartData.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.chartjs;
+
+/**
+ * Provides chart data used by doughnut charts.
+ */
+public class DoughnutChartData extends SimpleColorValueChartData {
+
+ private static final long serialVersionUID = -5122104387810776812L;
+
+ private String label;
+
+ /**
+ * Instantiates a new doughnut chart data.
+ *
+ * @param value the value
+ * @param color the color
+ */
+ public DoughnutChartData(final Integer value, final String color) {
+ super(value, color);
+ }
+
+ public DoughnutChartData(final Number value, final String color, final String label) {
+ super(value, color);
+ this.label = label;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(final String label) {
+ this.label = label;
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/e78f91e2/client/console/src/main/java/org/apache/syncope/client/console/chartjs/DoughnutChartOptions.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/chartjs/DoughnutChartOptions.java b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/DoughnutChartOptions.java
new file mode 100644
index 0000000..b72dafb
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/DoughnutChartOptions.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.chartjs;
+
+/**
+ * Provides options, that are available for {@link Doughnut}.
+ */
+public class DoughnutChartOptions extends PieChartOptions {
+
+ private static final long serialVersionUID = -5356780831848556616L;
+
+ /** The percentage inner cutout. */
+ private Integer percentageInnerCutout;
+
+ /**
+ * Gets the percentage inner cutout.
+ *
+ * @return the percentage inner cutout
+ */
+ public Integer getPercentageInnerCutout() {
+ return percentageInnerCutout;
+ }
+
+ /**
+ * Sets the percentage inner cutout.
+ *
+ * @param percentageInnerCutout the percentage of the chart that we cut out of the middle (default is 50).
+ */
+ public void setPercentageInnerCutout(final Integer percentageInnerCutout) {
+ this.percentageInnerCutout = percentageInnerCutout;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/e78f91e2/client/console/src/main/java/org/apache/syncope/client/console/chartjs/DoughnutDataSet.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/chartjs/DoughnutDataSet.java b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/DoughnutDataSet.java
new file mode 100644
index 0000000..ab46485
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/DoughnutDataSet.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.chartjs;
+
+import java.util.List;
+
+/**
+ * Provides all information needed for {@link DoughnutChartData}.
+ */
+public class DoughnutDataSet extends BaseDataSet {
+
+ private static final long serialVersionUID = 3095383371272813559L;
+
+ /**
+ * Instantiates a new bar data set.
+ *
+ * @param data the values
+ */
+ public DoughnutDataSet(final List<? extends Number> data) {
+ super(data);
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/e78f91e2/client/console/src/main/java/org/apache/syncope/client/console/chartjs/Line.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/chartjs/Line.java b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/Line.java
new file mode 100644
index 0000000..9af958a
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/Line.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.chartjs;
+
+public class Line extends DataSetChart<LineChartData<LineDataSet>, LineChartOptions, LineDataSet> {
+
+ private static final long serialVersionUID = -2467327116468783154L;
+
+ @Override
+ public LineChartOptions getOptions() {
+ if (options == null) {
+ options = new LineChartOptions();
+ }
+ return options;
+ }
+
+ @Override
+ public LineChartData<LineDataSet> getData() {
+ if (data == null) {
+ data = new LineChartData<>();
+ }
+ return data;
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/e78f91e2/client/console/src/main/java/org/apache/syncope/client/console/chartjs/LineChartData.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/chartjs/LineChartData.java b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/LineChartData.java
new file mode 100644
index 0000000..f8617d2
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/LineChartData.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.chartjs;
+
+/**
+ * Provides chart data used by line charts.
+ *
+ * @param <T> the generic type of it's dataset
+ */
+public class LineChartData<T extends PointColorDataSet> extends ChartData<T> {
+
+ private static final long serialVersionUID = 9057475640743455047L;
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/e78f91e2/client/console/src/main/java/org/apache/syncope/client/console/chartjs/LineChartOptions.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/chartjs/LineChartOptions.java b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/LineChartOptions.java
new file mode 100644
index 0000000..1aa8246
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/LineChartOptions.java
@@ -0,0 +1,227 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.chartjs;
+
+/**
+ * Provides options for {@link Line}.
+ */
+public class LineChartOptions extends ChartOptions {
+
+ private static final long serialVersionUID = -5356780831848556616L;
+
+ private Boolean scaleShowHorizontalLines = true;
+
+ private Boolean scaleShowVerticalLines = true;
+
+ private Double bezierCurveTension = 0.4;
+
+ private Integer pointHitDetectionRadius = 20;
+
+ private String legendTemplate = "<ul class=\"<%=name.toLowerCase()%>-legend\">"
+ + "<% for (var i=0; i<datasets.length; i++){%><li>"
+ + "<span style=\"background-color:<%=datasets[i].strokeColor%>\"></span>"
+ + "<%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>";
+
+ /** The bezier curve. */
+ private Boolean bezierCurve;
+
+ /** The point dot. */
+ private Boolean pointDot;
+
+ /** The point dot radius. */
+ private Integer pointDotRadius;
+
+ /** The point dot stroke width. */
+ private Integer pointDotStrokeWidth;
+
+ /** The dataset stroke. */
+ private Boolean datasetStroke;
+
+ /** The dataset stroke width. */
+ private Integer datasetStrokeWidth;
+
+ /** The dataset fill. */
+ private Boolean datasetFill;
+
+ public Boolean getScaleShowHorizontalLines() {
+ return scaleShowHorizontalLines;
+ }
+
+ public void setScaleShowHorizontalLines(final Boolean scaleShowHorizontalLines) {
+ this.scaleShowHorizontalLines = scaleShowHorizontalLines;
+ }
+
+ public Boolean getScaleShowVerticalLines() {
+ return scaleShowVerticalLines;
+ }
+
+ public void setScaleShowVerticalLines(final Boolean scaleShowVerticalLines) {
+ this.scaleShowVerticalLines = scaleShowVerticalLines;
+ }
+
+ public Double getBezierCurveTension() {
+ return bezierCurveTension;
+ }
+
+ public void setBezierCurveTension(final Double bezierCurveTension) {
+ this.bezierCurveTension = bezierCurveTension;
+ }
+
+ public Integer getPointHitDetectionRadius() {
+ return pointHitDetectionRadius;
+ }
+
+ public void setPointHitDetectionRadius(final Integer pointHitDetectionRadius) {
+ this.pointHitDetectionRadius = pointHitDetectionRadius;
+ }
+
+ public String getLegendTemplate() {
+ return legendTemplate;
+ }
+
+ public void setLegendTemplate(final String legendTemplate) {
+ this.legendTemplate = legendTemplate;
+ }
+
+ /**
+ * Gets the bezier curve.
+ *
+ * @return the bezier curve
+ */
+ public Boolean getBezierCurve() {
+ return bezierCurve;
+ }
+
+ /**
+ * Sets the bezier curve.
+ *
+ * @param bezierCurve decides whether the line is curved between points (default is true).
+ */
+ public void setBezierCurve(final Boolean bezierCurve) {
+ this.bezierCurve = bezierCurve;
+ }
+
+ /**
+ * Gets the point dot.
+ *
+ * @return the point dot
+ */
+ public Boolean getPointDot() {
+ return pointDot;
+ }
+
+ /**
+ * Sets the point dot.
+ *
+ * @param pointDot decides whether to show a dot for each point (default is true).
+ */
+ public void setPointDot(final Boolean pointDot) {
+ this.pointDot = pointDot;
+ }
+
+ /**
+ * Gets the point dot radius.
+ *
+ * @return the point dot radius
+ */
+ public Integer getPointDotRadius() {
+ return pointDotRadius;
+ }
+
+ /**
+ * Sets the point dot radius.
+ *
+ * @param pointDotRadius the new point dot radius (default is 3).
+ */
+ public void setPointDotRadius(final Integer pointDotRadius) {
+ this.pointDotRadius = pointDotRadius;
+ }
+
+ /**
+ * Gets the point dot stroke width.
+ *
+ * @return the point dot stroke width
+ */
+ public Integer getPointDotStrokeWidth() {
+ return pointDotStrokeWidth;
+ }
+
+ /**
+ * Sets the point dot stroke width.
+ *
+ * @param pointDotStrokeWidth the new point dot stroke width (default is 1).
+ */
+ public void setPointDotStrokeWidth(final Integer pointDotStrokeWidth) {
+ this.pointDotStrokeWidth = pointDotStrokeWidth;
+ }
+
+ /**
+ * Gets the dataset stroke.
+ *
+ * @return the dataset stroke
+ */
+ public Boolean getDatasetStroke() {
+ return datasetStroke;
+ }
+
+ /**
+ * Sets the dataset stroke.
+ *
+ * @param datasetStroke decides whether to show a stroke for datasets (default is true)
+ */
+ public void setDatasetStroke(final Boolean datasetStroke) {
+ this.datasetStroke = datasetStroke;
+ }
+
+ /**
+ * Gets the dataset stroke width.
+ *
+ * @return the dataset stroke width
+ */
+ public Integer getDatasetStrokeWidth() {
+ return datasetStrokeWidth;
+ }
+
+ /**
+ * Sets the dataset stroke width.
+ *
+ * @param datasetStrokeWidth the new dataset stroke width (default is 2).
+ */
+ public void setDatasetStrokeWidth(final Integer datasetStrokeWidth) {
+ this.datasetStrokeWidth = datasetStrokeWidth;
+ }
+
+ /**
+ * Gets the dataset fill.
+ *
+ * @return the dataset fill
+ */
+ public Boolean getDatasetFill() {
+ return datasetFill;
+ }
+
+ /**
+ * Sets the dataset fill.
+ *
+ * @param datasetFill whether to fill the dataset with a color (default is true)
+ */
+ public void setDatasetFill(final Boolean datasetFill) {
+ this.datasetFill = datasetFill;
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/e78f91e2/client/console/src/main/java/org/apache/syncope/client/console/chartjs/LineDataSet.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/chartjs/LineDataSet.java b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/LineDataSet.java
new file mode 100644
index 0000000..610dccc
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/LineDataSet.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.chartjs;
+
+import java.util.List;
+
+/**
+ * Provides all information needed for {@link LineChartData}.
+ */
+public class LineDataSet extends PointColorDataSet {
+
+ private static final long serialVersionUID = -3154092519924576329L;
+
+ private String label;
+
+ public LineDataSet(final List<? extends Number> data) {
+ super(data);
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(final String label) {
+ this.label = label;
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/e78f91e2/client/console/src/main/java/org/apache/syncope/client/console/chartjs/PieChartOptions.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/chartjs/PieChartOptions.java b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/PieChartOptions.java
new file mode 100644
index 0000000..9177d8b
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/PieChartOptions.java
@@ -0,0 +1,145 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.chartjs;
+
+/**
+ * Provides options, that are available for {@link Pie}.
+ */
+public class PieChartOptions extends ChartOptions {
+
+ private static final long serialVersionUID = -5356780831848556616L;
+
+ /** The segment show stroke. */
+ private Boolean segmentShowStroke;
+
+ /** The segment stroke color. */
+ private String segmentStrokeColor;
+
+ /** The segment stroke width. */
+ private Integer segmentStrokeWidth;
+
+ /** The animate rotate. */
+ private Boolean animateRotate;
+
+ /** The animate scale. */
+ private Boolean animateScale;
+
+ private String legendTemplate = "<ul class=\"<%=name.toLowerCase()%>-legend\">"
+ + "<% for (var i=0; i<segments.length; i++){%><li>"
+ + "<span style=\"background-color:<%=segments[i].fillColor%>\">"
+ + "<%if(segments[i].label){%><%=segments[i].label%><%}%></span></li><%}%></ul>";
+
+ public String getLegendTemplate() {
+ return legendTemplate;
+ }
+
+ public void setLegendTemplate(final String legendTemplate) {
+ this.legendTemplate = legendTemplate;
+ }
+
+ /**
+ * Gets the segment show stroke.
+ *
+ * @return the segment show stroke
+ */
+ public Boolean getSegmentShowStroke() {
+ return segmentShowStroke;
+ }
+
+ /**
+ * Sets the segment show stroke.
+ *
+ * @param segmentShowStroke decides whether we should show a stroke on each segment (default is true)
+ */
+ public void setSegmentShowStroke(final Boolean segmentShowStroke) {
+ this.segmentShowStroke = segmentShowStroke;
+ }
+
+ /**
+ * Gets the segment stroke color.
+ *
+ * @return the segment stroke color
+ */
+ public String getSegmentStrokeColor() {
+ return segmentStrokeColor;
+ }
+
+ /**
+ * Sets the segment stroke color.
+ *
+ * @param segmentStrokeColor the new segment stroke color (default is "#fff").
+ */
+ public void setSegmentStrokeColor(final String segmentStrokeColor) {
+ this.segmentStrokeColor = segmentStrokeColor;
+ }
+
+ /**
+ * Gets the segment stroke width.
+ *
+ * @return the segment stroke width
+ */
+ public Integer getSegmentStrokeWidth() {
+ return segmentStrokeWidth;
+ }
+
+ /**
+ * Sets the segment stroke width.
+ *
+ * @param segmentStrokeWidth the new segment stroke width (default is 2).
+ */
+ public void setSegmentStrokeWidth(final Integer segmentStrokeWidth) {
+ this.segmentStrokeWidth = segmentStrokeWidth;
+ }
+
+ /**
+ * Gets the animate rotate.
+ *
+ * @return the animate rotate
+ */
+ public Boolean getAnimateRotate() {
+ return animateRotate;
+ }
+
+ /**
+ * Sets the animate rotate.
+ *
+ * @param animateRotate decides whether we animate the rotation of the pie (default is true).
+ */
+ public void setAnimateRotate(final Boolean animateRotate) {
+ this.animateRotate = animateRotate;
+ }
+
+ /**
+ * Gets the animate scale.
+ *
+ * @return the animate scale
+ */
+ public Boolean getAnimateScale() {
+ return animateScale;
+ }
+
+ /**
+ * Sets the animate scale.
+ *
+ * @param animateScale decides whether we animate scaling the Pie from the center (default is false).
+ */
+ public void setAnimateScale(final Boolean animateScale) {
+ this.animateScale = animateScale;
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/e78f91e2/client/console/src/main/java/org/apache/syncope/client/console/chartjs/PointColorDataSet.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/chartjs/PointColorDataSet.java b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/PointColorDataSet.java
new file mode 100644
index 0000000..7d96b21
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/PointColorDataSet.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.chartjs;
+
+import java.util.List;
+
+/**
+ * Provides some additional point color and point stroke color information.
+ */
+public abstract class PointColorDataSet extends BaseDataSet {
+
+ private static final long serialVersionUID = 1581171902504828797L;
+
+ /** The point color. */
+ private String pointColor = "rgba(220,220,220,1)";
+
+ /** The point stroke color. */
+ private String pointStrokeColor = "#fff";
+
+ /**
+ * Instantiates a new abstract point color data set.
+ *
+ * @param data the values
+ */
+ public PointColorDataSet(final List<? extends Number> data) {
+ super(data);
+ }
+
+ /**
+ * Gets the point color.
+ *
+ * @return the point color
+ */
+ public String getPointColor() {
+ return pointColor;
+ }
+
+ /**
+ * Sets the point color.
+ *
+ * @param pointColor the point color
+ */
+ public void setPointColor(final String pointColor) {
+ this.pointColor = pointColor;
+ }
+
+ /**
+ * Gets the point stroke color.
+ *
+ * @return the point stroke color
+ */
+ public String getPointStrokeColor() {
+ return pointStrokeColor;
+ }
+
+ /**
+ * Sets the point stroke color.
+ *
+ * @param pointStrokeColor the point stroke color
+ */
+ public void setPointStrokeColor(final String pointStrokeColor) {
+ this.pointStrokeColor = pointStrokeColor;
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/e78f91e2/client/console/src/main/java/org/apache/syncope/client/console/chartjs/SimpleChart.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/chartjs/SimpleChart.java b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/SimpleChart.java
new file mode 100644
index 0000000..9af3f2d
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/SimpleChart.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.chartjs;
+
+import java.util.List;
+
+/**
+ * Provides chart data and options.
+ *
+ * @param <D> the generic type of chart data
+ * @param <O> the generic type of chart options
+ */
+public abstract class SimpleChart<D extends SimpleColorValueChartData, O extends ChartOptions> extends Chart<O> {
+
+ private static final long serialVersionUID = 4176838766615656412L;
+
+ /** The data. */
+ protected List<D> data;
+
+ public List<D> getData() {
+ return data;
+ }
+
+ public void setData(final List<D> data) {
+ this.data = data;
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/e78f91e2/client/console/src/main/java/org/apache/syncope/client/console/chartjs/SimpleColorValueChartData.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/chartjs/SimpleColorValueChartData.java b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/SimpleColorValueChartData.java
new file mode 100644
index 0000000..d10744c
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/chartjs/SimpleColorValueChartData.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.chartjs;
+
+import java.io.Serializable;
+
+public class SimpleColorValueChartData implements Serializable {
+
+ private static final long serialVersionUID = 3049771486746243572L;
+
+ public SimpleColorValueChartData(final Number value, final String color) {
+ this.value = value;
+ this.color = color;
+ }
+
+ private Number value;
+
+ private String color;
+
+ public String getColor() {
+ return color;
+ }
+
+ public void setColor(final String color) {
+ this.color = color;
+ }
+
+ public Number getValue() {
+ return value;
+ }
+
+ public void setValue(final Integer value) {
+ this.value = value;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/e78f91e2/client/console/src/main/java/org/apache/syncope/client/console/widgets/AnyByRealmWidget.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/widgets/AnyByRealmWidget.java b/client/console/src/main/java/org/apache/syncope/client/console/widgets/AnyByRealmWidget.java
index ce549f4..541252d 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/widgets/AnyByRealmWidget.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/widgets/AnyByRealmWidget.java
@@ -18,9 +18,6 @@
*/
package org.apache.syncope.client.console.widgets;
-import com.pingunaut.wicket.chartjs.chart.impl.Bar;
-import com.pingunaut.wicket.chartjs.core.panel.BarChartPanel;
-import com.pingunaut.wicket.chartjs.data.sets.BarDataSet;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
@@ -28,6 +25,9 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
+import org.apache.syncope.client.console.chartjs.Bar;
+import org.apache.syncope.client.console.chartjs.BarDataSet;
+import org.apache.syncope.client.console.chartjs.ChartJSPanel;
import org.apache.wicket.model.Model;
public class AnyByRealmWidget extends BaseWidget {
@@ -48,7 +48,7 @@ public class AnyByRealmWidget extends BaseWidget {
private Map<String, Integer> any2ByRealm;
- private final BarChartPanel chart;
+ private final ChartJSPanel chart;
public AnyByRealmWidget(
final String id,
@@ -68,7 +68,7 @@ public class AnyByRealmWidget extends BaseWidget {
this.any2ByRealm = any2ByRealm;
setOutputMarkupId(true);
- chart = new BarChartPanel(
+ chart = new ChartJSPanel(
"chart",
Model.of(build(usersByRealm, groupsByRealm, anyType1, any1ByRealm, anyType2, any2ByRealm)));
add(chart);
@@ -101,8 +101,19 @@ public class AnyByRealmWidget extends BaseWidget {
List<String> realms = new ArrayList<>(realmSet);
Collections.sort(realms);
+ Bar bar = new Bar();
+ bar.getOptions().setScaleBeginAtZero(true);
+ bar.getOptions().setBarShowStroke(true);
+ bar.getOptions().setBarStrokeWidth(2);
+ bar.getOptions().setBarValueSpacing(5);
+ bar.getOptions().setBarDatasetSpacing(1);
+ bar.getOptions().setResponsive(true);
+ bar.getOptions().setMaintainAspectRatio(true);
+ bar.getOptions().setMultiTooltipTemplate("<%= datasetLabel %> - <%= value %>");
+
for (int i = 0; i < realms.size() && i < MAX_REALMS; i++) {
- labels.add(StringUtils.prependIfMissing(StringUtils.substringAfterLast(realms.get(i), "/"), "/"));
+ bar.getData().getLabels().add(
+ StringUtils.prependIfMissing(StringUtils.substringAfterLast(realms.get(i), "/"), "/"));
userValues.add(usersByRealm.get(realms.get(i)));
groupValues.add(groupsByRealm.get(realms.get(i)));
@@ -114,42 +125,26 @@ public class AnyByRealmWidget extends BaseWidget {
}
}
- Bar bar = new Bar();
- bar.getOptions().setScaleBeginAtZero(true);
- bar.getOptions().setScaleShowGridLines(true);
- bar.getOptions().setScaleGridLineWidth(1);
- bar.getOptions().setBarShowStroke(true);
- bar.getOptions().setBarStrokeWidth(2);
- bar.getOptions().setBarValueSpacing(5);
- bar.getOptions().setBarDatasetSpacing(1);
- bar.getOptions().setResponsive(true);
- bar.getOptions().setMaintainAspectRatio(true);
- bar.getOptions().setMultiTooltipTemplate("<%= datasetLabel %> - <%= value %>");
-
- bar.getData().setLabels(labels);
-
- List<BarDataSet> datasets = new ArrayList<>();
- LabeledBarDataSet userDataSet = new LabeledBarDataSet(userValues);
+ BarDataSet userDataSet = new BarDataSet(userValues);
userDataSet.setFillColor("orange");
userDataSet.setLabel(getString("users"));
- datasets.add(userDataSet);
- LabeledBarDataSet groupDataSet = new LabeledBarDataSet(groupValues);
+ bar.getData().getDatasets().add(userDataSet);
+ BarDataSet groupDataSet = new BarDataSet(groupValues);
groupDataSet.setFillColor("red");
groupDataSet.setLabel(getString("groups"));
- datasets.add(groupDataSet);
+ bar.getData().getDatasets().add(groupDataSet);
if (anyType1 != null) {
- LabeledBarDataSet any1DataSet = new LabeledBarDataSet(any1Values);
+ BarDataSet any1DataSet = new BarDataSet(any1Values);
any1DataSet.setFillColor("green");
any1DataSet.setLabel(anyType1);
- datasets.add(any1DataSet);
+ bar.getData().getDatasets().add(any1DataSet);
}
if (anyType2 != null) {
- LabeledBarDataSet any2DataSet = new LabeledBarDataSet(any2Values);
+ BarDataSet any2DataSet = new BarDataSet(any2Values);
any2DataSet.setFillColor("aqua");
any2DataSet.setLabel(anyType2);
- datasets.add(any2DataSet);
+ bar.getData().getDatasets().add(any2DataSet);
}
- bar.getData().setDatasets(datasets);
return bar;
}