Skip to content

Commit

Permalink
Merge pull request #49 from xdev-software/support-more-data-structures
Browse files Browse the repository at this point in the history
Support more data structures
  • Loading branch information
AB-xdev authored Oct 26, 2023
2 parents b5339c0 + e476231 commit 0c36094
Show file tree
Hide file tree
Showing 26 changed files with 275 additions and 269 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
## 1.1.0
* Added support for more [data structures](https://www.chartjs.org/docs/4.4.0/general/data-structures.html) inside ``Dataset#data``
* ``Dataset#data`` can now contain ``Object``s

## 1.0.2
* Support Java 11
* Updated dependencies

## 1.0.1
* Added support for [stacked bar chart with groups](https://www.chartjs.org/docs/latest/samples/bar/stacked-groups.html)
* Added support for [stacked bar chart with groups](https://www.chartjs.org/docs/4.4.0/samples/bar/stacked-groups.html)

## 1.0.0
Initial release
Expand Down
2 changes: 1 addition & 1 deletion chartjs-java-model-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.xdev-software</groupId>
<artifactId>chartjs-java-model-demo</artifactId>
<version>1.0.3-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<inceptionYear>2022</inceptionYear>
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>com.xdev-software</groupId>
<artifactId>chartjs-java-model</artifactId>
<version>1.0.3-SNAPSHOT</version>
<version>1.1.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 @@ -28,7 +28,7 @@
import software.xdev.chartjs.model.options.Options;


public abstract class AbstractChart<T, O extends Options<O, ?>, D extends Data<D, ?, ?>>
public abstract class AbstractChart<T, O extends Options<O, ?>, D extends Data<D, ?>>
implements Chart<T, O, D>
{
protected D data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@


@SuppressWarnings("java:S119") // SELF means the Chart itself... Not a problem
public interface Chart<SELF, O extends Options<O, ?>, D extends Data<D, ?, ?>>
public interface Chart<SELF, O extends Options<O, ?>, D extends Data<D, ?>>
{
/**
* @return type of this {@link Chart} implementation for proper drawing in JavaScript.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@
*/
package software.xdev.chartjs.model.data;

import java.math.BigDecimal;

import software.xdev.chartjs.model.dataset.BarDataset;


public class BarData extends Data<BarData, BarDataset, BigDecimal>
public class BarData extends Data<BarData, BarDataset>
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
*/
package software.xdev.chartjs.model.data;

import software.xdev.chartjs.model.datapoint.BubbleDataPoint;
import software.xdev.chartjs.model.dataset.BubbleDataset;


public class BubbleData extends Data<BubbleData, BubbleDataset, BubbleDataPoint>
public class BubbleData extends Data<BubbleData, BubbleDataset>
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@
import software.xdev.chartjs.model.dataset.Dataset;


public class Data<D extends Data<D, T, O>, T extends Dataset<T, O>, O>
public class Data<D extends Data<D, T>, T extends Dataset<T, ?>>
{

private final List<String> labels = new ArrayList<>();
private final List<T> datasets = new ArrayList<>();

Expand All @@ -40,7 +39,6 @@ public List<String> getLabels() {
/**
* Sets the backing label list, replacing any labels previously added or set
*
* @param labels
* @return this object to allow method chaining
*/
public D setLabels(final Collection<String> labels) {
Expand All @@ -54,7 +52,6 @@ public D setLabels(final Collection<String> labels) {
/**
* Sets the backing label list, replacing any labels previously added or set
*
* @param labels
* @return this object to allow method chaining
*/
public D setLabels(final String... labels) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@
*/
package software.xdev.chartjs.model.data;

import java.math.BigDecimal;

import software.xdev.chartjs.model.dataset.DoughnutDataset;


public class DoughnutData extends Data<DoughnutData, DoughnutDataset, BigDecimal>
public class DoughnutData extends Data<DoughnutData, DoughnutDataset>
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@
*/
package software.xdev.chartjs.model.data;

import java.math.BigDecimal;

import software.xdev.chartjs.model.dataset.LineDataset;


public class LineData extends Data<LineData, LineDataset, BigDecimal>
public class LineData extends Data<LineData, LineDataset>
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@
*/
package software.xdev.chartjs.model.data;

import java.math.BigDecimal;

import software.xdev.chartjs.model.dataset.PieDataset;


public class PieData extends Data<PieData, PieDataset, BigDecimal>
public class PieData extends Data<PieData, PieDataset>
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@
*/
package software.xdev.chartjs.model.data;

import java.math.BigDecimal;

import software.xdev.chartjs.model.dataset.PolarDataset;


public class PolarData extends Data<PolarData, PolarDataset, BigDecimal>
public class PolarData extends Data<PolarData, PolarDataset>
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@
*/
package software.xdev.chartjs.model.data;

import java.math.BigDecimal;

import software.xdev.chartjs.model.dataset.RadarDataset;


public class RadarData extends Data<RadarData, RadarDataset, BigDecimal>
public class RadarData extends Data<RadarData, RadarDataset>
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
*/
package software.xdev.chartjs.model.data;

import software.xdev.chartjs.model.datapoint.ScatterDataPoint;
import software.xdev.chartjs.model.dataset.ScatterDataset;


public class ScatterData extends Data<ScatterData, ScatterDataset, ScatterDataPoint>
public class ScatterData extends Data<ScatterData, ScatterDataset>
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,8 @@
import java.math.BigDecimal;


public class BubbleDataPoint
public class BubbleDataPoint extends XYDataPointBase<BubbleDataPoint>
{

private BigDecimal x;

private BigDecimal y;

private BigDecimal r;

public BubbleDataPoint()
Expand All @@ -33,57 +28,10 @@ public BubbleDataPoint()

public BubbleDataPoint(final BigDecimal x, final BigDecimal y, final BigDecimal r)
{
this.x = x;
this.y = y;
super(x, y);
this.r = r;
}

public BigDecimal getX()
{
return this.x;
}

public BubbleDataPoint setX(final int x)
{
this.x = new BigDecimal(x);
return this;
}

public BubbleDataPoint setX(final double x)
{
this.x = new BigDecimal(String.valueOf(x));
return this;
}

public BubbleDataPoint setX(final BigDecimal x)
{
this.x = x;
return this;
}

public BigDecimal getY()
{
return this.y;
}

public BubbleDataPoint setY(final int y)
{
this.y = new BigDecimal(y);
return this;
}

public BubbleDataPoint setY(final double y)
{
this.y = new BigDecimal(String.valueOf(y));
return this;
}

public BubbleDataPoint setY(final BigDecimal y)
{
this.y = y;
return this;
}

public BigDecimal getR()
{
return this.r;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,78 +18,24 @@
import java.math.BigDecimal;


public class ScatterDataPoint
public class ScatterDataPoint extends XYDataPointBase<ScatterDataPoint>
{

private BigDecimal x;

private BigDecimal y;

public ScatterDataPoint()
{
}

public ScatterDataPoint(final int x, final int y)
{
this.setX(x);
this.setY(y);
super(x, y);
}

public ScatterDataPoint(final double x, final double y)
{
this.setX(x);
this.setY(y);
super(x, y);
}

public ScatterDataPoint(final BigDecimal x, final BigDecimal y)
{
this.setX(x);
this.setY(y);
}

public BigDecimal getX()
{
return this.x;
}

public ScatterDataPoint setX(final int x)
{
this.x = new BigDecimal(x);
return this;
}

public ScatterDataPoint setX(final double x)
{
this.x = new BigDecimal(String.valueOf(x));
return this;
}

public ScatterDataPoint setX(final BigDecimal x)
{
this.x = x;
return this;
}

public BigDecimal getY()
{
return this.y;
}

public ScatterDataPoint setY(final int y)
{
this.y = new BigDecimal(y);
return this;
}

public ScatterDataPoint setY(final double y)
{
this.y = new BigDecimal(String.valueOf(y));
return this;
}

public ScatterDataPoint setY(final BigDecimal y)
{
this.y = y;
return this;
super(x, y);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* 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.datapoint;

import java.math.BigDecimal;


public class XYDataPoint extends XYDataPointBase<XYDataPoint>
{
public XYDataPoint()
{
}

public XYDataPoint(final int x, final int y)
{
super(x, y);
}

public XYDataPoint(final double x, final double y)
{
super(x, y);
}

public XYDataPoint(final BigDecimal x, final BigDecimal y)
{
super(x, y);
}
}
Loading

0 comments on commit 0c36094

Please sign in to comment.