Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf2f071b

Browse files
committed
test simple polar bar
1 parent0017321 commitf2f071b

File tree

5 files changed

+115
-0
lines changed

5 files changed

+115
-0
lines changed

‎src/main/java/org/icepear/echarts/PolarCoordChart.java‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
packageorg.icepear.echarts;
22

3+
importorg.icepear.echarts.components.coord.polar.CategoryAngleAxis;
4+
importorg.icepear.echarts.components.coord.polar.CategoryRadiusAxis;
35
importorg.icepear.echarts.components.coord.polar.DefaultAngleAxis;
46
importorg.icepear.echarts.components.coord.polar.DefaultRadiusAxis;
57
importorg.icepear.echarts.components.coord.polar.PolarAxis;
@@ -13,6 +15,11 @@ public PolarCoordChart(final Class<T> clazz, final Class<E> seriesClazz) {
1315
option.setPolar(newPolarAxis());
1416
}
1517

18+
publicTsetPolarAxis(String[]radius) {
19+
option.setPolar(newPolarAxis().setRadius(radius));
20+
returnself;
21+
}
22+
1623
publicTsetPolarAxis(PolarAxispolarAxis) {
1724
option.setPolar(polarAxis);
1825
returnself;
@@ -23,6 +30,16 @@ public T setAngleAxis() {
2330
returnself;
2431
}
2532

33+
publicTsetAngleAxis(Numbermax) {
34+
option.setAngleAxis(newDefaultAngleAxis().setMax(max));
35+
returnself;
36+
}
37+
38+
publicTsetAngleAxis(String[]categories) {
39+
option.setAngleAxis(newCategoryAngleAxis().setData(categories));
40+
returnself;
41+
}
42+
2643
publicTsetAngleAxis(AngleAxisOptionangleAxis) {
2744
option.setAngleAxis(angleAxis);
2845
returnself;
@@ -33,6 +50,16 @@ public T setRadiusAxis() {
3350
returnself;
3451
}
3552

53+
publicTsetRadiusAxis(Numbermax) {
54+
option.setRadiusAxis(newDefaultRadiusAxis().setMax(max));
55+
returnself;
56+
}
57+
58+
publicTsetRadiusAxis(String[]categories) {
59+
option.setRadiusAxis(newCategoryRadiusAxis().setData(categories));
60+
returnself;
61+
}
62+
3663
publicTsetRadiusAxis(RadiusAxisOptionradiusAxis) {
3764
option.setRadiusAxis(radiusAxis);
3865
returnself;
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
packageorg.icepear.echarts.simple.polarBar;
2+
3+
importstaticorg.junit.Assert.assertEquals;
4+
5+
importjava.io.InputStreamReader;
6+
importjava.io.Reader;
7+
8+
importcom.google.gson.JsonElement;
9+
importcom.google.gson.JsonParser;
10+
11+
importorg.icepear.echarts.PolarBar;
12+
importorg.icepear.echarts.serializer.EChartsSerializer;
13+
importorg.junit.Test;
14+
15+
publicclassRadialPolarBarTest {
16+
@Test
17+
publicvoidtestRadialPolarBar() {
18+
PolarBarpolarBar =newPolarBar()
19+
.setTitle("Radial Polar Bar")
20+
.setPolarAxis(newString[] {"30","80%" })
21+
.setRadiusAxis(4)
22+
.setAngleAxis(newString[] {"a","b","c","d" })
23+
.setTooltip("item")
24+
.addSeries(newNumber[] {2,1.2,2.4,3.6 });
25+
26+
Readerreader =newInputStreamReader(
27+
this.getClass().getResourceAsStream("/simple/polar-bar/radial-polar-bar.json"));
28+
JsonElementexpected =JsonParser.parseReader(reader);
29+
JsonElementactual =EChartsSerializer.toJsonTree(polarBar.getOption());
30+
assertEquals(expected,actual);
31+
32+
// System.out.println(EChartsSerializer.toJson(polarBar.getOption()));
33+
}
34+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
packageorg.icepear.echarts.simple.polarBar;
2+
3+
importstaticorg.junit.Assert.assertEquals;
4+
5+
importjava.io.InputStreamReader;
6+
importjava.io.Reader;
7+
8+
importcom.google.gson.JsonElement;
9+
importcom.google.gson.JsonParser;
10+
11+
importorg.icepear.echarts.PolarBar;
12+
importorg.icepear.echarts.serializer.EChartsSerializer;
13+
importorg.junit.Test;
14+
15+
publicclassTangentialPolarBarTest {
16+
@Test
17+
publicvoidtestTangentialPolarBar() {
18+
PolarBarpolarBar =newPolarBar()
19+
.setTitle("Tangential Polar Bar")
20+
.setPolarAxis(newString[] {"30","80%" })
21+
.setRadiusAxis(newString[] {"a","b","c","d" })
22+
.setAngleAxis(4)
23+
.setTooltip("item")
24+
.addSeries(newNumber[] {2,1.2,2.4,3.6 });
25+
26+
Readerreader =newInputStreamReader(
27+
this.getClass().getResourceAsStream("/simple/polar-bar/tangential-polar-bar.json"));
28+
JsonElementexpected =JsonParser.parseReader(reader);
29+
JsonElementactual =EChartsSerializer.toJsonTree(polarBar.getOption());
30+
assertEquals(expected,actual);
31+
32+
// System.out.println(EChartsSerializer.toJson(polarBar.getOption()));
33+
}
34+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"title": {"text":"Radial Polar Bar" },
3+
"polar": {"radius": ["30","80%"] },
4+
"angleAxis": {"type":"category","data": ["a","b","c","d"] },
5+
"radiusAxis": {"max":4 },
6+
"tooltip": {"trigger":"item" },
7+
"series": [
8+
{"type":"bar","data": [2,1.2,2.4,3.6],"coordinateSystem":"polar" }
9+
]
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"title": {"text":"Tangential Polar Bar" },
3+
"polar": {"radius": ["30","80%"] },
4+
"angleAxis": {"max":4 },
5+
"radiusAxis": {"type":"category","data": ["a","b","c","d"] },
6+
"tooltip": {"trigger":"item" },
7+
"series": [
8+
{"type":"bar","data": [2,1.2,2.4,3.6],"coordinateSystem":"polar" }
9+
]
10+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp