Skip to content

Commit 9bc999a

Browse files
committed
增加横向滚动,支持更多自定义图表,提供案例
1 parent f3f1dd6 commit 9bc999a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1758
-280
lines changed

README.en.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,25 @@
22

33
------
44
* [Chinese README](/README.md/)
5+
### version 1.4
6+
> support horizontal rolling and set width ratio.
7+
> to provide more cases
8+
>
9+
! [animation] (/img/zuoping.jpg)
510

11+
12+
! [animation] (/img/gif/tip.gif)
13+
### version 1.2 features
14+
15+
#### supports Tip and MarkView is highly customizable
16+
! [animation] (/img/gif/tip.gif)
17+
18+
### version 1.1 features
19+
20+
#### 1. ViewPager and a list of gestures to solve the conflict
21+
! [gesture conflict] (/img/gif/viewpager.gif)
22+
2. #### text rotation axis
23+
! [spin] (/img/gif/rotate_axis_value.gif)
624
* SmartChart is an Android chart framework that supports linear diagrams (broken lines, curves, scatter points) bar charts, area charts, pie charts, and 3D columnar diagrams to support a variety of configurations.
725
* [apk download url](/img/smartChart.apk)
826
## Function display
@@ -99,7 +117,7 @@ allprojects {
99117
> *Step 2. Add the dependency
100118
```gradle
101119
dependencies {
102-
compile 'com.github.huangyanbin:SmartChart:1.1'
120+
compile 'com.github.huangyanbin:SmartChart:1.4'
103121
}
104122
```
105123

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,17 @@
77

88
* [apk下载地址](/img/smartChart.apk)
99

10-
## 功能展示
1110

1211

13-
### 未来版本功能
14-
> 从实践看,还有很多需要开放更多功能。如果修改代码,可以满足几乎所有图表展示的功能。后面我将持续完善图表扩展内容。
12+
### 1.4 版本
13+
> 支持横向滚动,设置宽度比。
14+
> 提供更多案例
15+
> 后面将补充所有方法注释
1516
17+
![动画](/img/zuoping.jpg)
18+
19+
20+
![动画](/img/gif/tip.gif)
1621
### 1.2版本功能
1722

1823
#### 支持Tip和MarkView高度可定制化
@@ -124,7 +129,7 @@ allprojects {
124129
> *Step 2. Add the dependency
125130
```gradle
126131
dependencies {
127-
       compile 'com.github.huangyanbin:SmartChart:1.3.3'
132+
       compile 'com.github.huangyanbin:SmartChart:1.4'
128133
}
129134
```
130135

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<activity android:name=".Pie3DChartActivity"/>
3535
<activity android:name=".RotateActivity"/>
3636
<activity android:name=".CustomLineChartActivity"/>
37-
37+
<activity android:name=".TestChartActivity"/>
3838
</application>
3939

4040
</manifest>

app/src/main/java/com/bin/david/smartchart/AreaChartActivity.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.daivd.chart.data.style.PointStyle;
2525
import com.daivd.chart.listener.OnClickColumnListener;
2626
import com.daivd.chart.provider.component.mark.BubbleMarkView;
27+
import com.daivd.chart.provider.component.point.LegendPoint;
2728
import com.daivd.chart.provider.component.point.Point;
2829

2930
import java.util.ArrayList;
@@ -134,7 +135,7 @@ protected void onCreate(Bundle savedInstanceState) {
134135
levelLine.getLineStyle().setEffect(effects2);
135136
lineChart.getProvider().addLevelLine(levelLine);
136137
lineChart.getLegend().setDirection(IComponent.BOTTOM);
137-
Point legendPoint = (Point) lineChart.getLegend().getPoint();
138+
LegendPoint legendPoint = (LegendPoint) lineChart.getLegend().getPoint();
138139
PointStyle style = legendPoint.getPointStyle();
139140
style.setShape(PointStyle.CIRCLE);
140141
lineChart.getLegend().setPercent(0.2f);
@@ -442,7 +443,7 @@ private void showLegendStyle(ChartStyle c) {
442443

443444
@Override
444445
public void onItemClick(String s, int position) {
445-
Point legendPoint = (Point) lineChart.getLegend().getPoint();
446+
LegendPoint legendPoint = (LegendPoint) lineChart.getLegend().getPoint();
446447
PointStyle style = legendPoint.getPointStyle();
447448
if(position == 0){
448449
style.setShape(PointStyle.SQUARE);

app/src/main/java/com/bin/david/smartchart/Bar3DChartActivity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import com.daivd.chart.data.style.PointStyle;
1717
import com.daivd.chart.listener.OnClickColumnListener;
1818
import com.daivd.chart.provider.component.mark.BubbleMarkView;
19+
import com.daivd.chart.provider.component.point.LegendPoint;
1920
import com.daivd.chart.provider.component.point.Point;
2021

2122
import java.util.ArrayList;
@@ -72,7 +73,7 @@ protected void onCreate(Bundle savedInstanceState) {
7273
levelLine.getLineStyle().setWidth(this,1).setColor(res.getColor(R.color.arc23)).setEffect(effects);
7374
bar3DChart.getProvider().addLevelLine(levelLine);
7475
bar3DChart.getProvider().setMarkView(new BubbleMarkView(this));
75-
Point legendPoint = (Point) bar3DChart.getLegend().getPoint();
76+
LegendPoint legendPoint = (LegendPoint) bar3DChart.getLegend().getPoint();
7677
PointStyle style = legendPoint.getPointStyle();
7778
style.setShape(PointStyle.CIRCLE);
7879
BaseAxis vaxis = bar3DChart.getLeftVerticalAxis();

app/src/main/java/com/bin/david/smartchart/BarChartActivity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import com.daivd.chart.data.style.PointStyle;
1717
import com.daivd.chart.listener.OnClickColumnListener;
1818
import com.daivd.chart.provider.component.mark.BubbleMarkView;
19+
import com.daivd.chart.provider.component.point.LegendPoint;
1920
import com.daivd.chart.provider.component.point.Point;
2021

2122
import java.util.ArrayList;
@@ -73,7 +74,7 @@ protected void onCreate(Bundle savedInstanceState) {
7374
barChart.getProvider().addLevelLine(levelLine);
7475
barChart.getLeftVerticalAxis().getGridStyle().setEffect(effects);
7576
barChart.getProvider().setMarkView(new BubbleMarkView(this));
76-
Point legendPoint = (Point) barChart.getLegend().getPoint();
77+
LegendPoint legendPoint = (LegendPoint) barChart.getLegend().getPoint();
7778
PointStyle style = legendPoint.getPointStyle();
7879
style.setShape(PointStyle.CIRCLE);
7980
BaseAxis vaxis = barChart.getLeftVerticalAxis();

app/src/main/java/com/bin/david/smartchart/BarLineChartActivity.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.daivd.chart.provider.component.cross.DoubleDriCross;
2424
import com.daivd.chart.provider.component.level.LevelLine;
2525
import com.daivd.chart.provider.component.mark.BubbleMarkView;
26+
import com.daivd.chart.provider.component.point.LegendPoint;
2627
import com.daivd.chart.provider.component.point.Point;
2728

2829
import java.util.ArrayList;
@@ -112,7 +113,7 @@ protected void onCreate(Bundle savedInstanceState) {
112113
levelLine.getLineStyle().setEffect(effects2);
113114
barLineChart.getProvider().addLevelLine(levelLine);
114115
barLineChart.getLegend().setDirection(IComponent.BOTTOM);
115-
Point legendPoint = (Point)barLineChart.getLegend().getPoint();
116+
LegendPoint legendPoint = (LegendPoint) barLineChart.getLegend().getPoint();
116117
PointStyle style = legendPoint.getPointStyle();
117118
style.setShape(PointStyle.RECT);
118119
barLineChart.getLegend().setPercent(0.2f);
@@ -416,7 +417,7 @@ private void showLegendStyle(ChartStyle c) {
416417

417418
@Override
418419
public void onItemClick(String s, int position) {
419-
Point legendPoint = (Point)barLineChart.getLegend().getPoint();
420+
LegendPoint legendPoint = (LegendPoint) barLineChart.getLegend().getPoint();
420421
PointStyle style = legendPoint.getPointStyle();
421422
if(position == 0){
422423
style.setShape(PointStyle.SQUARE);

app/src/main/java/com/bin/david/smartchart/CustomLineChartActivity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.daivd.chart.listener.OnClickColumnListener;
2929
import com.daivd.chart.provider.component.cross.VerticalCross;
3030
import com.daivd.chart.provider.component.level.LevelLine;
31+
import com.daivd.chart.provider.component.point.LegendPoint;
3132
import com.daivd.chart.provider.component.point.Point;
3233
import com.daivd.chart.provider.component.tip.MultiLineBubbleTip;
3334
import com.daivd.chart.utils.DensityUtils;
@@ -151,7 +152,7 @@ public String[] format(LineData lineData, int position) {
151152
levelLine.getLineStyle().setEffect(effects2);
152153
lineChart.getProvider().addLevelLine(levelLine);
153154
lineChart.getLegend().setDirection(IComponent.BOTTOM);
154-
Point legendPoint = (Point)lineChart.getLegend().getPoint();
155+
LegendPoint legendPoint = (LegendPoint)lineChart.getLegend().getPoint();
155156
PointStyle style = legendPoint.getPointStyle();
156157
style.setShape(PointStyle.RECT);
157158
lineChart.getLegend().setPercent(0.2f);

app/src/main/java/com/bin/david/smartchart/LineChartActivity.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import com.daivd.chart.data.style.PointStyle;
3535
import com.daivd.chart.listener.OnClickColumnListener;
3636
import com.daivd.chart.provider.component.point.IPoint;
37+
import com.daivd.chart.provider.component.point.LegendPoint;
3738
import com.daivd.chart.provider.component.point.Point;
3839
import com.daivd.chart.provider.component.tip.MultiLineBubbleTip;
3940
import com.daivd.chart.utils.DensityUtils;
@@ -165,7 +166,7 @@ public String[] format(LineData lineData, int position) {
165166
levelLine.getLineStyle().setEffect(effects2);
166167
lineChart.getProvider().addLevelLine(levelLine);
167168
lineChart.getLegend().setDirection(IComponent.BOTTOM);
168-
Point legendPoint = (Point) lineChart.getLegend().getPoint();
169+
LegendPoint legendPoint = (LegendPoint) lineChart.getLegend().getPoint();
169170
PointStyle style = legendPoint.getPointStyle();
170171
style.setShape(PointStyle.RECT);
171172
lineChart.getLegend().setPercent(0.2f);
@@ -494,7 +495,7 @@ private void showLegendStyle(ChartStyle c) {
494495

495496
@Override
496497
public void onItemClick(String s, int position) {
497-
Point legendPoint = (Point) lineChart.getLegend().getPoint();
498+
LegendPoint legendPoint = (LegendPoint) lineChart.getLegend().getPoint();
498499
PointStyle style = legendPoint.getPointStyle();
499500
if (position == 0) {
500501
style.setShape(PointStyle.SQUARE);

app/src/main/java/com/bin/david/smartchart/MainActivity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ protected void onCreate(Bundle savedInstanceState) {
3535
items.add(new MainItem(RadarChartActivity.class,"Radar chart"));
3636
items.add(new MainItem(RoseChartActivity.class,"Rose chart"));
3737
items.add(new MainItem(BarLineChartActivity.class,"Bar line chart"));
38-
items.add(new MainItem(CustomLineChartActivity.class,"Custom line chart"));
38+
items.add(new MainItem(TestChartActivity.class,"Custom line chart1"));
39+
items.add(new MainItem(CustomLineChartActivity.class,"Custom line chart2"));
3940
items.add(new MainItem(ZoomChartListActivity.class,"scale chart List(Solving gesture conflict)"));
4041
items.add(new MainItem(RotateChartListActivity.class,"rotate chart List(Solving gesture conflict)"));
4142
itemAdapter = new ItemAdapter(items);

app/src/main/java/com/bin/david/smartchart/Pie3DChartActivity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.daivd.chart.data.style.PointStyle;
1414
import com.daivd.chart.listener.OnClickColumnListener;
1515
import com.daivd.chart.provider.component.mark.BubbleMarkView;
16+
import com.daivd.chart.provider.component.point.LegendPoint;
1617
import com.daivd.chart.provider.component.point.Point;
1718

1819
import java.util.ArrayList;
@@ -54,7 +55,7 @@ protected void onCreate(Bundle savedInstanceState) {
5455
fontStyle.setTextSpSize(this,15);
5556
pie3DChart.getProvider().setOpenMark(true);
5657
pie3DChart.getProvider().setMarkView(new BubbleMarkView(this));
57-
Point legendPoint = (Point) pie3DChart.getLegend().getPoint();
58+
LegendPoint legendPoint = (LegendPoint) pie3DChart.getLegend().getPoint();
5859
PointStyle style = legendPoint.getPointStyle();
5960
style.setShape(PointStyle.CIRCLE);
6061
pie3DChart.getLegend().setDirection(IComponent.TOP);

app/src/main/java/com/bin/david/smartchart/PieChartActivity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.daivd.chart.data.style.PointStyle;
1414
import com.daivd.chart.listener.OnClickColumnListener;
1515
import com.daivd.chart.provider.component.mark.BubbleMarkView;
16+
import com.daivd.chart.provider.component.point.LegendPoint;
1617
import com.daivd.chart.provider.component.point.Point;
1718

1819
import java.util.ArrayList;
@@ -54,7 +55,7 @@ protected void onCreate(Bundle savedInstanceState) {
5455
fontStyle.setTextSpSize(this,15);
5556
pieChart.getProvider().setOpenMark(true);
5657
pieChart.getProvider().setMarkView(new BubbleMarkView(this));
57-
Point legendPoint = (Point)pieChart.getLegend().getPoint();
58+
LegendPoint legendPoint = (LegendPoint)pieChart.getLegend().getPoint();
5859
PointStyle style = legendPoint.getPointStyle();
5960
style.setShape(PointStyle.CIRCLE);
6061
pieChart.getLegend().setDirection(IComponent.TOP);

app/src/main/java/com/bin/david/smartchart/RadarChartActivity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.daivd.chart.data.style.FontStyle;
1212
import com.daivd.chart.data.style.PointStyle;
1313
import com.daivd.chart.provider.component.mark.BubbleMarkView;
14+
import com.daivd.chart.provider.component.point.LegendPoint;
1415
import com.daivd.chart.provider.component.point.Point;
1516

1617
import java.util.ArrayList;
@@ -70,7 +71,7 @@ protected void onCreate(Bundle savedInstanceState) {
7071
//设置标题样式
7172
radarChart.getChartTitle().getFontStyle().setTextColor(res.getColor(R.color.arc23));
7273
radarChart.getLegend().setDirection(IComponent.BOTTOM);
73-
Point point = (Point)radarChart.getLegend().getPoint();
74+
LegendPoint point = (LegendPoint)radarChart.getLegend().getPoint();
7475
point.getPointStyle().setShape(PointStyle.SQUARE);
7576
radarChart.getLegend().setPercent(0.2f);
7677
radarChart.setChartData(chartData2);

app/src/main/java/com/bin/david/smartchart/RoseChartActivity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.daivd.chart.data.style.FontStyle;
1313
import com.daivd.chart.data.style.PointStyle;
1414
import com.daivd.chart.provider.component.mark.BubbleMarkView;
15+
import com.daivd.chart.provider.component.point.LegendPoint;
1516
import com.daivd.chart.provider.component.point.Point;
1617

1718
import java.util.ArrayList;
@@ -78,7 +79,7 @@ protected void onCreate(Bundle savedInstanceState) {
7879
fontStyle.setTextColor(res.getColor(R.color.arc23));
7980
fontStyle.setTextSpSize(this,16);
8081
roseChart.getLegend().setDirection(IComponent.BOTTOM);
81-
Point legendPoint = (Point)roseChart.getLegend().getPoint();
82+
LegendPoint legendPoint = (LegendPoint)roseChart.getLegend().getPoint();
8283
PointStyle style = legendPoint.getPointStyle();
8384
style.setShape(PointStyle.SQUARE);
8485
roseChart.getLegend().setPercent(0.2f);

app/src/main/java/com/bin/david/smartchart/ScatterChartActivity.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.daivd.chart.data.style.LineStyle;
2424
import com.daivd.chart.data.style.PointStyle;
2525
import com.daivd.chart.provider.component.mark.BubbleMarkView;
26+
import com.daivd.chart.provider.component.point.LegendPoint;
2627
import com.daivd.chart.provider.component.point.Point;
2728

2829
import java.util.ArrayList;
@@ -123,7 +124,7 @@ protected void onCreate(Bundle savedInstanceState) {
123124
levelLine.getLineStyle().setEffect(effects2);
124125
lineChart.getProvider().addLevelLine(levelLine);
125126
lineChart.getLegend().setDirection(IComponent.BOTTOM);
126-
Point legendPoint = (Point)lineChart.getLegend().getPoint();
127+
LegendPoint legendPoint = (LegendPoint)lineChart.getLegend().getPoint();
127128
PointStyle style = legendPoint.getPointStyle();
128129
style.setShape(PointStyle.RECT);
129130
lineChart.getLegend().setPercent(0.2f);
@@ -439,7 +440,7 @@ private void showLegendStyle(ChartStyle c) {
439440

440441
@Override
441442
public void onItemClick(String s, int position) {
442-
Point legendPoint = (Point) lineChart.getLegend().getPoint();
443+
LegendPoint legendPoint = (LegendPoint) lineChart.getLegend().getPoint();
443444
PointStyle style = legendPoint.getPointStyle();
444445
if(position == 0){
445446
style.setShape(PointStyle.SQUARE);
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.bin.david.smartchart;
2+
3+
import android.os.Bundle;
4+
import android.support.v7.app.AppCompatActivity;
5+
6+
import com.bin.david.smartchart.helper.DrawHelper;
7+
import com.daivd.chart.core.LineChart;
8+
9+
10+
public class TestChartActivity extends AppCompatActivity {
11+
12+
13+
LineChart lineChart2;
14+
LineChart lineChart;
15+
LineChart lineChart3;
16+
LineChart lineChart4;
17+
LineChart lineChart5;
18+
LineChart lineChart6;
19+
20+
21+
@Override
22+
protected void onCreate(Bundle savedInstanceState) {
23+
super.onCreate(savedInstanceState);
24+
setContentView(R.layout.activity_test);
25+
lineChart = (LineChart) findViewById(R.id.lineChart);
26+
lineChart2 = (LineChart) findViewById(R.id.lineChart2);
27+
lineChart3= (LineChart) findViewById(R.id.lineChart3);
28+
lineChart4 = (LineChart) findViewById(R.id.lineChart4);
29+
lineChart5 = (LineChart) findViewById(R.id.lineChart5);
30+
lineChart6 = (LineChart) findViewById(R.id.lineChart6);
31+
DrawHelper.drawWeatherChart(this, lineChart);
32+
DrawHelper.drawFrozenSoilChart(this, lineChart2);
33+
DrawHelper.drawGroundTempChart(this, lineChart3);
34+
DrawHelper.drawFactorChart(this, lineChart4);
35+
DrawHelper.drawSoilChart(this, lineChart5);
36+
DrawHelper.drawHomeWeatherChart(this,lineChart6);
37+
}
38+
}

app/src/main/java/com/bin/david/smartchart/adapter/RotateChartListAdapter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.daivd.chart.data.style.FontStyle;
1414
import com.daivd.chart.data.style.PointStyle;
1515
import com.daivd.chart.provider.component.mark.BubbleMarkView;
16+
import com.daivd.chart.provider.component.point.LegendPoint;
1617
import com.daivd.chart.provider.component.point.Point;
1718

1819
import java.util.ArrayList;
@@ -61,7 +62,7 @@ protected void convert(BaseViewHolder helper, String item) {
6162
fontStyle.setTextSpSize(mContext,15);
6263
pieChart.getProvider().setOpenMark(true);
6364
pieChart.getProvider().setMarkView(new BubbleMarkView(mContext));
64-
Point legendPoint = (Point) pieChart.getLegend().getPoint();
65+
LegendPoint legendPoint = (LegendPoint) pieChart.getLegend().getPoint();
6566
PointStyle style = legendPoint.getPointStyle();
6667
style.setShape(PointStyle.CIRCLE);
6768
pieChart.getLegend().setDirection(IComponent.TOP);

app/src/main/java/com/bin/david/smartchart/adapter/ZoomChartListAdapter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.daivd.chart.data.style.LineStyle;
2222
import com.daivd.chart.data.style.PointStyle;
2323
import com.daivd.chart.provider.component.mark.BubbleMarkView;
24+
import com.daivd.chart.provider.component.point.LegendPoint;
2425
import com.daivd.chart.provider.component.point.Point;
2526

2627
import java.util.ArrayList;
@@ -119,7 +120,7 @@ protected void convert(BaseViewHolder helper, String item) {
119120
levelLine.getLineStyle().setEffect(effects2);
120121
lineChart.getProvider().addLevelLine(levelLine);
121122
lineChart.getLegend().setDirection(IComponent.BOTTOM);
122-
Point legendPoint = (Point) lineChart.getLegend().getPoint();
123+
LegendPoint legendPoint = (LegendPoint) lineChart.getLegend().getPoint();
123124
PointStyle style = legendPoint.getPointStyle();
124125
style.setShape(PointStyle.RECT);
125126
lineChart.getLegend().setPercent(0.2f);

0 commit comments

Comments
 (0)