Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 2.6.0
* Synced ``Doughnut/PieOptions`` from ChartJS source code #293

## 2.5.0
* Synced ``Legend`` from ChartJS source code #285

Expand Down
4 changes: 2 additions & 2 deletions chartjs-java-model-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<parent>
<groupId>software.xdev</groupId>
<artifactId>chartjs-java-model-root</artifactId>
<version>2.5.1-SNAPSHOT</version>
<version>2.6.0-SNAPSHOT</version>
</parent>

<artifactId>chartjs-java-model-demo</artifactId>
<version>2.5.1-SNAPSHOT</version>
<version>2.6.0-SNAPSHOT</version>
<packaging>jar</packaging>

<organization>
Expand Down
2 changes: 1 addition & 1 deletion chartjs-java-model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>software.xdev</groupId>
<artifactId>chartjs-java-model</artifactId>
<version>2.5.1-SNAPSHOT</version>
<version>2.6.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>chartjs-java-model</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,100 +16,8 @@
package software.xdev.chartjs.model.options;

import software.xdev.chartjs.model.options.animation.DoughnutAnimation;
import software.xdev.chartjs.model.options.elements.ArcElements;


public class DoughnutOptions extends Options<DoughnutOptions, DoughnutAnimation>
public class DoughnutOptions extends DoughnutOptionsBase<DoughnutOptions, DoughnutAnimation>
{
/**
* Default {@code 50}
*
* @see #setCutout(Number cutout)
*/
protected Number cutout;

/**
* Rotation in degrees. Default {@code 0}. {@code 0} is at the top.
*
* @see #setRotation(Number rotation)
*/
protected Number rotation;

/**
* Circumference in degrees. Default {@code 360}.
*
* @see #setCircumference(Number circumference)
*/
protected Number circumference;

protected ArcElements elements;

/**
* @see #setCutout(Number cutoutPercentage)
*/
public Number getCutout()
{
return this.cutout;
}

/**
* The pixels as number of the chart that is cut out of the middle.
*/
public DoughnutOptions setCutout(final Number cutout)
{
this.cutout = cutout;
return this;
}

/**
* @see #setRotation(Number rotation)
*/
public Number getRotation()
{
return this.rotation;
}

/**
* Starting angle to draw arcs from in degrees
*/
public DoughnutOptions setRotation(final Number rotation)
{
this.rotation = rotation;
return this;
}

/**
* @see #setCircumference(Number circumference)
*/
public Number getCircumference()
{
return this.circumference;
}

/**
* Sweep to allow arcs to cover in degrees
*/
public DoughnutOptions setCircumference(final Number circumference)
{
this.circumference = circumference;
return this;
}

/**
* @return {@link ArcElements} instance, or {@code null} if not set
*/
public ArcElements getElements()
{
return this.elements;
}

/**
* @param elements an {@link ArcElements} instance, or {@code null}
* @return this instance for method chaining
*/
public DoughnutOptions setElements(final ArcElements elements)
{
this.elements = elements;
return this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* Copyright © 2023 XDEV Software (https://xdev.software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package software.xdev.chartjs.model.options;

import software.xdev.chartjs.model.options.animation.DoughnutAnimationBase;


/**
* @see <a href="https://github.com/chartjs/Chart.js/blob/v4.4.6/src/types/index.d.ts#L298">ChartJS Source</a>
*/
public abstract class DoughnutOptionsBase<O extends DoughnutOptionsBase<O, A>, A extends DoughnutAnimationBase<A>>
extends Options<O, A>
{
private Number circumference;
private Object cutout; // number or string
private Object offset; // number or number[]
private Object radius; // number or string
private Number rotation;
private Number spacing;

public Number getCircumference()
{
return this.circumference;
}

public DoughnutOptionsBase<O, A> setCircumference(final Number circumference)
{
this.circumference = circumference;
return this.self();
}

public Object getCutout()
{
return this.cutout;
}

public DoughnutOptionsBase<O, A> setCutout(final Object cutout)
{
this.cutout = cutout;
return this.self();
}

public Object getOffset()
{
return this.offset;
}

public DoughnutOptionsBase<O, A> setOffset(final Object offset)
{
this.offset = offset;
return this.self();
}

public Object getRadius()
{
return this.radius;
}

public DoughnutOptionsBase<O, A> setRadius(final Object radius)
{
this.radius = radius;
return this.self();
}

public Number getRotation()
{
return this.rotation;
}

public DoughnutOptionsBase<O, A> setRotation(final Number rotation)
{
this.rotation = rotation;
return this.self();
}

public Number getSpacing()
{
return this.spacing;
}

public DoughnutOptionsBase<O, A> setSpacing(final Number spacing)
{
this.spacing = spacing;
return this.self();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@


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

Expand Down Expand Up @@ -89,18 +92,12 @@ public T setResponsive(final Boolean responsive)
return this.self();
}

/**
* @see #setAnimation(Boolean)
*/
public Boolean getAnimation()
public Object getAnimation()
{
return this.animation;
}

/**
* Default {@code true} Disables the Animation completely if set to {@code false}.
*/
public T setAnimation(final Boolean animation)
public T setAnimation(final Object animation)
{
this.animation = animation;
return this.self();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,101 +16,8 @@
package software.xdev.chartjs.model.options;

import software.xdev.chartjs.model.options.animation.PieAnimation;
import software.xdev.chartjs.model.options.elements.ArcElements;


public class PieOptions extends Options<PieOptions, PieAnimation>
public class PieOptions extends DoughnutOptionsBase<PieOptions, PieAnimation>
{

/**
* Default {@code 50 - for doughnut, 0 - for pie}
*
* @see #setCutoutPercentage(Number cutoutPercentage)
*/
protected Number cutoutPercentage;

/**
* Default {@code -0.5 * Math.PI}
*
* @see #setRotation(Number rotation)
*/
protected Number rotation;

/**
* Default {@code 2 * Math.PI}
*
* @see #setCircumference(Number circumference)
*/
protected Number circumference;

protected ArcElements elements;

/**
* @see #setCutoutPercentage(Number cutoutPercentage)
*/
public Number getCutoutPercentage()
{
return this.cutoutPercentage;
}

/**
* The percentage of the chart that is cut out of the middle.
*/
public PieOptions setCutoutPercentage(final Number cutoutPercentage)
{
this.cutoutPercentage = cutoutPercentage;
return this;
}

/**
* @see #setRotation(Number rotation)
*/
public Number getRotation()
{
return this.rotation;
}

/**
* Starting angle to draw arcs from
*/
public PieOptions setRotation(final Number rotation)
{
this.rotation = rotation;
return this;
}

/**
* @see #setCircumference(Number circumference)
*/
public Number getCircumference()
{
return this.circumference;
}

/**
* Sweep to allow arcs to cover
*/
public PieOptions setCircumference(final Number circumference)
{
this.circumference = circumference;
return this;
}

/**
* @return {@link ArcElements} instance, or {@code null} if not set
*/
public ArcElements getElements()
{
return this.elements;
}

/**
* @param elements an {@link ArcElements} instance, or {@code null}
* @return this instance for method chaining
*/
public PieOptions setElements(final ArcElements elements)
{
this.elements = elements;
return this;
}
}
Loading
Loading