diff --git a/data/src/main/java/nl/crashdata/chartjs/data/ChartJsDataset.java b/data/src/main/java/nl/crashdata/chartjs/data/ChartJsDataset.java index a876d39..2e0086e 100644 --- a/data/src/main/java/nl/crashdata/chartjs/data/ChartJsDataset.java +++ b/data/src/main/java/nl/crashdata/chartjs/data/ChartJsDataset.java @@ -43,9 +43,24 @@ public interface ChartJsDataset extends Serializable @JsonProperty("hoverBorderWidth") List getHoverBorderWidth(); + @JsonProperty("pointBackgroundColor") + List getPointBackgroundColor(); + + @JsonProperty("pointBorderColor") + List getPointBorderColor(); + + @JsonProperty("pointBorderWidth") + List getPointBorderWidth(); + + @JsonProperty("pointRadius") + List getPointRadius(); + @JsonProperty("fill") ChartJsFill getFill(); @JsonProperty("stack") String getStack(); + + @JsonProperty("order") + Integer getOrder(); } diff --git a/data/src/main/java/nl/crashdata/chartjs/data/simple/SimpleChartJsDataset.java b/data/src/main/java/nl/crashdata/chartjs/data/simple/SimpleChartJsDataset.java index 8c08055..7515a5e 100644 --- a/data/src/main/java/nl/crashdata/chartjs/data/simple/SimpleChartJsDataset.java +++ b/data/src/main/java/nl/crashdata/chartjs/data/simple/SimpleChartJsDataset.java @@ -25,10 +25,20 @@ public class SimpleChartJsDataset implements ChartJsData private List hoverBorderWidth; + private List pointBackgroundColor; + + private List pointBorderColor; + + private List pointBorderWidth; + + private List pointRadius; + private ChartJsFill fill; private String stack; + private Integer order; + private List data; @Override @@ -108,13 +118,57 @@ public void setHoverBorderWidth(List hoverBorderWidth) this.hoverBorderWidth = hoverBorderWidth; } + @Override + public List getPointBackgroundColor() + { + return pointBackgroundColor; + } + + public void setPointBackgroundColor(List pointBackgroundColor) + { + this.pointBackgroundColor = pointBackgroundColor; + } + + @Override + public List getPointBorderColor() + { + return pointBorderColor; + } + + public void setPointBorderColor(List pointBorderColor) + { + this.pointBorderColor = pointBorderColor; + } + + @Override + public List getPointBorderWidth() + { + return pointBorderWidth; + } + + public void setPointBorderWidth(List pointBorderWidth) + { + this.pointBorderWidth = pointBorderWidth; + } + + @Override + public List getPointRadius() + { + return pointRadius; + } + + public void setPointRadius(List pointRadius) + { + this.pointRadius = pointRadius; + } + @Override public ChartJsFill getFill() { return fill; } - public void setFill(ChartJsFill fill) + public void setFill(ChartJsFill fill) { this.fill = fill; } @@ -128,6 +182,15 @@ public void setStack(String stack) { this.stack = stack; } + @Override + public Integer getOrder() { + return order; + } + + public void setOrder(Integer order) { + this.order = order; + } + @Override public List getData() { diff --git a/data/src/main/java/nl/crashdata/chartjs/data/simple/builder/SimpleChartJsDatasetBuilder.java b/data/src/main/java/nl/crashdata/chartjs/data/simple/builder/SimpleChartJsDatasetBuilder.java index 7acd1f1..5539b6a 100644 --- a/data/src/main/java/nl/crashdata/chartjs/data/simple/builder/SimpleChartJsDatasetBuilder.java +++ b/data/src/main/java/nl/crashdata/chartjs/data/simple/builder/SimpleChartJsDatasetBuilder.java @@ -27,12 +27,22 @@ public class SimpleChartJsDatasetBuilder private List hoverBorderWidth; + private List pointBackgroundColor; + + private List pointBorderColor; + + private List pointBorderWidth; + + private List pointRadius; + private String label; private ChartJsFill fill = ChartJsFill.DISABLED; private String stack; + private Integer order; + private List data = new ArrayList<>(); public SimpleChartJsDatasetBuilder @@ -74,6 +84,31 @@ public SimpleChartJsDatasetBuilder withHoverBorderWidths(List hoverB return this; } + public SimpleChartJsDatasetBuilder + withPointBackgroundColors(List pointBackgroundColors) + { + this.pointBackgroundColor = pointBackgroundColors; + return this; + } + + public SimpleChartJsDatasetBuilder withPointBorderColors(List pointBorderColors) + { + this.pointBorderColor = pointBorderColors; + return this; + } + + public SimpleChartJsDatasetBuilder withPointBorderWidths(List pointBorderWidths) + { + this.pointBorderWidth = pointBorderWidths; + return this; + } + + public SimpleChartJsDatasetBuilder withPointRadiuses(List pointRadiuses) + { + this.pointRadius = pointRadiuses; + return this; + } + public SimpleChartJsDatasetBuilder withBackgroundColor(ChartJsRGBAColor backgroundColor) { this.backgroundColor = Collections.singletonList(backgroundColor); @@ -111,6 +146,30 @@ public SimpleChartJsDatasetBuilder withHoverBorderWidth(Integer hoverBorderWi return this; } + public SimpleChartJsDatasetBuilder withPointBackgroundColor(ChartJsRGBAColor pointBackgroundColor) + { + this.pointBackgroundColor = Collections.singletonList(pointBackgroundColor); + return this; + } + + public SimpleChartJsDatasetBuilder withPointBorderColor(ChartJsRGBAColor pointBorderColor) + { + this.pointBorderColor = Collections.singletonList(pointBorderColor); + return this; + } + + public SimpleChartJsDatasetBuilder withPointBorderWidth(Integer pointBorderWidth) + { + this.pointBorderWidth = Collections.singletonList(pointBorderWidth); + return this; + } + + public SimpleChartJsDatasetBuilder withPointRadius(Integer pointRadius) + { + this.pointRadius = Collections.singletonList(pointRadius); + return this; + } + public SimpleChartJsDatasetBuilder withLabel(String label) { this.label = label; @@ -123,6 +182,12 @@ public SimpleChartJsDatasetBuilder withStack(String stack) return this; } + public SimpleChartJsDatasetBuilder withOrder(Integer order) + { + this.order = order; + return this; + } + public SimpleChartJsDatasetBuilder withDataPoints(List dataPoints) { this.data = dataPoints; @@ -163,9 +228,14 @@ public SimpleChartJsDataset build() throws IllegalStateException ret.setHoverBackgroundColor(hoverBackgroundColor); ret.setHoverBorderColor(hoverBorderColor); ret.setHoverBorderWidth(hoverBorderWidth); + ret.setPointBackgroundColor(pointBackgroundColor); + ret.setPointBorderColor(pointBorderColor); + ret.setPointBorderWidth(pointBorderWidth); + ret.setPointRadius(pointRadius); ret.setData(data); ret.setFill(fill); ret.setStack(stack); + ret.setOrder(order); return ret; } } diff --git a/wicket/src/main/java/nl/crashdata/chartjs/wicket/components/panels/SimpleGraphPanel.java b/wicket/src/main/java/nl/crashdata/chartjs/wicket/components/panels/SimpleGraphPanel.java index 55174c7..ed88896 100644 --- a/wicket/src/main/java/nl/crashdata/chartjs/wicket/components/panels/SimpleGraphPanel.java +++ b/wicket/src/main/java/nl/crashdata/chartjs/wicket/components/panels/SimpleGraphPanel.java @@ -18,8 +18,8 @@ import nl.crashdata.chartjs.data.ChartJsConfig; import nl.crashdata.chartjs.data.ChartJsDataset; import nl.crashdata.chartjs.serialization.ChartJsObjectMapperFactory; -import nl.crashdata.chartjs.wicket.resources.ChartJSCSSResourceReference; -import nl.crashdata.chartjs.wicket.resources.ChartJSJavaScriptResourceReference; +import nl.crashdata.chartjs.wicket.resources.ChartJsCssResourceReference; +import nl.crashdata.chartjs.wicket.resources.ChartJsJavaScriptResourceReference; public class SimpleGraphPanel> extends GenericPanel { @@ -50,8 +50,8 @@ public void renderHead(IHeaderResponse response) super.renderHead(response); response - .render(JavaScriptHeaderItem.forReference(ChartJSJavaScriptResourceReference.get())); - response.render(CssHeaderItem.forReference(ChartJSCSSResourceReference.get())); + .render(JavaScriptHeaderItem.forReference(ChartJsJavaScriptResourceReference.get())); + response.render(CssHeaderItem.forReference(ChartJsCssResourceReference.get())); response.render(OnDomReadyHeaderItem .forScript("moment.locale('" + Session.get().getLocale().toLanguageTag() + "');\n" + "Chart.platform.disableCSSInjection = true;\n" + "document.getElementById(\"" diff --git a/wicket/src/main/java/nl/crashdata/chartjs/wicket/resources/ChartJSCSSResourceReference.java b/wicket/src/main/java/nl/crashdata/chartjs/wicket/resources/ChartJSCSSResourceReference.java deleted file mode 100644 index 3cc8a99..0000000 --- a/wicket/src/main/java/nl/crashdata/chartjs/wicket/resources/ChartJSCSSResourceReference.java +++ /dev/null @@ -1,33 +0,0 @@ -package nl.crashdata.chartjs.wicket.resources; - -import java.util.Collections; -import java.util.List; - -import org.apache.wicket.markup.head.HeaderItem; -import org.apache.wicket.markup.head.JavaScriptHeaderItem; -import org.apache.wicket.request.resource.CssResourceReference; - -public class ChartJSCSSResourceReference extends CssResourceReference -{ - private static final long serialVersionUID = 1L; - - private static ChartJSCSSResourceReference INSTANCE = - new ChartJSCSSResourceReference(ChartJSCSSResourceReference.class, "Chart.css"); - - private ChartJSCSSResourceReference(Class< ? > scope, String name) - { - super(scope, name); - } - - public static ChartJSCSSResourceReference get() - { - return INSTANCE; - } - - @Override - public List getDependencies() - { - return Collections.singletonList( - JavaScriptHeaderItem.forReference(ChartJSJavaScriptResourceReference.get())); - } -} diff --git a/wicket/src/main/java/nl/crashdata/chartjs/wicket/resources/ChartJsCssResourceReference.java b/wicket/src/main/java/nl/crashdata/chartjs/wicket/resources/ChartJsCssResourceReference.java index ff2ad10..d98235f 100644 --- a/wicket/src/main/java/nl/crashdata/chartjs/wicket/resources/ChartJsCssResourceReference.java +++ b/wicket/src/main/java/nl/crashdata/chartjs/wicket/resources/ChartJsCssResourceReference.java @@ -1,6 +1,6 @@ package nl.crashdata.chartjs.wicket.resources; -import static nl.crashdata.chartjs.wicket.resources.ChartJSJavaScriptResourceReference.*; +import static nl.crashdata.chartjs.wicket.resources.ChartJsJavaScriptResourceReference.*; import java.util.Collections; import java.util.List; diff --git a/wicket/src/main/java/nl/crashdata/chartjs/wicket/resources/ChartJSJavaScriptResourceReference.java b/wicket/src/main/java/nl/crashdata/chartjs/wicket/resources/ChartJsJavaScriptResourceReference.java similarity index 70% rename from wicket/src/main/java/nl/crashdata/chartjs/wicket/resources/ChartJSJavaScriptResourceReference.java rename to wicket/src/main/java/nl/crashdata/chartjs/wicket/resources/ChartJsJavaScriptResourceReference.java index 19c065a..9d2c1cf 100644 --- a/wicket/src/main/java/nl/crashdata/chartjs/wicket/resources/ChartJSJavaScriptResourceReference.java +++ b/wicket/src/main/java/nl/crashdata/chartjs/wicket/resources/ChartJsJavaScriptResourceReference.java @@ -7,7 +7,7 @@ import org.apache.wicket.markup.head.JavaScriptHeaderItem; import org.apache.wicket.request.resource.JavaScriptResourceReference; -public final class ChartJSJavaScriptResourceReference extends JavaScriptResourceReference +public final class ChartJsJavaScriptResourceReference extends JavaScriptResourceReference { private static final long serialVersionUID = 1L; @@ -15,15 +15,15 @@ public final class ChartJSJavaScriptResourceReference extends JavaScriptResource private static final String CHARTJS_JS_NAME = CHARTJS_VERSIONED_NAME + ".js"; - private static final ChartJSJavaScriptResourceReference INSTANCE = - new ChartJSJavaScriptResourceReference(); + private static final ChartJsJavaScriptResourceReference INSTANCE = + new ChartJsJavaScriptResourceReference(); - private ChartJSJavaScriptResourceReference() + private ChartJsJavaScriptResourceReference() { - super(ChartJSJavaScriptResourceReference.class, CHARTJS_JS_NAME); + super(ChartJsJavaScriptResourceReference.class, CHARTJS_JS_NAME); } - public static ChartJSJavaScriptResourceReference get() + public static ChartJsJavaScriptResourceReference get() { return INSTANCE; }