Skip to content

Commit

Permalink
增加横向滚动,支持更多自定义图表,提供案例
Browse files Browse the repository at this point in the history
  • Loading branch information
huangyanbin committed Dec 13, 2017
1 parent f3f1dd6 commit 9bc999a
Show file tree
Hide file tree
Showing 65 changed files with 1,758 additions and 280 deletions.
20 changes: 19 additions & 1 deletion README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,25 @@

------
* [Chinese README](/README.md/)
### version 1.4
> support horizontal rolling and set width ratio.
> to provide more cases
>
! [animation] (/img/zuoping.jpg)


! [animation] (/img/gif/tip.gif)
### version 1.2 features

#### supports Tip and MarkView is highly customizable
! [animation] (/img/gif/tip.gif)

### version 1.1 features

#### 1. ViewPager and a list of gestures to solve the conflict
! [gesture conflict] (/img/gif/viewpager.gif)
2. #### text rotation axis
! [spin] (/img/gif/rotate_axis_value.gif)
* 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.
* [apk download url](/img/smartChart.apk)
## Function display
Expand Down Expand Up @@ -99,7 +117,7 @@ allprojects {
> *Step 2. Add the dependency
```gradle
dependencies {
compile 'com.github.huangyanbin:SmartChart:1.1'
compile 'com.github.huangyanbin:SmartChart:1.4'
}
```

Expand Down
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@

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

## 功能展示


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


![动画](/img/gif/tip.gif)
### 1.2版本功能

#### 支持Tip和MarkView高度可定制化
Expand Down Expand Up @@ -124,7 +129,7 @@ allprojects {
> *Step 2. Add the dependency
```gradle
dependencies {
       compile 'com.github.huangyanbin:SmartChart:1.3.3'
       compile 'com.github.huangyanbin:SmartChart:1.4'
}
```

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<activity android:name=".Pie3DChartActivity"/>
<activity android:name=".RotateActivity"/>
<activity android:name=".CustomLineChartActivity"/>

<activity android:name=".TestChartActivity"/>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.daivd.chart.data.style.PointStyle;
import com.daivd.chart.listener.OnClickColumnListener;
import com.daivd.chart.provider.component.mark.BubbleMarkView;
import com.daivd.chart.provider.component.point.LegendPoint;
import com.daivd.chart.provider.component.point.Point;

import java.util.ArrayList;
Expand Down Expand Up @@ -134,7 +135,7 @@ protected void onCreate(Bundle savedInstanceState) {
levelLine.getLineStyle().setEffect(effects2);
lineChart.getProvider().addLevelLine(levelLine);
lineChart.getLegend().setDirection(IComponent.BOTTOM);
Point legendPoint = (Point) lineChart.getLegend().getPoint();
LegendPoint legendPoint = (LegendPoint) lineChart.getLegend().getPoint();
PointStyle style = legendPoint.getPointStyle();
style.setShape(PointStyle.CIRCLE);
lineChart.getLegend().setPercent(0.2f);
Expand Down Expand Up @@ -442,7 +443,7 @@ private void showLegendStyle(ChartStyle c) {

@Override
public void onItemClick(String s, int position) {
Point legendPoint = (Point) lineChart.getLegend().getPoint();
LegendPoint legendPoint = (LegendPoint) lineChart.getLegend().getPoint();
PointStyle style = legendPoint.getPointStyle();
if(position == 0){
style.setShape(PointStyle.SQUARE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.daivd.chart.data.style.PointStyle;
import com.daivd.chart.listener.OnClickColumnListener;
import com.daivd.chart.provider.component.mark.BubbleMarkView;
import com.daivd.chart.provider.component.point.LegendPoint;
import com.daivd.chart.provider.component.point.Point;

import java.util.ArrayList;
Expand Down Expand Up @@ -72,7 +73,7 @@ protected void onCreate(Bundle savedInstanceState) {
levelLine.getLineStyle().setWidth(this,1).setColor(res.getColor(R.color.arc23)).setEffect(effects);
bar3DChart.getProvider().addLevelLine(levelLine);
bar3DChart.getProvider().setMarkView(new BubbleMarkView(this));
Point legendPoint = (Point) bar3DChart.getLegend().getPoint();
LegendPoint legendPoint = (LegendPoint) bar3DChart.getLegend().getPoint();
PointStyle style = legendPoint.getPointStyle();
style.setShape(PointStyle.CIRCLE);
BaseAxis vaxis = bar3DChart.getLeftVerticalAxis();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.daivd.chart.data.style.PointStyle;
import com.daivd.chart.listener.OnClickColumnListener;
import com.daivd.chart.provider.component.mark.BubbleMarkView;
import com.daivd.chart.provider.component.point.LegendPoint;
import com.daivd.chart.provider.component.point.Point;

import java.util.ArrayList;
Expand Down Expand Up @@ -73,7 +74,7 @@ protected void onCreate(Bundle savedInstanceState) {
barChart.getProvider().addLevelLine(levelLine);
barChart.getLeftVerticalAxis().getGridStyle().setEffect(effects);
barChart.getProvider().setMarkView(new BubbleMarkView(this));
Point legendPoint = (Point) barChart.getLegend().getPoint();
LegendPoint legendPoint = (LegendPoint) barChart.getLegend().getPoint();
PointStyle style = legendPoint.getPointStyle();
style.setShape(PointStyle.CIRCLE);
BaseAxis vaxis = barChart.getLeftVerticalAxis();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.daivd.chart.provider.component.cross.DoubleDriCross;
import com.daivd.chart.provider.component.level.LevelLine;
import com.daivd.chart.provider.component.mark.BubbleMarkView;
import com.daivd.chart.provider.component.point.LegendPoint;
import com.daivd.chart.provider.component.point.Point;

import java.util.ArrayList;
Expand Down Expand Up @@ -112,7 +113,7 @@ protected void onCreate(Bundle savedInstanceState) {
levelLine.getLineStyle().setEffect(effects2);
barLineChart.getProvider().addLevelLine(levelLine);
barLineChart.getLegend().setDirection(IComponent.BOTTOM);
Point legendPoint = (Point)barLineChart.getLegend().getPoint();
LegendPoint legendPoint = (LegendPoint) barLineChart.getLegend().getPoint();
PointStyle style = legendPoint.getPointStyle();
style.setShape(PointStyle.RECT);
barLineChart.getLegend().setPercent(0.2f);
Expand Down Expand Up @@ -416,7 +417,7 @@ private void showLegendStyle(ChartStyle c) {

@Override
public void onItemClick(String s, int position) {
Point legendPoint = (Point)barLineChart.getLegend().getPoint();
LegendPoint legendPoint = (LegendPoint) barLineChart.getLegend().getPoint();
PointStyle style = legendPoint.getPointStyle();
if(position == 0){
style.setShape(PointStyle.SQUARE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.daivd.chart.listener.OnClickColumnListener;
import com.daivd.chart.provider.component.cross.VerticalCross;
import com.daivd.chart.provider.component.level.LevelLine;
import com.daivd.chart.provider.component.point.LegendPoint;
import com.daivd.chart.provider.component.point.Point;
import com.daivd.chart.provider.component.tip.MultiLineBubbleTip;
import com.daivd.chart.utils.DensityUtils;
Expand Down Expand Up @@ -151,7 +152,7 @@ public String[] format(LineData lineData, int position) {
levelLine.getLineStyle().setEffect(effects2);
lineChart.getProvider().addLevelLine(levelLine);
lineChart.getLegend().setDirection(IComponent.BOTTOM);
Point legendPoint = (Point)lineChart.getLegend().getPoint();
LegendPoint legendPoint = (LegendPoint)lineChart.getLegend().getPoint();
PointStyle style = legendPoint.getPointStyle();
style.setShape(PointStyle.RECT);
lineChart.getLegend().setPercent(0.2f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.daivd.chart.data.style.PointStyle;
import com.daivd.chart.listener.OnClickColumnListener;
import com.daivd.chart.provider.component.point.IPoint;
import com.daivd.chart.provider.component.point.LegendPoint;
import com.daivd.chart.provider.component.point.Point;
import com.daivd.chart.provider.component.tip.MultiLineBubbleTip;
import com.daivd.chart.utils.DensityUtils;
Expand Down Expand Up @@ -165,7 +166,7 @@ public String[] format(LineData lineData, int position) {
levelLine.getLineStyle().setEffect(effects2);
lineChart.getProvider().addLevelLine(levelLine);
lineChart.getLegend().setDirection(IComponent.BOTTOM);
Point legendPoint = (Point) lineChart.getLegend().getPoint();
LegendPoint legendPoint = (LegendPoint) lineChart.getLegend().getPoint();
PointStyle style = legendPoint.getPointStyle();
style.setShape(PointStyle.RECT);
lineChart.getLegend().setPercent(0.2f);
Expand Down Expand Up @@ -494,7 +495,7 @@ private void showLegendStyle(ChartStyle c) {

@Override
public void onItemClick(String s, int position) {
Point legendPoint = (Point) lineChart.getLegend().getPoint();
LegendPoint legendPoint = (LegendPoint) lineChart.getLegend().getPoint();
PointStyle style = legendPoint.getPointStyle();
if (position == 0) {
style.setShape(PointStyle.SQUARE);
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/bin/david/smartchart/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ protected void onCreate(Bundle savedInstanceState) {
items.add(new MainItem(RadarChartActivity.class,"Radar chart"));
items.add(new MainItem(RoseChartActivity.class,"Rose chart"));
items.add(new MainItem(BarLineChartActivity.class,"Bar line chart"));
items.add(new MainItem(CustomLineChartActivity.class,"Custom line chart"));
items.add(new MainItem(TestChartActivity.class,"Custom line chart1"));
items.add(new MainItem(CustomLineChartActivity.class,"Custom line chart2"));
items.add(new MainItem(ZoomChartListActivity.class,"scale chart List(Solving gesture conflict)"));
items.add(new MainItem(RotateChartListActivity.class,"rotate chart List(Solving gesture conflict)"));
itemAdapter = new ItemAdapter(items);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.daivd.chart.data.style.PointStyle;
import com.daivd.chart.listener.OnClickColumnListener;
import com.daivd.chart.provider.component.mark.BubbleMarkView;
import com.daivd.chart.provider.component.point.LegendPoint;
import com.daivd.chart.provider.component.point.Point;

import java.util.ArrayList;
Expand Down Expand Up @@ -54,7 +55,7 @@ protected void onCreate(Bundle savedInstanceState) {
fontStyle.setTextSpSize(this,15);
pie3DChart.getProvider().setOpenMark(true);
pie3DChart.getProvider().setMarkView(new BubbleMarkView(this));
Point legendPoint = (Point) pie3DChart.getLegend().getPoint();
LegendPoint legendPoint = (LegendPoint) pie3DChart.getLegend().getPoint();
PointStyle style = legendPoint.getPointStyle();
style.setShape(PointStyle.CIRCLE);
pie3DChart.getLegend().setDirection(IComponent.TOP);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.daivd.chart.data.style.PointStyle;
import com.daivd.chart.listener.OnClickColumnListener;
import com.daivd.chart.provider.component.mark.BubbleMarkView;
import com.daivd.chart.provider.component.point.LegendPoint;
import com.daivd.chart.provider.component.point.Point;

import java.util.ArrayList;
Expand Down Expand Up @@ -54,7 +55,7 @@ protected void onCreate(Bundle savedInstanceState) {
fontStyle.setTextSpSize(this,15);
pieChart.getProvider().setOpenMark(true);
pieChart.getProvider().setMarkView(new BubbleMarkView(this));
Point legendPoint = (Point)pieChart.getLegend().getPoint();
LegendPoint legendPoint = (LegendPoint)pieChart.getLegend().getPoint();
PointStyle style = legendPoint.getPointStyle();
style.setShape(PointStyle.CIRCLE);
pieChart.getLegend().setDirection(IComponent.TOP);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.daivd.chart.data.style.FontStyle;
import com.daivd.chart.data.style.PointStyle;
import com.daivd.chart.provider.component.mark.BubbleMarkView;
import com.daivd.chart.provider.component.point.LegendPoint;
import com.daivd.chart.provider.component.point.Point;

import java.util.ArrayList;
Expand Down Expand Up @@ -70,7 +71,7 @@ protected void onCreate(Bundle savedInstanceState) {
//设置标题样式
radarChart.getChartTitle().getFontStyle().setTextColor(res.getColor(R.color.arc23));
radarChart.getLegend().setDirection(IComponent.BOTTOM);
Point point = (Point)radarChart.getLegend().getPoint();
LegendPoint point = (LegendPoint)radarChart.getLegend().getPoint();
point.getPointStyle().setShape(PointStyle.SQUARE);
radarChart.getLegend().setPercent(0.2f);
radarChart.setChartData(chartData2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.daivd.chart.data.style.FontStyle;
import com.daivd.chart.data.style.PointStyle;
import com.daivd.chart.provider.component.mark.BubbleMarkView;
import com.daivd.chart.provider.component.point.LegendPoint;
import com.daivd.chart.provider.component.point.Point;

import java.util.ArrayList;
Expand Down Expand Up @@ -78,7 +79,7 @@ protected void onCreate(Bundle savedInstanceState) {
fontStyle.setTextColor(res.getColor(R.color.arc23));
fontStyle.setTextSpSize(this,16);
roseChart.getLegend().setDirection(IComponent.BOTTOM);
Point legendPoint = (Point)roseChart.getLegend().getPoint();
LegendPoint legendPoint = (LegendPoint)roseChart.getLegend().getPoint();
PointStyle style = legendPoint.getPointStyle();
style.setShape(PointStyle.SQUARE);
roseChart.getLegend().setPercent(0.2f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.daivd.chart.data.style.LineStyle;
import com.daivd.chart.data.style.PointStyle;
import com.daivd.chart.provider.component.mark.BubbleMarkView;
import com.daivd.chart.provider.component.point.LegendPoint;
import com.daivd.chart.provider.component.point.Point;

import java.util.ArrayList;
Expand Down Expand Up @@ -123,7 +124,7 @@ protected void onCreate(Bundle savedInstanceState) {
levelLine.getLineStyle().setEffect(effects2);
lineChart.getProvider().addLevelLine(levelLine);
lineChart.getLegend().setDirection(IComponent.BOTTOM);
Point legendPoint = (Point)lineChart.getLegend().getPoint();
LegendPoint legendPoint = (LegendPoint)lineChart.getLegend().getPoint();
PointStyle style = legendPoint.getPointStyle();
style.setShape(PointStyle.RECT);
lineChart.getLegend().setPercent(0.2f);
Expand Down Expand Up @@ -439,7 +440,7 @@ private void showLegendStyle(ChartStyle c) {

@Override
public void onItemClick(String s, int position) {
Point legendPoint = (Point) lineChart.getLegend().getPoint();
LegendPoint legendPoint = (LegendPoint) lineChart.getLegend().getPoint();
PointStyle style = legendPoint.getPointStyle();
if(position == 0){
style.setShape(PointStyle.SQUARE);
Expand Down
38 changes: 38 additions & 0 deletions app/src/main/java/com/bin/david/smartchart/TestChartActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.bin.david.smartchart;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.bin.david.smartchart.helper.DrawHelper;
import com.daivd.chart.core.LineChart;


public class TestChartActivity extends AppCompatActivity {


LineChart lineChart2;
LineChart lineChart;
LineChart lineChart3;
LineChart lineChart4;
LineChart lineChart5;
LineChart lineChart6;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
lineChart = (LineChart) findViewById(R.id.lineChart);
lineChart2 = (LineChart) findViewById(R.id.lineChart2);
lineChart3= (LineChart) findViewById(R.id.lineChart3);
lineChart4 = (LineChart) findViewById(R.id.lineChart4);
lineChart5 = (LineChart) findViewById(R.id.lineChart5);
lineChart6 = (LineChart) findViewById(R.id.lineChart6);
DrawHelper.drawWeatherChart(this, lineChart);
DrawHelper.drawFrozenSoilChart(this, lineChart2);
DrawHelper.drawGroundTempChart(this, lineChart3);
DrawHelper.drawFactorChart(this, lineChart4);
DrawHelper.drawSoilChart(this, lineChart5);
DrawHelper.drawHomeWeatherChart(this,lineChart6);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.daivd.chart.data.style.FontStyle;
import com.daivd.chart.data.style.PointStyle;
import com.daivd.chart.provider.component.mark.BubbleMarkView;
import com.daivd.chart.provider.component.point.LegendPoint;
import com.daivd.chart.provider.component.point.Point;

import java.util.ArrayList;
Expand Down Expand Up @@ -61,7 +62,7 @@ protected void convert(BaseViewHolder helper, String item) {
fontStyle.setTextSpSize(mContext,15);
pieChart.getProvider().setOpenMark(true);
pieChart.getProvider().setMarkView(new BubbleMarkView(mContext));
Point legendPoint = (Point) pieChart.getLegend().getPoint();
LegendPoint legendPoint = (LegendPoint) pieChart.getLegend().getPoint();
PointStyle style = legendPoint.getPointStyle();
style.setShape(PointStyle.CIRCLE);
pieChart.getLegend().setDirection(IComponent.TOP);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.daivd.chart.data.style.LineStyle;
import com.daivd.chart.data.style.PointStyle;
import com.daivd.chart.provider.component.mark.BubbleMarkView;
import com.daivd.chart.provider.component.point.LegendPoint;
import com.daivd.chart.provider.component.point.Point;

import java.util.ArrayList;
Expand Down Expand Up @@ -119,7 +120,7 @@ protected void convert(BaseViewHolder helper, String item) {
levelLine.getLineStyle().setEffect(effects2);
lineChart.getProvider().addLevelLine(levelLine);
lineChart.getLegend().setDirection(IComponent.BOTTOM);
Point legendPoint = (Point) lineChart.getLegend().getPoint();
LegendPoint legendPoint = (LegendPoint) lineChart.getLegend().getPoint();
PointStyle style = legendPoint.getPointStyle();
style.setShape(PointStyle.RECT);
lineChart.getLegend().setPercent(0.2f);
Expand Down
Loading

0 comments on commit 9bc999a

Please sign in to comment.