Skip to content

Commit 39778ab

Browse files
committed
Merge branch 'dougnut-pie-options' into develop
2 parents 729909d + dae35d5 commit 39778ab

File tree

11 files changed

+165
-298
lines changed

11 files changed

+165
-298
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.6.0
2+
* Synced ``Doughnut/PieOptions`` from ChartJS source code #293
3+
* Updated dependencies
4+
15
## 2.5.0
26
* Synced ``Legend`` from ChartJS source code #285
37

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.5.1-SNAPSHOT</version>
10+
<version>2.6.0-SNAPSHOT</version>
1111
</parent>
1212

1313
<artifactId>chartjs-java-model-demo</artifactId>
14-
<version>2.5.1-SNAPSHOT</version>
14+
<version>2.6.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.5.1-SNAPSHOT</version>
9+
<version>2.6.0-SNAPSHOT</version>
1010
<packaging>jar</packaging>
1111

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

chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/DoughnutOptions.java

Lines changed: 1 addition & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -16,100 +16,8 @@
1616
package software.xdev.chartjs.model.options;
1717

1818
import software.xdev.chartjs.model.options.animation.DoughnutAnimation;
19-
import software.xdev.chartjs.model.options.elements.ArcElements;
2019

2120

22-
public class DoughnutOptions extends Options<DoughnutOptions, DoughnutAnimation>
21+
public class DoughnutOptions extends DoughnutOptionsBase<DoughnutOptions, DoughnutAnimation>
2322
{
24-
/**
25-
* Default {@code 50}
26-
*
27-
* @see #setCutout(Number cutout)
28-
*/
29-
protected Number cutout;
30-
31-
/**
32-
* Rotation in degrees. Default {@code 0}. {@code 0} is at the top.
33-
*
34-
* @see #setRotation(Number rotation)
35-
*/
36-
protected Number rotation;
37-
38-
/**
39-
* Circumference in degrees. Default {@code 360}.
40-
*
41-
* @see #setCircumference(Number circumference)
42-
*/
43-
protected Number circumference;
44-
45-
protected ArcElements elements;
46-
47-
/**
48-
* @see #setCutout(Number cutoutPercentage)
49-
*/
50-
public Number getCutout()
51-
{
52-
return this.cutout;
53-
}
54-
55-
/**
56-
* The pixels as number of the chart that is cut out of the middle.
57-
*/
58-
public DoughnutOptions setCutout(final Number cutout)
59-
{
60-
this.cutout = cutout;
61-
return this;
62-
}
63-
64-
/**
65-
* @see #setRotation(Number rotation)
66-
*/
67-
public Number getRotation()
68-
{
69-
return this.rotation;
70-
}
71-
72-
/**
73-
* Starting angle to draw arcs from in degrees
74-
*/
75-
public DoughnutOptions setRotation(final Number rotation)
76-
{
77-
this.rotation = rotation;
78-
return this;
79-
}
80-
81-
/**
82-
* @see #setCircumference(Number circumference)
83-
*/
84-
public Number getCircumference()
85-
{
86-
return this.circumference;
87-
}
88-
89-
/**
90-
* Sweep to allow arcs to cover in degrees
91-
*/
92-
public DoughnutOptions setCircumference(final Number circumference)
93-
{
94-
this.circumference = circumference;
95-
return this;
96-
}
97-
98-
/**
99-
* @return {@link ArcElements} instance, or {@code null} if not set
100-
*/
101-
public ArcElements getElements()
102-
{
103-
return this.elements;
104-
}
105-
106-
/**
107-
* @param elements an {@link ArcElements} instance, or {@code null}
108-
* @return this instance for method chaining
109-
*/
110-
public DoughnutOptions setElements(final ArcElements elements)
111-
{
112-
this.elements = elements;
113-
return this;
114-
}
11523
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/*
2+
* Copyright © 2023 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package software.xdev.chartjs.model.options;
17+
18+
import software.xdev.chartjs.model.options.animation.DoughnutAnimationBase;
19+
20+
21+
/**
22+
* @see <a href="https://github.com/chartjs/Chart.js/blob/v4.4.6/src/types/index.d.ts#L298">ChartJS Source</a>
23+
*/
24+
public abstract class DoughnutOptionsBase<O extends DoughnutOptionsBase<O, A>, A extends DoughnutAnimationBase<A>>
25+
extends Options<O, A>
26+
{
27+
private Number circumference;
28+
private Object cutout; // number or string
29+
private Object offset; // number or number[]
30+
private Object radius; // number or string
31+
private Number rotation;
32+
private Number spacing;
33+
34+
public Number getCircumference()
35+
{
36+
return this.circumference;
37+
}
38+
39+
public DoughnutOptionsBase<O, A> setCircumference(final Number circumference)
40+
{
41+
this.circumference = circumference;
42+
return this.self();
43+
}
44+
45+
public Object getCutout()
46+
{
47+
return this.cutout;
48+
}
49+
50+
public DoughnutOptionsBase<O, A> setCutout(final Object cutout)
51+
{
52+
this.cutout = cutout;
53+
return this.self();
54+
}
55+
56+
public Object getOffset()
57+
{
58+
return this.offset;
59+
}
60+
61+
public DoughnutOptionsBase<O, A> setOffset(final Object offset)
62+
{
63+
this.offset = offset;
64+
return this.self();
65+
}
66+
67+
public Object getRadius()
68+
{
69+
return this.radius;
70+
}
71+
72+
public DoughnutOptionsBase<O, A> setRadius(final Object radius)
73+
{
74+
this.radius = radius;
75+
return this.self();
76+
}
77+
78+
public Number getRotation()
79+
{
80+
return this.rotation;
81+
}
82+
83+
public DoughnutOptionsBase<O, A> setRotation(final Number rotation)
84+
{
85+
this.rotation = rotation;
86+
return this.self();
87+
}
88+
89+
public Number getSpacing()
90+
{
91+
return this.spacing;
92+
}
93+
94+
public DoughnutOptionsBase<O, A> setSpacing(final Number spacing)
95+
{
96+
this.spacing = spacing;
97+
return this.self();
98+
}
99+
}

chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/Options.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@
2828

2929

3030
/**
31-
* @see <a href="https://github.com/chartjs/Chart.js/blob/v4.4.3/src/types/index.d.ts#L1588">ChartJS Source</a>
31+
* @see <a href="https://github.com/chartjs/Chart.js/blob/v4.4.7/src/types/index.d.ts#L1588">
32+
* ChartJS Source (Options)</a>
33+
* @see <a href="https://github.com/chartjs/Chart.js/blob/v4.4.7/src/types/index.d.ts#L1756">
34+
* ChartJS Source (AnimationOptons)</a>
3235
*/
3336
public class Options<T extends Options<T, A>, A extends Animation<A>>
3437
{
@@ -43,7 +46,7 @@ public class Options<T extends Options<T, A>, A extends Animation<A>>
4346
protected CoreInteractionOptions interaction;
4447
protected CoreInteractionOptions hover;
4548
protected Animations<A> animations;
46-
protected Boolean animation = true;
49+
protected Object animation; // Not supported by all charts, but usually a boolean or of Type <A>
4750
protected Layout layout;
4851
protected Plugins plugins = new Plugins();
4952

@@ -89,18 +92,12 @@ public T setResponsive(final Boolean responsive)
8992
return this.self();
9093
}
9194

92-
/**
93-
* @see #setAnimation(Boolean)
94-
*/
95-
public Boolean getAnimation()
95+
public Object getAnimation()
9696
{
9797
return this.animation;
9898
}
9999

100-
/**
101-
* Default {@code true} Disables the Animation completely if set to {@code false}.
102-
*/
103-
public T setAnimation(final Boolean animation)
100+
public T setAnimation(final Object animation)
104101
{
105102
this.animation = animation;
106103
return this.self();

chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/PieOptions.java

Lines changed: 1 addition & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -16,101 +16,8 @@
1616
package software.xdev.chartjs.model.options;
1717

1818
import software.xdev.chartjs.model.options.animation.PieAnimation;
19-
import software.xdev.chartjs.model.options.elements.ArcElements;
2019

2120

22-
public class PieOptions extends Options<PieOptions, PieAnimation>
21+
public class PieOptions extends DoughnutOptionsBase<PieOptions, PieAnimation>
2322
{
24-
25-
/**
26-
* Default {@code 50 - for doughnut, 0 - for pie}
27-
*
28-
* @see #setCutoutPercentage(Number cutoutPercentage)
29-
*/
30-
protected Number cutoutPercentage;
31-
32-
/**
33-
* Default {@code -0.5 * Math.PI}
34-
*
35-
* @see #setRotation(Number rotation)
36-
*/
37-
protected Number rotation;
38-
39-
/**
40-
* Default {@code 2 * Math.PI}
41-
*
42-
* @see #setCircumference(Number circumference)
43-
*/
44-
protected Number circumference;
45-
46-
protected ArcElements elements;
47-
48-
/**
49-
* @see #setCutoutPercentage(Number cutoutPercentage)
50-
*/
51-
public Number getCutoutPercentage()
52-
{
53-
return this.cutoutPercentage;
54-
}
55-
56-
/**
57-
* The percentage of the chart that is cut out of the middle.
58-
*/
59-
public PieOptions setCutoutPercentage(final Number cutoutPercentage)
60-
{
61-
this.cutoutPercentage = cutoutPercentage;
62-
return this;
63-
}
64-
65-
/**
66-
* @see #setRotation(Number rotation)
67-
*/
68-
public Number getRotation()
69-
{
70-
return this.rotation;
71-
}
72-
73-
/**
74-
* Starting angle to draw arcs from
75-
*/
76-
public PieOptions setRotation(final Number rotation)
77-
{
78-
this.rotation = rotation;
79-
return this;
80-
}
81-
82-
/**
83-
* @see #setCircumference(Number circumference)
84-
*/
85-
public Number getCircumference()
86-
{
87-
return this.circumference;
88-
}
89-
90-
/**
91-
* Sweep to allow arcs to cover
92-
*/
93-
public PieOptions setCircumference(final Number circumference)
94-
{
95-
this.circumference = circumference;
96-
return this;
97-
}
98-
99-
/**
100-
* @return {@link ArcElements} instance, or {@code null} if not set
101-
*/
102-
public ArcElements getElements()
103-
{
104-
return this.elements;
105-
}
106-
107-
/**
108-
* @param elements an {@link ArcElements} instance, or {@code null}
109-
* @return this instance for method chaining
110-
*/
111-
public PieOptions setElements(final ArcElements elements)
112-
{
113-
this.elements = elements;
114-
return this;
115-
}
11623
}

0 commit comments

Comments
 (0)