- * Is the legend displayed - */ - public Legend setDisplay(final Boolean display) - { - this.display = display; - return this; - } - - /** - * @see #setPosition(Legend.Position) - */ - public Position getPosition() - { - return this.position; - } - - /** - * Default {@code 'top'} - *
- * Position of the legend. Options are 'top' or 'bottom' - */ - public Legend setPosition(final Legend.Position position) - { - this.position = position; - return this; - } - - /** - * @see #setAlign(String) - */ - public String getAlign() - { - return this.align; - } - - /** - * Default 'center'. - *
- * Alignment of the legend - */ - public Legend setAlign(final String align) - { - this.align = align; - return this; - } - - /** - * @see #setMaxHeight(Integer) - */ - public Integer getMaxHeight() - { - return this.maxHeight; - } - - /** - * Maximum height of the legend, in pixels - */ - public Legend setMaxHeight(final Integer maxHeight) - { - this.maxHeight = maxHeight; - return this; - } - - /** - * @see #setMaxWidth(Integer) - */ - public Integer getMaxWidth() - { - return this.maxWidth; - } - - /** - * Maximum width of the legend, in pixels - */ - public Legend setMaxWidth(final Integer maxWidth) - { - this.maxWidth = maxWidth; - return this; - } - - /** - * @see #setFullSize(Boolean) - */ - public Boolean getFullSize() - { - return this.fullSize; - } - - /** - * Default {@code true} - *
- * Marks that this box should take the full width of the canvas (pushing down other boxes)
- */
- public Legend setFullSize(final Boolean fullSize)
- {
- this.fullSize = fullSize;
- return this;
- }
-
- /**
- * @see #setOnClick(JavaScriptFunction)
- */
- public JavaScriptFunction getOnClick()
- {
- return this.onClick;
- }
-
- /**
- * A callback that is called when a click is registered on top of a label item
- */
- public Legend setOnClick(final JavaScriptFunction onClick)
- {
- this.onClick = onClick;
- return this;
- }
-
- /**
- * @see #setOnHover(JavaScriptFunction)
- */
- public JavaScriptFunction getOnHover()
- {
- return this.onHover;
- }
-
- /**
- * A callback that is called when a 'mousemove' event is registered on top of a label item
- */
- public Legend setOnHover(final JavaScriptFunction onHover)
- {
- this.onHover = onHover;
- return this;
- }
-
- /**
- * @see #setOnLeave(JavaScriptFunction)
- */
- public JavaScriptFunction getOnLeave()
- {
- return this.onLeave;
- }
-
- /**
- * A callback that is called when a 'mousemove' event is registered outside of a previously hovered label item
- */
- public Legend setOnLeave(final JavaScriptFunction onLeave)
- {
- this.onLeave = onLeave;
- return this;
- }
-
- /**
- * @see #setReverse(Boolean)
- */
- public Boolean getReverse()
- {
- return this.reverse;
- }
-
- /**
- * Default false
- *
- * Legend will show datasets in reverse order - */ - public Legend setReverse(final Boolean reverse) - { - this.reverse = reverse; - return this; - } - - /** - * @see #setLabels(LegendLabels) - */ - public LegendLabels getLabels() - { - return this.labels; - } - - /** - * Default {@code -} - *
- * See the Legend Label Configuration section below.
- */
- public Legend setLabels(final LegendLabels labels)
- {
- this.labels = labels;
- return this;
- }
-
- /**
- * @see #setRtl(Boolean)
- */
- public Boolean getRtl()
- {
- return this.rtl;
- }
-
- /**
- * true for rendering the legends from right to left
- */
- public Legend setRtl(final Boolean rtl)
- {
- this.rtl = rtl;
- return this;
- }
-
- /**
- * @see #setTextDirection(String)
- */
- public String getTextDirection()
- {
- return this.textDirection;
- }
-
- /**
- * This will force the text direction 'rtl' or 'ltr' on the canvas for rendering the legend, regardless of the css
- * specified on the canvas
- */
- public Legend setTextDirection(final String textDirection)
- {
- this.textDirection = textDirection;
- return this;
- }
-
- /**
- * @see #setTitle(LegendTitle)
- */
- public LegendTitle getTitle()
- {
- return this.title;
- }
-
- /**
- * @see LegendTitle
- */
- public Legend setTitle(final LegendTitle title)
- {
- this.title = title;
- return this;
- }
-
- public enum Position
- {
- TOP,
- BOTTOM,
- LEFT,
- RIGHT;
-
- @Override
- @JsonValue
- public String toString()
- {
- return this.name().toLowerCase(Locale.ENGLISH);
- }
- }
-}
diff --git a/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/LegendLabels.java b/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/LegendLabels.java
deleted file mode 100644
index 1eb028c0..00000000
--- a/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/LegendLabels.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Copyright © 2023 XDEV Software (https://xdev.software)
- *
- * Licensed 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 software.xdev.chartjs.model.options;
-
-import software.xdev.chartjs.model.enums.FontStyle;
-import software.xdev.chartjs.model.javascript.JavaScriptFunction;
-
-
-public class LegendLabels
-{
- protected Integer boxWidth;
- protected Integer fontSize;
- protected FontStyle fontStyle;
- protected Object fontColor;
- protected String fontFamily;
- protected Integer padding;
- protected JavaScriptFunction generateLabels;
- protected Boolean usePointStyle;
-
- /**
- * @see #setBoxWidth(Integer)
- */
- public Integer getBoxWidth()
- {
- return this.boxWidth;
- }
-
- /**
- *
- * Width of coloured box - *
- * - *- * Default {@code 40} - *
- */ - public LegendLabels setBoxWidth(final Integer boxWidth) - { - this.boxWidth = boxWidth; - return this; - } - - /** - * @see #setFontSize(Integer) - */ - public Integer getFontSize() - { - return this.fontSize; - } - - /** - *- * Font size inherited from global configuration - *
- * - *- * Default {@code 12} - *
- */ - public LegendLabels setFontSize(final Integer fontSize) - { - this.fontSize = fontSize; - return this; - } - - /** - * @see #setFontStyle(FontStyle) - */ - public FontStyle getFontStyle() - { - return this.fontStyle; - } - - /** - *- * Font style inherited from global configuration - *
- * - *- * Default {@code "normal"} - *
- */ - public LegendLabels setFontStyle(final FontStyle fontStyle) - { - this.fontStyle = fontStyle; - return this; - } - - /** - * @see #setFontColor(Object) - */ - public Object getFontColor() - { - return this.fontColor; - } - - /** - *- * Font color inherited from global configuration - *
- * - *- * Default {@code "#666"} - *
- */ - public LegendLabels setFontColor(final Object fontColor) - { - this.fontColor = fontColor; - return this; - } - - /** - * @see #setFontFamily(String) - */ - public String getFontFamily() - { - return this.fontFamily; - } - - /** - *- * Font family inherited from global configuration - *
- * - *- * Default {@code "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif"} - *
- */ - public LegendLabels setFontFamily(final String fontFamily) - { - this.fontFamily = fontFamily; - return this; - } - - /** - * @see #setPadding(Integer) - */ - public Integer getPadding() - { - return this.padding; - } - - /** - *- * Padding between rows of colored boxes - *
- * - *- * Default {@code 10} - *
- */ - public LegendLabels setPadding(final Integer padding) - { - this.padding = padding; - return this; - } - - /** - * @see #setGenerateLabels(JavaScriptFunction) - */ - public JavaScriptFunction getGenerateLabels() - { - return this.generateLabels; - } - - /** - *- * Generates legend items for each thing in the legend. Default implementation returns the text + styling for the - * color box. See Legend Item for details. - *
- * - *- * Default {@code function(chart) { }} - *
- */ - public LegendLabels setGenerateLabels(final JavaScriptFunction generateLabels) - { - this.generateLabels = generateLabels; - return this; - } - - /** - * @see #setUsePointStyle(Boolean) - */ - public Boolean getUsePointStyle() - { - return this.usePointStyle; - } - - /** - *- * Label style will match corresponding point style (size is based on fontSize, boxWidth is not used in this case). - *
- * - *- * Default {@code false} - *
- */ - public LegendLabels setUsePointStyle(final Boolean usePointStyle) - { - this.usePointStyle = usePointStyle; - return this; - } -} diff --git a/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/LegendOptions.java b/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/LegendOptions.java new file mode 100644 index 00000000..f7e50339 --- /dev/null +++ b/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/LegendOptions.java @@ -0,0 +1,437 @@ +/* + * Copyright © 2023 XDEV Software (https://xdev.software) + * + * Licensed 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 software.xdev.chartjs.model.options; + +import software.xdev.chartjs.model.javascript.JavaScriptFunction; + + +/** + * @see ChartJS Source + */ +public class LegendOptions +{ + protected Boolean display; + protected Object position; + protected String align; + protected Number maxHeight; + protected Number maxWidth; + protected Boolean fullSize; + protected Boolean reverse; + protected JavaScriptFunction onClick; + protected JavaScriptFunction onHover; + protected JavaScriptFunction onLeave; + protected Labels labels; + protected Boolean rtl; + protected String textDirection; + protected Title title; + + public Boolean getDisplay() + { + return this.display; + } + + public LegendOptions setDisplay(final Boolean display) + { + this.display = display; + return this; + } + + public Object getPosition() + { + return this.position; + } + + public LegendOptions setPosition(final Object position) + { + this.position = position; + return this; + } + + public String getAlign() + { + return this.align; + } + + public LegendOptions setAlign(final String align) + { + this.align = align; + return this; + } + + public Number getMaxHeight() + { + return this.maxHeight; + } + + public LegendOptions setMaxHeight(final Number maxHeight) + { + this.maxHeight = maxHeight; + return this; + } + + public Number getMaxWidth() + { + return this.maxWidth; + } + + public LegendOptions setMaxWidth(final Number maxWidth) + { + this.maxWidth = maxWidth; + return this; + } + + public Boolean getFullSize() + { + return this.fullSize; + } + + public LegendOptions setFullSize(final Boolean fullSize) + { + this.fullSize = fullSize; + return this; + } + + public Boolean getReverse() + { + return this.reverse; + } + + public LegendOptions setReverse(final Boolean reverse) + { + this.reverse = reverse; + return this; + } + + public JavaScriptFunction getOnClick() + { + return this.onClick; + } + + public LegendOptions setOnClick(final JavaScriptFunction onClick) + { + this.onClick = onClick; + return this; + } + + public JavaScriptFunction getOnHover() + { + return this.onHover; + } + + public LegendOptions setOnHover(final JavaScriptFunction onHover) + { + this.onHover = onHover; + return this; + } + + public JavaScriptFunction getOnLeave() + { + return this.onLeave; + } + + public LegendOptions setOnLeave(final JavaScriptFunction onLeave) + { + this.onLeave = onLeave; + return this; + } + + public Labels getLabels() + { + return this.labels; + } + + public LegendOptions setLabels(final Labels labels) + { + this.labels = labels; + return this; + } + + public Boolean getRtl() + { + return this.rtl; + } + + public LegendOptions setRtl(final Boolean rtl) + { + this.rtl = rtl; + return this; + } + + public String getTextDirection() + { + return this.textDirection; + } + + public LegendOptions setTextDirection(final String textDirection) + { + this.textDirection = textDirection; + return this; + } + + public Title getTitle() + { + return this.title; + } + + public LegendOptions setTitle(final Title title) + { + this.title = title; + return this; + } + + /** + * @see ChartJS Source + */ + public static class Labels + { + protected Number boxWidth; + protected Number boxHeight; + protected Object color; + protected Font font; + protected Number padding; + protected Number pointStyleWidth; + protected JavaScriptFunction generateLabels; + protected JavaScriptFunction filter; + protected JavaScriptFunction sort; + protected String textAlign; + protected Boolean usePointStyle; + protected Boolean useBorderRadius; + protected Number borderRadius; + + public Number getBoxWidth() + { + return this.boxWidth; + } + + public Labels setBoxWidth(final Number boxWidth) + { + this.boxWidth = boxWidth; + return this; + } + + public Number getBoxHeight() + { + return this.boxHeight; + } + + public Labels setBoxHeight(final Number boxHeight) + { + this.boxHeight = boxHeight; + return this; + } + + public Object getColor() + { + return this.color; + } + + public Labels setColor(final Object color) + { + this.color = color; + return this; + } + + public Font getFont() + { + return this.font; + } + + public Labels setFont(final Font font) + { + this.font = font; + return this; + } + + public Number getPadding() + { + return this.padding; + } + + public Labels setPadding(final Number padding) + { + this.padding = padding; + return this; + } + + public Number getPointStyleWidth() + { + return this.pointStyleWidth; + } + + public Labels setPointStyleWidth(final Number pointStyleWidth) + { + this.pointStyleWidth = pointStyleWidth; + return this; + } + + public JavaScriptFunction getGenerateLabels() + { + return this.generateLabels; + } + + public Labels setGenerateLabels(final JavaScriptFunction generateLabels) + { + this.generateLabels = generateLabels; + return this; + } + + public JavaScriptFunction getFilter() + { + return this.filter; + } + + public Labels setFilter(final JavaScriptFunction filter) + { + this.filter = filter; + return this; + } + + public JavaScriptFunction getSort() + { + return this.sort; + } + + public Labels setSort(final JavaScriptFunction sort) + { + this.sort = sort; + return this; + } + + public String getTextAlign() + { + return this.textAlign; + } + + public Labels setTextAlign(final String textAlign) + { + this.textAlign = textAlign; + return this; + } + + public Boolean getUsePointStyle() + { + return this.usePointStyle; + } + + public Labels setUsePointStyle(final Boolean usePointStyle) + { + this.usePointStyle = usePointStyle; + return this; + } + + public Boolean getUseBorderRadius() + { + return this.useBorderRadius; + } + + public Labels setUseBorderRadius(final Boolean useBorderRadius) + { + this.useBorderRadius = useBorderRadius; + return this; + } + + public Number getBorderRadius() + { + return this.borderRadius; + } + + public Labels setBorderRadius(final Number borderRadius) + { + this.borderRadius = borderRadius; + return this; + } + } + + + /** + * @see ChartJS Source + */ + public static class Title + { + protected Boolean display; + protected Object color; + protected Font font; + protected String position; + protected Object padding; + protected String text; + + public Boolean getDisplay() + { + return this.display; + } + + public Title setDisplay(final Boolean display) + { + this.display = display; + return this; + } + + public Object getColor() + { + return this.color; + } + + public Title setColor(final Object color) + { + this.color = color; + return this; + } + + public Font getFont() + { + return this.font; + } + + public Title setFont(final Font font) + { + this.font = font; + return this; + } + + public String getPosition() + { + return this.position; + } + + public Title setPosition(final String position) + { + this.position = position; + return this; + } + + public Object getPadding() + { + return this.padding; + } + + public Title setPadding(final Object padding) + { + this.padding = padding; + return this; + } + + public String getText() + { + return this.text; + } + + public Title setText(final String text) + { + this.text = text; + return this; + } + } +} diff --git a/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/LegendTitle.java b/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/LegendTitle.java deleted file mode 100644 index 92e9dd86..00000000 --- a/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/LegendTitle.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright © 2023 XDEV Software (https://xdev.software) - * - * Licensed 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 software.xdev.chartjs.model.options; - -import software.xdev.chartjs.model.options.layout.Padding; - - -public class LegendTitle -{ - protected Object color; - protected Boolean display; - protected Font font; - protected Padding padding; - protected String text; - - /** - * @see #setColor(Object) - */ - public Object getColor() - { - return this.color; - } - - /** - * DefaultChart.defaults.color
- *
- * Color of text
- */
- public LegendTitle setColor(final Object color)
- {
- this.color = color;
- return this;
- }
-
- /**
- * @see #setDisplay(Boolean)
- */
- public Boolean getDisplay()
- {
- return this.display;
- }
-
- /**
- * Default false
- *
- * Is the legend title displayed?
- */
- public LegendTitle setDisplay(final Boolean display)
- {
- this.display = display;
- return this;
- }
-
- /**
- * @see #setFont(Font)
- */
- public Font getFont()
- {
- return this.font;
- }
-
- /**
- * Default Chart.defaults.font
- */
- public LegendTitle setFont(final Font font)
- {
- this.font = font;
- return this;
- }
-
- /**
- * @see #setPadding(Padding)
- */
- public Padding getPadding()
- {
- return this.padding;
- }
-
- /**
- * Padding around the title
- */
- public LegendTitle setPadding(final Padding padding)
- {
- this.padding = padding;
- return this;
- }
-
- /**
- * @see #setText(String)
- */
- public String getText()
- {
- return this.text;
- }
-
- /**
- * The string title
- */
- public LegendTitle setText(final String text)
- {
- this.text = text;
- return this;
- }
-}
diff --git a/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/Plugins.java b/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/Plugins.java
index f3c6608c..021421bc 100644
--- a/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/Plugins.java
+++ b/chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/Plugins.java
@@ -22,7 +22,7 @@ public class Plugins
{
protected Title title;
protected Title subtitle;
- protected Legend legend;
+ protected LegendOptions legend;
protected Tooltip tooltip;
protected Zoom zoom;
@@ -63,9 +63,9 @@ public Plugins setSubtitle(final Title subtitle)
}
/**
- * @see #setLegend(Legend)
+ * @see #setLegend(LegendOptions)
*/
- public Legend getLegend()
+ public LegendOptions getLegend()
{
return this.legend;
}
@@ -74,7 +74,7 @@ public Legend getLegend()
* The legend configuration is passed into the options.legend namespace. The global options for the chart legend is
* defined in Chart.defaults.global.legend.
*/
- public Plugins setLegend(final Legend legend)
+ public Plugins setLegend(final LegendOptions legend)
{
this.legend = legend;
return this;
diff --git a/pom.xml b/pom.xml
index 7eea1a53..c9720bcc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@