File tree 5 files changed +40
-46
lines changed
main/java/software/xdev/chartjs/model/options
test/java/software/xdev/chartjs/model
5 files changed +40
-46
lines changed Original file line number Diff line number Diff line change
1
+ ## 2.0.2
2
+ * Make `` IndexAxis `` available in all options
3
+
1
4
## 2.0.1
2
5
* Restored `` DisplayFormats `` #186
3
6
Original file line number Diff line number Diff line change 15
15
*/
16
16
package software .xdev .chartjs .model .options ;
17
17
18
- import java .util .Locale ;
19
-
20
- import com .fasterxml .jackson .annotation .JsonValue ;
21
-
22
18
import software .xdev .chartjs .model .options .animation .DefaultAnimation ;
23
19
import software .xdev .chartjs .model .options .elements .BarElements ;
24
20
25
21
26
22
public class BarOptions extends Options <BarOptions , DefaultAnimation >
27
23
{
28
- protected IndexAxis indexAxis = IndexAxis .X ;
29
24
protected BarElements elements ;
30
25
31
26
/**
@@ -36,48 +31,9 @@ public BarElements getElements()
36
31
return this .elements ;
37
32
}
38
33
39
- /**
40
- * @param elements an {@link BarElements} instance, or {@code null}
41
- * @return this instance for method chaining
42
- */
43
34
public BarOptions setElements (final BarElements elements )
44
35
{
45
36
this .elements = elements ;
46
37
return this ;
47
38
}
48
-
49
- /**
50
- * @return the orientation of the bars
51
- */
52
- public IndexAxis getIndexAxis ()
53
- {
54
- return this .indexAxis ;
55
- }
56
-
57
- /**
58
- * <p>
59
- * Sets the orientation of the bars. {@code "y"} results in horizontal bars.
60
- * </p>
61
- * <p>
62
- * Default {@code "x"}
63
- * </p>
64
- */
65
- public BarOptions setIndexAxis (final IndexAxis indexAxis )
66
- {
67
- this .indexAxis = indexAxis ;
68
- return this ;
69
- }
70
-
71
- public enum IndexAxis
72
- {
73
- X ,
74
- Y ;
75
-
76
- @ JsonValue
77
- @ Override
78
- public String toString ()
79
- {
80
- return super .toString ().toLowerCase (Locale .ENGLISH );
81
- }
82
- }
83
39
}
Original file line number Diff line number Diff line change
1
+ package software .xdev .chartjs .model .options ;
2
+
3
+ import java .util .Locale ;
4
+
5
+ import com .fasterxml .jackson .annotation .JsonValue ;
6
+
7
+
8
+ public enum IndexAxis
9
+ {
10
+ X ,
11
+ Y ;
12
+
13
+ @ JsonValue
14
+ @ Override
15
+ public String toString ()
16
+ {
17
+ return super .toString ().toLowerCase (Locale .ENGLISH );
18
+ }
19
+ }
Original file line number Diff line number Diff line change 26
26
import software .xdev .chartjs .model .options .scale .Scales ;
27
27
28
28
29
+ /**
30
+ * @see <a href="https://github.com/chartjs/Chart.js/blob/v4.4.3/src/types/index.d.ts#L1588">ChartJS Source</a>
31
+ */
29
32
public class Options <T extends Options <T , A >, A extends Animation <A >>
30
33
{
31
34
protected final Set <String > events = new HashSet <>();
35
+ protected IndexAxis indexAxis ;
32
36
protected Boolean responsive ;
33
37
protected Integer responsiveAnimationDuration ;
34
38
protected Boolean maintainAspectRatio ;
@@ -55,6 +59,17 @@ public T setScales(final Scales scales)
55
59
return this .self ();
56
60
}
57
61
62
+ public IndexAxis getIndexAxis ()
63
+ {
64
+ return this .indexAxis ;
65
+ }
66
+
67
+ public T setIndexAxis (final IndexAxis indexAxis )
68
+ {
69
+ this .indexAxis = indexAxis ;
70
+ return this .self ();
71
+ }
72
+
58
73
/**
59
74
* @see #setResponsive(Boolean)
60
75
*/
Original file line number Diff line number Diff line change 29
29
import software .xdev .chartjs .model .datapoint .XYDataPoint ;
30
30
import software .xdev .chartjs .model .dataset .BarDataset ;
31
31
import software .xdev .chartjs .model .options .BarOptions ;
32
+ import software .xdev .chartjs .model .options .IndexAxis ;
32
33
import software .xdev .chartjs .model .options .scale .Scales ;
33
34
import software .xdev .chartjs .model .options .scale .cartesian .AbstractCartesianScaleOptions ;
34
35
import software .xdev .chartjs .model .options .scale .cartesian .CartesianScaleOptions ;
@@ -134,7 +135,7 @@ void testStackedHorizontal()
134
135
{
135
136
final BarOptions options = new BarOptions ()
136
137
.setAnimation (false )
137
- .setIndexAxis (BarOptions . IndexAxis .Y );
138
+ .setIndexAxis (IndexAxis .Y );
138
139
options
139
140
.getScales ()
140
141
.addScale (Scales .ScaleAxis .X , new CartesianScaleOptions ().setStacked (true ))
@@ -177,7 +178,7 @@ void testStackedWithGroups()
177
178
178
179
final BarOptions options = new BarOptions ()
179
180
.setAnimation (false )
180
- .setIndexAxis (BarOptions . IndexAxis .Y );
181
+ .setIndexAxis (IndexAxis .Y );
181
182
options
182
183
.getScales ()
183
184
.addScale (Scales .ScaleAxis .X , new CartesianScaleOptions ().setStacked (true ))
You can’t perform that action at this time.
0 commit comments