Skip to content

Commit 6fc5886

Browse files
committed
Sync datasets with ChartJS source
Fixes #244
1 parent f1ecf1e commit 6fc5886

File tree

21 files changed

+393
-170
lines changed

21 files changed

+393
-170
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 2.3.0
2+
* Update available datasets fields from ChartJS source code #244
3+
14
## 2.2.0
25
* Improve color handling #238
36
* Change ``Color`` to ``RGBAColor`` as it only handles RGBA

chartjs-java-model-demo/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
<parent>
88
<groupId>software.xdev</groupId>
99
<artifactId>chartjs-java-model-root</artifactId>
10-
<version>2.2.1-SNAPSHOT</version>
10+
<version>2.3.0-SNAPSHOT</version>
1111
</parent>
1212

1313
<artifactId>chartjs-java-model-demo</artifactId>
14-
<version>2.2.1-SNAPSHOT</version>
14+
<version>2.3.0-SNAPSHOT</version>
1515
<packaging>jar</packaging>
1616

1717
<organization>

chartjs-java-model/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>software.xdev</groupId>
88
<artifactId>chartjs-java-model</artifactId>
9-
<version>2.2.1-SNAPSHOT</version>
9+
<version>2.3.0-SNAPSHOT</version>
1010
<packaging>jar</packaging>
1111

1212
<name>chartjs-java-model</name>

chartjs-java-model/src/main/java/software/xdev/chartjs/model/dataset/BackgroundBorderHoverDataset.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,10 @@ public abstract class BackgroundBorderHoverDataset<T extends BackgroundBorderHov
2525
extends Dataset<T, O>
2626
{
2727
protected final List<Object> backgroundColor = new OptionalArray<>();
28-
2928
protected final List<Object> borderColor = new OptionalArray<>();
30-
3129
protected final List<Integer> borderWidth = new OptionalArray<>();
32-
3330
protected final List<Object> hoverBackgroundColor = new OptionalArray<>();
34-
3531
protected final List<Object> hoverBorderColor = new OptionalArray<>();
36-
3732
protected final List<Integer> hoverBorderWidth = new OptionalArray<>();
3833

3934
public List<Object> getBackgroundColor()

chartjs-java-model/src/main/java/software/xdev/chartjs/model/dataset/BarDataset.java

Lines changed: 92 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,34 @@
1818
import java.util.List;
1919

2020
import software.xdev.chartjs.model.enums.BorderSkipped;
21+
import software.xdev.chartjs.model.enums.PointStyle;
2122
import software.xdev.chartjs.model.objects.OptionalArray;
2223

2324

25+
/**
26+
* @see <a href="https://github.com/chartjs/Chart.js/blob/v4.4.4/src/types/index.d.ts#L114">ChartJS Source</a>
27+
*/
2428
public class BarDataset extends BackgroundBorderHoverDataset<BarDataset, Number>
2529
implements NumberDataset<BarDataset>
2630
{
27-
private String label;
28-
private String xAxisID;
29-
private String yAxisID;
30-
private final List<BorderSkipped> borderSkipped = new OptionalArray<>();
31-
private String stack;
31+
protected String xAxisID;
32+
protected String yAxisID;
33+
protected Number barPercentage;
34+
protected Number categoryPercentage;
35+
protected Object barThickness;
36+
protected Number maxBarThickness;
37+
protected Number minBarLength;
38+
protected PointStyle pointStyle;
39+
protected Boolean grouped;
40+
41+
protected final List<BorderSkipped> borderSkipped = new OptionalArray<>();
3242

3343
@Override
3444
protected String defaultType()
3545
{
3646
return "bar";
3747
}
3848

39-
public String getLabel()
40-
{
41-
return this.label;
42-
}
43-
44-
public BarDataset setLabel(final String label)
45-
{
46-
this.label = label;
47-
return this;
48-
}
49-
5049
public String getXAxisID()
5150
{
5251
return this.xAxisID;
@@ -69,6 +68,83 @@ public BarDataset setYAxisID(final String yAxisID)
6968
return this;
7069
}
7170

71+
public Number getBarPercentage()
72+
{
73+
return this.barPercentage;
74+
}
75+
76+
public BarDataset setBarPercentage(final Number barPercentage)
77+
{
78+
this.barPercentage = barPercentage;
79+
return this;
80+
}
81+
82+
public Number getCategoryPercentage()
83+
{
84+
return this.categoryPercentage;
85+
}
86+
87+
public BarDataset setCategoryPercentage(final Number categoryPercentage)
88+
{
89+
this.categoryPercentage = categoryPercentage;
90+
return this;
91+
}
92+
93+
public Object getBarThickness()
94+
{
95+
return this.barThickness;
96+
}
97+
98+
public BarDataset setBarThickness(final Object barThickness)
99+
{
100+
this.barThickness = barThickness;
101+
return this;
102+
}
103+
104+
public Number getMaxBarThickness()
105+
{
106+
return this.maxBarThickness;
107+
}
108+
109+
public BarDataset setMaxBarThickness(final Number maxBarThickness)
110+
{
111+
this.maxBarThickness = maxBarThickness;
112+
return this;
113+
}
114+
115+
public Number getMinBarLength()
116+
{
117+
return this.minBarLength;
118+
}
119+
120+
public BarDataset setMinBarLength(final Number minBarLength)
121+
{
122+
this.minBarLength = minBarLength;
123+
return this;
124+
}
125+
126+
public PointStyle getPointStyle()
127+
{
128+
return this.pointStyle;
129+
}
130+
131+
public BarDataset setPointStyle(final PointStyle pointStyle)
132+
{
133+
this.pointStyle = pointStyle;
134+
return this;
135+
}
136+
137+
public Boolean getGrouped()
138+
{
139+
return this.grouped;
140+
}
141+
142+
public BarDataset setGrouped(final Boolean grouped)
143+
{
144+
this.grouped = grouped;
145+
return this;
146+
}
147+
72148
public List<BorderSkipped> getBorderSkipped()
73149
{
74150
return this.borderSkipped;
@@ -89,15 +165,4 @@ public BarDataset setBorderSkipped(final List<BorderSkipped> borderSkipped)
89165
}
90166
return this;
91167
}
92-
93-
public String getStack()
94-
{
95-
return this.stack;
96-
}
97-
98-
public BarDataset setStack(final String stack)
99-
{
100-
this.stack = stack;
101-
return this;
102-
}
103168
}

