-
Notifications
You must be signed in to change notification settings - Fork 6
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Checklist
- I made sure that there are no existing issues - open or closed - which I could contribute my information to.
- I have taken the time to fill in all the required details. I understand that the feature request will be dismissed otherwise.
- This issue contains only one feature request/enhancement.
Description
Advantages are;
- Instead of using int, double and BigDecimal, you can create shorter classes using the Number abstract class.
- Sometimes there may be null or Double.NaN values in the data. https://www.chartjs.org/docs/latest/general/data-structures.html#object
Therefore, my suggestion is to create an interface NumberDataset.java
file instead of BigDecimalDataset.java file and remove int, double, BigDecimal and use Number abstract class instead.
As an example, the current ScatterDataPoint
file;
public class ScatterDataPoint extends XYDataPointBase<ScatterDataPoint>
{
public ScatterDataPoint()
{
}
public ScatterDataPoint(final int x, final int y)
{
super(x, y);
}
public ScatterDataPoint(final double x, final double y)
{
super(x, y);
}
public ScatterDataPoint(final BigDecimal x, final BigDecimal y)
{
super(x, y);
}
}
and after the change
public class ScatterDataPoint extends XYDataPointBase<ScatterDataPoint>
{
public ScatterDataPoint()
{
}
public ScatterDataPoint(final Number x, final Number y)
{
super(x, y);
}
}
and proposed NumberDataset.java
public interface NumberDataset<S extends Dataset<?, Number>>
{
S self();
default S setData(final Number... data)
{
this.self().clearData();
if(data != null)
{
Arrays.stream(data).forEach(this::addData);
}
return this.self();
}
/**
* Add the data point to this {@code Dataset}
*
* @see Dataset#setData(Collection)
*/
default S addData(final Number data)
{
this.self().addData(data);
return this.self();
}
}
Additional information
No response
AB-xdev
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request