Skip to content

Commit 2a4179c

Browse files
committed
PointStyle can also contain non-string constants
Fixes #280
1 parent f9ecc81 commit 2a4179c

File tree

6 files changed

+27
-31
lines changed

6 files changed

+27
-31
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 2.4.0
2+
* PointStyle can also contain non-string constants #280
3+
14
## 2.3.1
25
* Synced ``LineOptions/DataSet`` ``stepped`` and ``tension`` with ChartJS source #262
36
* Updated dependencies

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import java.util.List;
1919

2020
import software.xdev.chartjs.model.enums.BorderSkipped;
21-
import software.xdev.chartjs.model.enums.PointStyle;
2221
import software.xdev.chartjs.model.objects.OptionalArray;
2322

2423

@@ -35,7 +34,7 @@ public class BarDataset extends BackgroundBorderHoverDataset<BarDataset, Number>
3534
protected Object barThickness;
3635
protected Number maxBarThickness;
3736
protected Number minBarLength;
38-
protected PointStyle pointStyle;
37+
protected Object pointStyle;
3938
protected Boolean grouped;
4039

4140
protected final List<BorderSkipped> borderSkipped = new OptionalArray<>();
@@ -123,12 +122,12 @@ public BarDataset setMinBarLength(final Number minBarLength)
123122
return this;
124123
}
125124

126-
public PointStyle getPointStyle()
125+
public Object getPointStyle()
127126
{
128127
return this.pointStyle;
129128
}
130129

131-
public BarDataset setPointStyle(final PointStyle pointStyle)
130+
public BarDataset setPointStyle(final Object pointStyle)
132131
{
133132
this.pointStyle = pointStyle;
134133
return this;

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import java.util.List;
1919

2020
import software.xdev.chartjs.model.datapoint.BubbleDataPoint;
21-
import software.xdev.chartjs.model.enums.PointStyle;
2221
import software.xdev.chartjs.model.objects.OptionalArray;
2322

2423

@@ -32,7 +31,7 @@ public class BubbleDataset extends BackgroundBorderHoverDataset<BubbleDataset, B
3231

3332
protected final List<Integer> hoverRadius = new OptionalArray<>();
3433

35-
protected PointStyle pointStyle;
34+
protected Object pointStyle;
3635

3736
@Override
3837
protected String defaultType()
@@ -95,12 +94,12 @@ public List<Integer> getHoverRadius()
9594
return this.hoverRadius;
9695
}
9796

98-
public PointStyle getPointStyle()
97+
public Object getPointStyle()
9998
{
10099
return this.pointStyle;
101100
}
102101

103-
public BubbleDataset setPointStyle(final PointStyle pointStyle)
102+
public BubbleDataset setPointStyle(final Object pointStyle)
104103
{
105104
this.pointStyle = pointStyle;
106105
return this;

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import software.xdev.chartjs.model.enums.BorderCapStyle;
2222
import software.xdev.chartjs.model.enums.BorderJoinStyle;
23-
import software.xdev.chartjs.model.enums.PointStyle;
2423
import software.xdev.chartjs.model.objects.OptionalArray;
2524
import software.xdev.chartjs.model.options.elements.Fill;
2625

@@ -63,7 +62,7 @@ public abstract class PointDataset<T extends Dataset<T, O>, O> extends Dataset<T
6362

6463
private final List<Integer> pointHoverBorderWidth = new OptionalArray<>();
6564

66-
private final List<PointStyle> pointStyle = new OptionalArray<>();
65+
private final List<Object> pointStyle = new OptionalArray<>();
6766

6867
/**
6968
* @see #setFill(Fill)
@@ -528,15 +527,15 @@ public T setPointHoverBorderWidth(final List<Integer> pointHoverBorderWidth)
528527
/**
529528
* @see #setPointStyle(List)
530529
*/
531-
public List<PointStyle> getPointStyle()
530+
public List<Object> getPointStyle()
532531
{
533532
return this.pointStyle;
534533
}
535534

536535
/**
537536
* @see #setPointStyle(List)
538537
*/
539-
public T addPointStyle(final PointStyle pointStyle)
538+
public T addPointStyle(final Object pointStyle)
540539
{
541540
this.pointStyle.add(pointStyle);
542541
return this.self();
@@ -547,7 +546,7 @@ public T addPointStyle(final PointStyle pointStyle)
547546
* and
548547
* 'dash'. If the option is an image, that image is drawn on the canvas using drawImage.
549548
*/
550-
public T setPointStyle(final List<PointStyle> pointStyle)
549+
public T setPointStyle(final List<Object> pointStyle)
551550
{
552551
this.pointStyle.clear();
553552
if(pointStyle != null)

chartjs-java-model/src/main/java/software/xdev/chartjs/model/enums/PointStyle.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,23 @@
2020
import software.xdev.chartjs.model.EnumNameToCamelCase;
2121

2222

23+
/**
24+
* @apiNote Only contains the (string) constants. Other valid values are e.g. <code>false</code>, an image element or a
25+
* canvas element.
26+
* @see <a href="https://github.com/chartjs/Chart.js/blob/v4.4.4/src/types/index.d.ts#L1968">ChartJS Source</a>
27+
*/
2328
public enum PointStyle
2429
{
2530
CIRCLE,
26-
TRIANGLE,
31+
CROSS,
32+
CROSS_ROT,
33+
DASH,
34+
LINE,
2735
RECT,
2836
RECT_ROUNDED,
2937
RECT_ROT,
30-
CROSS,
31-
CROSS_ROT,
3238
STAR,
33-
LINE,
34-
DASH;
39+
TRIANGLE;
3540

3641
@JsonValue
3742
@Override

chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/elements/Point.java

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
*/
1616
package software.xdev.chartjs.model.options.elements;
1717

18-
import software.xdev.chartjs.model.enums.PointStyle;
19-
20-
2118
/**
2219
* <p>
2320
* Point elements are used to represent the points in a line chart or a bubble chart.
@@ -26,12 +23,13 @@
2623
* When set, these options apply to all objects of that type unless specifically overridden by the configuration
2724
* attached to a dataset.
2825
* </p>
26+
* @see <a href="https://github.com/chartjs/Chart.js/blob/v4.4.4/src/types/index.d.ts#L1983">ChartJS Source</a>
2927
*/
3028
public class Point
3129
{
3230
protected Integer radius;
3331

34-
protected PointStyle pointStyle;
32+
protected Object pointStyle;
3533

3634
protected Object backgroundColor;
3735

@@ -68,24 +66,17 @@ public Point setRadius(final Integer radius)
6866
return this;
6967
}
7068

71-
/**
72-
* @see #setPointStyle(PointStyle)
73-
*/
74-
public PointStyle getPointStyle()
69+
public Object getPointStyle()
7570
{
7671
return this.pointStyle;
7772
}
7873

7974
/**
80-
* <p>
81-
* Default point style
82-
* </p>
83-
*
8475
* <p>
8576
* Default {@code 'circle'}
8677
* </p>
8778
*/
88-
public Point setPointStyle(final PointStyle pointStyle)
79+
public Point setPointStyle(final Object pointStyle)
8980
{
9081
this.pointStyle = pointStyle;
9182
return this;

0 commit comments

Comments
 (0)