Skip to content

Commit

Permalink
update: polish the options and upgrade gradle
Browse files Browse the repository at this point in the history
Also add the sample code for local testing usage
  • Loading branch information
Koooooo-7 committed Jul 4, 2024
1 parent e8ce24c commit 3778073
Show file tree
Hide file tree
Showing 41 changed files with 860 additions and 94 deletions.
10 changes: 5 additions & 5 deletions echarts4j-3rd-charts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

### 📊 Support 3rd-Charts

- Liquid
- Liquid-Fill
- WordCloud

### 📝 RunBook
Expand All @@ -21,11 +21,11 @@

```
Enhanced3rdChartsCanvas.builder()
.addCharts(LiquidChart.builder()
.addCharts(LiquidFillChart.builder()
.options(ChartOption.builder()
.title(Title.builder().text("Liquid Basic").build())
.build()
.addSeries(LiquidChartSeries.builder()
.addSeries(LiquidFillChartSeries.builder()
.data(Arrays.asList("0.6", "0.5", "0.1")).build())
).build())
.addCharts(PieChart.builder()
Expand Down Expand Up @@ -58,11 +58,11 @@
// box to 3rd support
Enhanced3rdChartsCanvas.box3rdChartsSupport(canvasExistPieChart.asBuilder())
.addCharts(LiquidChart.builder()
.addCharts(LiquidFillChart.builder()
.options(ChartOption.builder()
.title(Title.builder().text("Liquid Basic").build())
.build()
.addSeries(LiquidChartSeries.builder()
.addSeries(LiquidFillChartSeries.builder()
.data(Arrays.asList("0.6", "0.5", "0.1")).build())
).build())
.build()
Expand Down
7 changes: 7 additions & 0 deletions echarts4j-3rd-charts/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,10 @@ dependencies {
compileOnly "org.projectlombok:lombok:$lombokVersion"
annotationProcessor "org.projectlombok:lombok:$lombokVersion"
}

// for higher JDK compatibility
test {
doFirst {
jvmArgs += "--add-opens=java.base/java.lang=ALL-UNNAMED"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@AllArgsConstructor
@Getter
public enum Chart3rdType {
Liquid("liquidFill"),
LiquidFill("liquidFill"),
WordCloud("wordCloud"),
;
private final String type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.github.koooooo7.echarts4j.chart.Chart;
import com.github.koooooo7.echarts4j.chart.ChartType;
import com.github.koooooo7.echarts4j.ext.charts.Enhanced3rdChart;
import com.github.koooooo7.echarts4j.option.ChartOption;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.SuperBuilder;
Expand All @@ -18,7 +17,7 @@
@Data
@SuperBuilder
@EqualsAndHashCode(callSuper = true)
public class LiquidChart extends BaseChart<LiquidChart> implements Enhanced3rdChart {
public class LiquidFillChart extends BaseChart<LiquidFillChart> implements Enhanced3rdChart {
private static final String LIQUID_ADDITION_ASSET =
"https://cdn.jsdelivr.net/gh/ecomfe/echarts-liquidfill@master/dist/echarts-liquidfill.min.js";

Expand All @@ -29,7 +28,7 @@ public ChartType getChartType() {

@Override
public String getType() {
return Chart3rdType.Liquid.getType();
return Chart3rdType.LiquidFill.getType();
}

@Override
Expand All @@ -40,7 +39,7 @@ public Consumer<Canvas> canvasPostProcessor() {
}

@Override
public Chart<LiquidChart> overlap(Chart<?> c) {
public Chart<LiquidFillChart> overlap(Chart<?> c) {
throw new UnsupportedOperationException("Liquid chart currently does not support overlap");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@SuperBuilder
@JsonInclude(JsonInclude.Include.NON_NULL)
@EqualsAndHashCode(callSuper = true)
public class LiquidChartSeries extends GenericSeriesOption implements SeriesOption {
public class LiquidFillChartSeries extends GenericSeriesOption implements SeriesOption {
@Builder.Default
private String type = Chart3rdType.Liquid.getType();
private String type = Chart3rdType.LiquidFill.getType();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
import com.github.koooooo7.echarts4j.chart.Canvas;
import com.github.koooooo7.echarts4j.chart.PieChart;
import com.github.koooooo7.echarts4j.ext.charts.Enhanced3rdChartsCanvas;
import com.github.koooooo7.echarts4j.ext.charts.series.LiquidChartSeries;
import com.github.koooooo7.echarts4j.ext.charts.series.LiquidFillChartSeries;
import com.github.koooooo7.echarts4j.helper.DataHelper;
import com.github.koooooo7.echarts4j.option.ChartOption;
import com.github.koooooo7.echarts4j.option.chart.Title;
import com.github.koooooo7.echarts4j.option.series.PieChartSeriesOption;
import com.github.koooooo7.echarts4j.option.series.PieChartSeries;
import org.junit.jupiter.api.Test;

import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;

class LiquidChartTests {
class LiquidFillChartTests {

@Test
void shouldGenerateLiquidChart_WhenCallTheLiquidChartConfig_GivenNecessaryConfigs() {
Expand All @@ -29,18 +29,18 @@ void shouldGenerateLiquidChart_WhenCallTheLiquidChartConfig_GivenNecessaryConfig
.get();

Enhanced3rdChartsCanvas.builder()
.addCharts(LiquidChart.builder()
.addCharts(LiquidFillChart.builder()
.options(ChartOption.builder()
.title(Title.builder().text("Liquid Basic").build())
.build()
.addSeries(LiquidChartSeries.builder()
.addSeries(LiquidFillChartSeries.builder()
.data(Arrays.asList("0.6", "0.5", "0.1")).build())
).build())
.addCharts(PieChart.builder()
.options(ChartOption.builder()
.title(Title.builder().text("Pie Chart").build())
.build()
.addSeries(PieChartSeriesOption.builder()
.addSeries(PieChartSeries.builder()
.data(data).build()))
.build()).build()
.render();
Expand All @@ -66,18 +66,18 @@ void shouldGenerateLiquidChart_WhenCallTheLiquidChartConfig_GivenNecessaryConfig
.options(ChartOption.builder()
.title(Title.builder().text("Pie Chart").build())
.build()
.addSeries(PieChartSeriesOption.builder()
.addSeries(PieChartSeries.builder()
.data(data).build()))
.build())
.build();

// box to 3rd support
Enhanced3rdChartsCanvas.box3rdChartsSupport(canvasExistPieChart.asBuilder())
.addCharts(LiquidChart.builder()
.addCharts(LiquidFillChart.builder()
.options(ChartOption.builder()
.title(Title.builder().text("Liquid Basic").build())
.build()
.addSeries(LiquidChartSeries.builder()
.addSeries(LiquidFillChartSeries.builder()
.data(Arrays.asList("0.6", "0.5", "0.1")).build())
).build())
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import com.github.koooooo7.echarts4j.option.chart.Title;
import com.github.koooooo7.echarts4j.option.chart.XAxis;
import com.github.koooooo7.echarts4j.option.chart.YAxis;
import com.github.koooooo7.echarts4j.option.series.BarChartSeriesOption;
import com.github.koooooo7.echarts4j.option.series.LineChartSeriesOption;
import com.github.koooooo7.echarts4j.option.series.BarChartSeries;
import com.github.koooooo7.echarts4j.option.series.LineChartSeries;
import com.github.koooooo7.echarts4j.option.series.SeriesOption;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -97,11 +97,11 @@ void shouldServerChart_WhenUseTheChartServer_GivenChartAndCallTheRender() throws
.build())
.yAxis(YAxis.builder().build())
.build()
.addSeries(LineChartSeriesOption.builder()
.addSeries(LineChartSeries.builder()
.name(seriesName)
.data(data1)
.build())
.addSeries(BarChartSeriesOption.builder()
.addSeries(BarChartSeries.builder()
.name(seriesName2)
.data(data2)
.build())
Expand Down Expand Up @@ -137,11 +137,11 @@ void shouldServerLiveUpdateChart_WhenUseTheChartServer_GivenChartWithCustomUpdat
.build())
.yAxis(YAxis.builder().build())
.build()
.addSeries(LineChartSeriesOption.builder()
.addSeries(LineChartSeries.builder()
.name(seriesName)
.data(data1)
.build())
.addSeries(BarChartSeriesOption.builder()
.addSeries(BarChartSeries.builder()
.name(seriesName2)
.data(data2)
.build())
Expand Down Expand Up @@ -207,7 +207,7 @@ void shouldServerLiveUpdateChart_WhenUseTheChartServer_Given2ChartWithDifferentU
.build())
.yAxis(YAxis.builder().build())
.build()
.addSeries(LineChartSeriesOption.builder()
.addSeries(LineChartSeries.builder()
.name(seriesName)
.data(data1)
.build())
Expand All @@ -227,7 +227,7 @@ void shouldServerLiveUpdateChart_WhenUseTheChartServer_Given2ChartWithDifferentU
.build())
.yAxis(YAxis.builder().build())
.build()
.addSeries(BarChartSeriesOption.builder()
.addSeries(BarChartSeries.builder()
.name(seriesName2)
.data(data2)
.build())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.github.koooooo7.echarts4j.option.chart.DataZoom;
import com.github.koooooo7.echarts4j.option.chart.Grid;
import com.github.koooooo7.echarts4j.option.chart.Legend;
import com.github.koooooo7.echarts4j.option.chart.Radar;
Expand Down Expand Up @@ -31,6 +32,7 @@ public class ChartOption {
@JsonProperty("yAxis")
private YAxis yAxis;
private Radar radar;
private List<? extends DataZoom> dataZoom;
private Tooltip tooltip;
private Toolbox toolbox;
private Object color;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.github.koooooo7.echarts4j.option.chart;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.github.koooooo7.echarts4j.option.embedded.NameTextStyle;
import com.github.koooooo7.echarts4j.option.embedded.NameTruncate;
import com.github.koooooo7.echarts4j.type.FuncStr;
import lombok.Data;
import lombok.experimental.SuperBuilder;

import java.util.List;

@Data
@SuperBuilder
@JsonInclude(JsonInclude.Include.NON_NULL)
public class AngleAxis {
private String id;
private Integer polarIndex;
private Integer startAngle;
private Integer endAngle;
private Boolean clockwise;
private String type;
private List<?> data;
private Object boundaryGap;
private FuncStr min;
private FuncStr max;
private Boolean scale;
private Integer splitNumber;
private Integer minInterval;
private Integer maxInterval;
private Integer interval;
private Integer logBase;
private Boolean silent;
private Boolean triggerEvent;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.github.koooooo7.echarts4j.option.chart;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.github.koooooo7.echarts4j.type.FuncStr;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.SuperBuilder;

import java.util.List;

public class DataZoom {

@Data
@Builder
@EqualsAndHashCode(callSuper = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public static class InsideDataZoom extends DataZoom {
private String id;
@Builder.Default
private String type = "inside";
private Integer start;
private Integer end;
private FuncStr xAxisIndex;
private FuncStr yAxisIndex;

}

@Data
@Builder
@EqualsAndHashCode(callSuper = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public static class SliderDataZoom extends DataZoom {
private String id;
@Builder.Default
private String type = "slider";
private Boolean show;
private Integer start;
private Integer end;
private FuncStr xAxisIndex;
private FuncStr yAxisIndex;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.github.koooooo7.echarts4j.option.embedded;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.github.koooooo7.echarts4j.type.FuncStr;
import lombok.Builder;
import lombok.Data;


@Data
@Builder
@JsonInclude(JsonInclude.Include.NON_NULL)
public class MarkArea {
private Boolean silent;
private Label label;
private ItemStyle itemStyle;
private Emphasis emphasis;
private Object data;
private Boolean animation;


@Data
@Builder
@JsonInclude(JsonInclude.Include.NON_NULL)
public static class MarkAreaDataItem {
private String name;
private String type;
private FuncStr coord;
private Integer x;
private Integer y;
private Integer value;
private ItemStyle itemStyle;
private Label label;
private Emphasis emphasis;
private Boolean animation;
}
}
Loading

0 comments on commit 3778073

Please sign in to comment.