chartjs-java-model/src/main/java/software/xdev/chartjs/model/dataset/BubbleDataset.java

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,45 @@
2323

2424

2525
/**
26-
* <p>
27-
* A collection of data points for a bubble chart.
28-
* </p>
29-
*
30-
* <p>
31-
* For best results, ensure that each property is set with a list of equal length.
32-
* </p>
26+
* @see <a href="https://github.com/chartjs/Chart.js/blob/v4.4.4/src/types/index.d.ts#L165">ChartJS Source</a>
3327
*/
34-
public class BubbleDataset extends RoundDataset<BubbleDataset, BubbleDataPoint>
28+
public class BubbleDataset extends BackgroundBorderHoverDataset<BubbleDataset, BubbleDataPoint>
3529
{
36-
private final List<Integer> hoverRadius = new OptionalArray<>();
30+
protected String xAxisID;
31+
protected String yAxisID;
32+
33+
protected final List<Integer> hoverRadius = new OptionalArray<>();
3734

38-
private PointStyle pointStyle;
35+
protected PointStyle pointStyle;
3936

4037
@Override
4138
protected String defaultType()
4239
{
4340
return "bubble";
4441
}
4542

43+
public String getXAxisID()
44+
{
45+
return this.xAxisID;
46+
}
47+
48+
public BubbleDataset setXAxisID(final String xAxisID)
49+
{
50+
this.xAxisID = xAxisID;
51+
return this;
52+
}
53+
54+
public String getYAxisID()
55+
{
56+
return this.yAxisID;
57+
}
58+
59+
public BubbleDataset setYAxisID(final String yAxisID)
60+
{
61+
this.yAxisID = yAxisID;
62+
return this;
63+
}
64+
4665
/**
4766
* <p>
4867
* Additional radius to add to data radius on hover.

chartjs-java-model/src/main/java/software/xdev/chartjs/model/dataset/Dataset.java

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,24 @@
2222
import java.util.List;
2323
import java.util.stream.Collectors;
2424

25+
import software.xdev.chartjs.model.enums.IndexAxis;
2526

27+
28+
/**
29+
* @see <a href="https://github.com/chartjs/Chart.js/blob/v4.4.4/src/types/index.d.ts#L66">ChartJS Source</a>
30+
*/
2631
public abstract class Dataset<T extends Dataset<T, O>, O>
2732
{
2833
protected String type;
2934
protected final List<Object> data = new ArrayList<>();
3035

36+
protected IndexAxis indexAxis;
37+
protected Object clip;
38+
protected String label;
39+
protected Number order;
40+
protected String stack;
41+
protected Boolean hidden;
42+
3143
protected abstract String defaultType();
3244

3345
/**
@@ -145,6 +157,72 @@ public T addData(final O data)
145157
return this.addDataUnchecked(data);
146158
}
147159

160+
public IndexAxis getIndexAxis()
161+
{
162+
return this.indexAxis;
163+
}
164+
165+
public T setIndexAxis(final IndexAxis indexAxis)
166+
{
167+
this.indexAxis = indexAxis;
168+
return this.self();
169+
}
170+
171+
public Object getClip()
172+
{
173+
return this.clip;
174+
}
175+
176+
public T setClip(final Object clip)
177+
{
178+
this.clip = clip;
179+
return this.self();
180+
}
181+
182+
public String getLabel()
183+
{
184+
return this.label;
185+
}
186+
187+
public T setLabel(final String label)
188+
{
189+
this.label = label;
190+
return this.self();
191+
}
192+
193+
public Number getOrder()
194+
{
195+
return this.order;
196+
}
197+
198+
public T setOrder(final Number order)
199+
{
200+
this.order = order;
201+
return this.self();
202+
}
203+
204+
public String getStack()
205+
{
206+
return this.stack;
207+
}
208+
209+
public T setStack(final String stack)
210+
{
211+
this.stack = stack;
212+
return this.self();
213+
}
214+
215+
public Boolean getHidden()
216+
{
217+
return this.hidden;
218+
}
219+
220+
public T setHidden(final Boolean hidden)
221+
{
222+
this.hidden = hidden;
223+
return this.self();
224+
}
225+
148226
@SuppressWarnings("unchecked")
149227
public T self()
150228
{

chartjs-java-model/src/main/java/software/xdev/chartjs/model/dataset/DoughnutDataset.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
package software.xdev.chartjs.model.dataset;
1717

18-
public class DoughnutDataset extends RoundDataset<DoughnutDataset, Number>
18+
public class DoughnutDataset extends DoughnutDatasetBase<DoughnutDataset>
1919
implements NumberDataset<DoughnutDataset>
2020
{
2121
@Override

0 commit comments

Comments
 (0)