Skip to content

Commit bc959ac

Browse files
committed
提供滚动监听
1 parent 231a56e commit bc959ac

File tree

7 files changed

+160
-1
lines changed

7 files changed

+160
-1
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99

1010
## 功能展示
1111

12+
![作品](/img/zuoping.jpg)
13+
### 未来版本功能
14+
> 从实践看,还有很多需要开放更多功能。如果修改代码,可以满足几乎所有图表展示的功能。后面我将持续完善图表扩展内容。
15+
1216
### 1.2版本功能
1317

1418
#### 支持Tip和MarkView高度可定制化

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.Manifest;
44
import android.content.pm.PackageManager;
55
import android.content.res.Resources;
6+
import android.graphics.Canvas;
67
import android.graphics.Color;
78
import android.graphics.DashPathEffect;
89
import android.graphics.Paint;
@@ -32,6 +33,7 @@
3233
import com.daivd.chart.data.style.LineStyle;
3334
import com.daivd.chart.data.style.PointStyle;
3435
import com.daivd.chart.listener.OnClickColumnListener;
36+
import com.daivd.chart.provider.component.point.IPoint;
3537
import com.daivd.chart.provider.component.point.Point;
3638
import com.daivd.chart.provider.component.tip.MultiLineBubbleTip;
3739
import com.daivd.chart.utils.DensityUtils;
@@ -166,6 +168,7 @@ public void onClickColumn(LineData lineData, int position) {
166168
});
167169

168170

171+
169172
}
170173

171174
public void onClick(View view) {
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package com.bin.david.smartchart.weather;
2+
3+
/**
4+
* Created by huang on 2017/11/30.
5+
*/
6+
7+
public class WeatherBean {
8+
9+
private String date;
10+
private String week;
11+
private String fristWeather;
12+
private String lastWeather;
13+
private String wind;
14+
private String hightTemp;
15+
private String lowTemp;
16+
17+
public String getDate() {
18+
return date;
19+
}
20+
21+
public void setDate(String date) {
22+
this.date = date;
23+
}
24+
25+
public String getWeek() {
26+
return week;
27+
}
28+
29+
public void setWeek(String week) {
30+
this.week = week;
31+
}
32+
33+
public String getFristWeather() {
34+
return fristWeather;
35+
}
36+
37+
public void setFristWeather(String fristWeather) {
38+
this.fristWeather = fristWeather;
39+
}
40+
41+
public String getLastWeather() {
42+
return lastWeather;
43+
}
44+
45+
public void setLastWeather(String lastWeather) {
46+
this.lastWeather = lastWeather;
47+
}
48+
49+
public String getWind() {
50+
return wind;
51+
}
52+
53+
public void setWind(String wind) {
54+
this.wind = wind;
55+
}
56+
57+
public String getHightTemp() {
58+
return hightTemp;
59+
}
60+
61+
public void setHightTemp(String hightTemp) {
62+
this.hightTemp = hightTemp;
63+
}
64+
65+
public String getLowTemp() {
66+
return lowTemp;
67+
}
68+
69+
public void setLowTemp(String lowTemp) {
70+
this.lowTemp = lowTemp;
71+
}
72+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package com.bin.david.smartchart.weather;
2+
3+
import android.content.Context;
4+
import android.content.res.TypedArray;
5+
import android.graphics.Canvas;
6+
7+
import android.support.annotation.Nullable;
8+
import android.util.AttributeSet;
9+
import android.widget.LinearLayout;
10+
11+
import com.bin.david.smartchart.R;
12+
import com.daivd.chart.utils.DensityUtils;
13+
14+
15+
/**
16+
* Created by huang on 2017/11/30.
17+
*/
18+
19+
public class WeatherView extends LinearLayout {
20+
21+
private int columnWidth;
22+
private int columnSize;
23+
private int width;
24+
private int height;
25+
26+
27+
public WeatherView(Context context, @Nullable AttributeSet attrs) {
28+
super(context, attrs);
29+
init(context,attrs);
30+
}
31+
32+
public WeatherView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
33+
super(context, attrs, defStyleAttr);
34+
init(context,attrs);
35+
}
36+
37+
38+
39+
private void init(Context context, @Nullable AttributeSet attrs){
40+
41+
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.weatherView);
42+
columnWidth = (int) a.getDimension(R.styleable.weatherView_weatherColumnWidth,
43+
DensityUtils.dp2px(context,50));
44+
columnSize = a.getInt(R.styleable.weatherView_weatherColumnCount, 7);
45+
a.recycle();
46+
}
47+
48+
@Override
49+
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
50+
super.onSizeChanged(w, h, oldw, oldh);
51+
width = w;
52+
height = h;
53+
}
54+
55+
@Override
56+
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
57+
int width= MeasureSpec.getSize(widthMeasureSpec);
58+
int height = columnWidth *columnSize;
59+
setMeasuredDimension(width, height);
60+
}
61+
62+
@Override
63+
protected void onDraw(Canvas canvas) {
64+
super.onDraw(canvas);
65+
66+
67+
}
68+
69+
70+
71+
72+
}

app/src/main/res/layout/activity_line.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<com.daivd.chart.core.LineChart
1111

1212
android:id="@+id/lineChart"
13-
android:layout_width="match_parent"
13+
android:layout_width="2000dp"
1414
android:background="#f4f4f4"
1515
android:layout_height="400dp"/>
1616

app/src/main/res/values/attrs.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<declare-styleable name="weatherView">
4+
<attr name="weatherColumnWidth" format="dimension"/>
5+
<attr name="weatherColumnCount" format="integer"/>
6+
</declare-styleable>
7+
8+
</resources>

img/zuoping.jpg

167 KB
Loading

0 commit comments

Comments
 (0)