File tree Expand file tree Collapse file tree 5 files changed +40
-46
lines changed
main/java/software/xdev/chartjs/model/options
test/java/software/xdev/chartjs/model Expand file tree Collapse file tree 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+
14## 2.0.1
25* Restored `` DisplayFormats `` #186
36
Original file line number Diff line number Diff line change 1515 */
1616package software .xdev .chartjs .model .options ;
1717
18- import java .util .Locale ;
19-
20- import com .fasterxml .jackson .annotation .JsonValue ;
21-
2218import software .xdev .chartjs .model .options .animation .DefaultAnimation ;
2319import software .xdev .chartjs .model .options .elements .BarElements ;
2420
2521
2622public class BarOptions extends Options <BarOptions , DefaultAnimation >
2723{
28- protected IndexAxis indexAxis = IndexAxis .X ;
2924 protected BarElements elements ;
3025
3126 /**
@@ -36,48 +31,9 @@ public BarElements getElements()
3631 return this .elements ;
3732 }
3833
39- /**
40- * @param elements an {@link BarElements} instance, or {@code null}
41- * @return this instance for method chaining
42- */
4334 public BarOptions setElements (final BarElements elements )
4435 {
4536 this .elements = elements ;
4637 return this ;
4738 }
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- }
8339}
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 2626import software .xdev .chartjs .model .options .scale .Scales ;
2727
2828
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+ */
2932public class Options <T extends Options <T , A >, A extends Animation <A >>
3033{
3134 protected final Set <String > events = new HashSet <>();
35+ protected IndexAxis indexAxis ;
3236 protected Boolean responsive ;
3337 protected Integer responsiveAnimationDuration ;
3438 protected Boolean maintainAspectRatio ;
@@ -55,6 +59,17 @@ public T setScales(final Scales scales)
5559 return this .self ();
5660 }
5761
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+
5873 /**
5974 * @see #setResponsive(Boolean)
6075 */
Original file line number Diff line number Diff line change 2929import software .xdev .chartjs .model .datapoint .XYDataPoint ;
3030import software .xdev .chartjs .model .dataset .BarDataset ;
3131import software .xdev .chartjs .model .options .BarOptions ;
32+ import software .xdev .chartjs .model .options .IndexAxis ;
3233import software .xdev .chartjs .model .options .scale .Scales ;
3334import software .xdev .chartjs .model .options .scale .cartesian .AbstractCartesianScaleOptions ;
3435import software .xdev .chartjs .model .options .scale .cartesian .CartesianScaleOptions ;
@@ -134,7 +135,7 @@ void testStackedHorizontal()
134135 {
135136 final BarOptions options = new BarOptions ()
136137 .setAnimation (false )
137- .setIndexAxis (BarOptions . IndexAxis .Y );
138+ .setIndexAxis (IndexAxis .Y );
138139 options
139140 .getScales ()
140141 .addScale (Scales .ScaleAxis .X , new CartesianScaleOptions ().setStacked (true ))
@@ -177,7 +178,7 @@ void testStackedWithGroups()
177178
178179 final BarOptions options = new BarOptions ()
179180 .setAnimation (false )
180- .setIndexAxis (BarOptions . IndexAxis .Y );
181+ .setIndexAxis (IndexAxis .Y );
181182 options
182183 .getScales ()
183184 .addScale (Scales .ScaleAxis .X , new CartesianScaleOptions ().setStacked (true ))
You can’t perform that action at this time.
0 commit comments