Commit 4d51724ee8a7d52f29303e9a63c34122eeab9b73
1 parent
b45abd57
Exists in
yxb_dev
and in
2 other branches
no message
Showing
10 changed files
with
108 additions
and
87 deletions
Show diff stats
.idea/modules.xml
... | ... | @@ -4,8 +4,8 @@ |
4 | 4 | <modules> |
5 | 5 | <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" /> |
6 | 6 | <module fileurl="file://$PROJECT_DIR$/mvpsdk/mvpsdk.iml" filepath="$PROJECT_DIR$/mvpsdk/mvpsdk.iml" /> |
7 | - <module fileurl="file://E:\parentwork\parentWorkHolper.iml" filepath="E:\parentwork\parentWorkHolper.iml" /> | |
8 | 7 | <module fileurl="file://F:\parentwork\parentWorkHolper.iml" filepath="F:\parentwork\parentWorkHolper.iml" /> |
8 | + <module fileurl="file://E:\parentwork\parentWorkHolper.iml" filepath="E:\parentwork\parentWorkHolper.iml" /> | |
9 | 9 | <module fileurl="file://$PROJECT_DIR$/parentwork.iml" filepath="$PROJECT_DIR$/parentwork.iml" /> |
10 | 10 | <module fileurl="file://F:\parentWorkHolper\parentwork.iml" filepath="F:\parentWorkHolper\parentwork.iml" /> |
11 | 11 | <module fileurl="file://$PROJECT_DIR$/processor/processor.iml" filepath="$PROJECT_DIR$/processor/processor.iml" /> | ... | ... |
app/libs/processor.jar
No preview for this file type
app/src/main/java/com/shunzhi/parent/ui/activity/report/ReportSceneActivity.java
... | ... | @@ -20,9 +20,9 @@ import com.shunzhi.parent.ui.fragment.report.ReportSceneFragment; |
20 | 20 | */ |
21 | 21 | |
22 | 22 | public class ReportSceneActivity extends BaseMVPCompatActivity implements View.OnClickListener { |
23 | - public static void getInstance(Context context,int screenID) { | |
23 | + public static void getInstance(Context context,int sceneID) { | |
24 | 24 | Intent intent = new Intent(context, ReportSceneActivity.class); |
25 | - intent.putExtra("screenID",screenID); | |
25 | + intent.putExtra("sceneID",sceneID); | |
26 | 26 | context.startActivity(intent); |
27 | 27 | } |
28 | 28 | |
... | ... | @@ -54,9 +54,9 @@ public class ReportSceneActivity extends BaseMVPCompatActivity implements View.O |
54 | 54 | center_title = findViewById(R.id.center_title); |
55 | 55 | center_title.setText("场景详情"); |
56 | 56 | ivBack.setOnClickListener(this); |
57 | - int screenID = getIntent().getIntExtra("screenID",0); | |
57 | + int sceneID = getIntent().getIntExtra("sceneID",0); | |
58 | 58 | Bundle bundle=new Bundle(); |
59 | - bundle.putInt("screenID",screenID); | |
59 | + bundle.putInt("sceneID",sceneID); | |
60 | 60 | reportSceneFragment.setArguments(bundle); |
61 | 61 | fragmentTransaction = getSupportFragmentManager().beginTransaction(); |
62 | 62 | fragmentTransaction.add(R.id.frame_scene, reportSceneFragment) | ... | ... |
app/src/main/java/com/shunzhi/parent/ui/fragment/ReportFragment.java
... | ... | @@ -4,33 +4,20 @@ package com.shunzhi.parent.ui.fragment; |
4 | 4 | import android.os.Bundle; |
5 | 5 | import android.os.Handler; |
6 | 6 | import android.os.Message; |
7 | -import android.support.annotation.NonNull; | |
8 | 7 | import android.support.annotation.Nullable; |
9 | 8 | import android.support.design.widget.TabLayout; |
10 | 9 | import android.support.v4.app.Fragment; |
11 | 10 | import android.support.v4.app.FragmentManager; |
12 | 11 | import android.support.v4.app.FragmentPagerAdapter; |
13 | 12 | import android.support.v4.view.ViewPager; |
14 | -import android.support.v7.widget.LinearLayoutManager; | |
15 | -import android.support.v7.widget.RecyclerView; | |
16 | 13 | import android.view.View; |
17 | 14 | import android.widget.TextView; |
18 | 15 | |
19 | -import com.amy.monthweek.materialcalendarview.MonthWeekMaterialCalendarView; | |
20 | -import com.prolificinteractive.materialcalendarview.CalendarDay; | |
21 | -import com.prolificinteractive.materialcalendarview.MaterialCalendarView; | |
22 | -import com.share.mvpsdk.base.BasePresenter; | |
23 | 16 | import com.share.mvpsdk.base.fragment.BaseCompatFragment; |
24 | -import com.share.mvpsdk.base.fragment.BaseMVPCompatFragment; | |
25 | -import com.share.mvpsdk.utils.ToastUtils; | |
26 | 17 | import com.shunzhi.parent.R; |
27 | -import com.shunzhi.parent.adapter.ReportAdapter; | |
28 | -import com.shunzhi.parent.bean.ReportBean; | |
29 | -import com.shunzhi.parent.contract.report.ReportContract; | |
30 | 18 | import com.shunzhi.parent.popu.ShaiXuanPop; |
31 | -import com.shunzhi.parent.presenter.report.ReportPresenter; | |
19 | +import com.shunzhi.parent.ui.activity.report.ReportSceneActivity; | |
32 | 20 | import com.shunzhi.parent.ui.fragment.report.ChengZhangFragment; |
33 | -import com.shunzhi.parent.views.CustomLinearLayoutManager; | |
34 | 21 | |
35 | 22 | import java.util.List; |
36 | 23 | |
... | ... | @@ -45,7 +32,7 @@ public class ReportFragment extends BaseCompatFragment implements View.OnClickLi |
45 | 32 | |
46 | 33 | ChengZhangFragment chengZhangFragment1 = null, chengZhangFragment2 = null;//成长、报告页面 |
47 | 34 | |
48 | - ShaiXuanPop shaiXuanPop=null; | |
35 | + ShaiXuanPop shaiXuanPop = null; | |
49 | 36 | |
50 | 37 | @Override |
51 | 38 | public int getLayoutId() { |
... | ... | @@ -60,6 +47,9 @@ public class ReportFragment extends BaseCompatFragment implements View.OnClickLi |
60 | 47 | tvNoData = view.findViewById(R.id.tvNoData); |
61 | 48 | tabLayout = view.findViewById(R.id.tabLayout); |
62 | 49 | |
50 | + | |
51 | + | |
52 | + tvNoData.setOnClickListener(this); | |
63 | 53 | tvShaiXuan.setOnClickListener(this); |
64 | 54 | |
65 | 55 | myFragmentAdapter = new MyFragmentAdapter(getChildFragmentManager()); |
... | ... | @@ -77,7 +67,7 @@ public class ReportFragment extends BaseCompatFragment implements View.OnClickLi |
77 | 67 | |
78 | 68 | @Override |
79 | 69 | public void onPageSelected(int position) { |
80 | - if (position==0)tvShaiXuan.setVisibility(View.GONE); | |
70 | + if (position == 0) tvShaiXuan.setVisibility(View.GONE); | |
81 | 71 | else tvShaiXuan.setVisibility(View.VISIBLE); |
82 | 72 | } |
83 | 73 | |
... | ... | @@ -91,15 +81,17 @@ public class ReportFragment extends BaseCompatFragment implements View.OnClickLi |
91 | 81 | |
92 | 82 | @Override |
93 | 83 | public void onClick(View view) { |
94 | - switch (view.getId()){ | |
84 | + switch (view.getId()) { | |
95 | 85 | case R.id.tvShaiXuan: |
96 | 86 | if (null == shaiXuanPop) shaiXuanPop = new ShaiXuanPop(getActivity()); |
97 | 87 | chengZhangFragment2.showShaixuan(handler); |
98 | 88 | break; |
89 | + case R.id.tvNoData: | |
90 | + ReportSceneActivity.getInstance(getActivity(), 3); | |
99 | 91 | } |
100 | 92 | } |
101 | 93 | |
102 | - Handler handler=new Handler(){ | |
94 | + Handler handler = new Handler() { | |
103 | 95 | @Override |
104 | 96 | public void handleMessage(Message msg) { |
105 | 97 | super.handleMessage(msg); |
... | ... | @@ -111,7 +103,7 @@ public class ReportFragment extends BaseCompatFragment implements View.OnClickLi |
111 | 103 | @Override |
112 | 104 | public void onDestroy() { |
113 | 105 | super.onDestroy(); |
114 | - if (handler!=null)handler=null; | |
106 | + if (handler != null) handler = null; | |
115 | 107 | } |
116 | 108 | |
117 | 109 | private class MyFragmentAdapter extends FragmentPagerAdapter { | ... | ... |
app/src/main/java/com/shunzhi/parent/ui/fragment/report/ReportSceneFragment.java
1 | 1 | package com.shunzhi.parent.ui.fragment.report; |
2 | 2 | |
3 | -import android.annotation.SuppressLint; | |
4 | 3 | import android.content.res.Resources; |
5 | 4 | import android.os.Bundle; |
6 | 5 | import android.support.annotation.NonNull; |
7 | 6 | import android.support.annotation.Nullable; |
8 | 7 | import android.support.v7.widget.LinearLayoutManager; |
9 | 8 | import android.support.v7.widget.RecyclerView; |
9 | +import android.util.Log; | |
10 | 10 | import android.view.View; |
11 | 11 | import android.widget.TextView; |
12 | 12 | |
... | ... | @@ -77,6 +77,11 @@ public class ReportSceneFragment extends BaseMVPCompatFragment<ReportSceneContra |
77 | 77 | |
78 | 78 | @Override |
79 | 79 | public void showChart(List<ChatBean> list1, List<ChatBean> list2, List<ChatBean> list3) { |
80 | + Log.e("11111", "1111----===="); | |
81 | + if(list1==null||list2==null||list3==null) { | |
82 | + Log.e("11111", "----===="); | |
83 | + return ; | |
84 | + } | |
80 | 85 | chartView.setColors(R.color.textColor, R.color.huodong_blue, R.color.gray); |
81 | 86 | List<InputData> inputDataList1 = new ArrayList<>(); |
82 | 87 | List<InputData> inputDataList2 = new ArrayList<>(); | ... | ... |
mvpsdk/src/main/java/com/share/mvpsdk/utils/ValueUtils.java
... | ... | @@ -3,8 +3,6 @@ package com.share.mvpsdk.utils; |
3 | 3 | import android.support.annotation.NonNull; |
4 | 4 | import android.support.annotation.Nullable; |
5 | 5 | import android.support.v4.app.NotificationCompat; |
6 | -import android.util.Log; | |
7 | - | |
8 | 6 | |
9 | 7 | import com.share.mvpsdk.view.chartview.data.Chart; |
10 | 8 | import com.share.mvpsdk.view.chartview.data.ChartPath; |
... | ... | @@ -14,12 +12,11 @@ import com.share.mvpsdk.view.chartview.data.InputData; |
14 | 12 | import java.util.ArrayList; |
15 | 13 | import java.util.List; |
16 | 14 | import java.util.ListIterator; |
17 | -import java.util.concurrent.TimeUnit; | |
18 | 15 | |
19 | 16 | public class ValueUtils { |
20 | 17 | |
21 | - public static long getCorrectedMaxValue(long maxValue) { | |
22 | - for (long value = maxValue; value >= Chart.CHART_PART_VALUE; value--) { | |
18 | + public static float getCorrectedMaxValue(float maxValue) { | |
19 | + for (float value = maxValue; value >= Chart.CHART_PART_VALUE; value--) { | |
23 | 20 | if (isRightValue(value)) { |
24 | 21 | return value; |
25 | 22 | } |
... | ... | @@ -28,8 +25,8 @@ public class ValueUtils { |
28 | 25 | return maxValue; |
29 | 26 | } |
30 | 27 | |
31 | - public static long max(@Nullable List<ChartPath> dataList) { | |
32 | - long maxValue = 0; | |
28 | + public static float max(@Nullable List<ChartPath> dataList) { | |
29 | + float maxValue = 0; | |
33 | 30 | |
34 | 31 | if (dataList == null || dataList.isEmpty()) { |
35 | 32 | return maxValue; |
... | ... | @@ -46,29 +43,42 @@ public class ValueUtils { |
46 | 43 | return maxValue; |
47 | 44 | } |
48 | 45 | |
49 | - private static long maxOne(List<InputData> dataList) { | |
50 | - long maxValue = 0; | |
46 | + private static long getMax(long max) { | |
47 | + if (max < 10) { | |
48 | + max = 10; | |
49 | + } else if (max / 10 < 10) { | |
50 | + max = (max / 10 + 1) * 10; | |
51 | + } else if (max / 100 < 10) { | |
52 | + max = (max / 100 + 1) * 100; | |
53 | + } else if (max / 1000 < 10) { | |
54 | + max = (max / 1000 + 1) * 1000; | |
55 | + } | |
56 | + return max; | |
57 | + } | |
58 | + | |
59 | + private static float maxOne(List<InputData> dataList) { | |
60 | + float maxValue = 0; | |
51 | 61 | |
52 | 62 | if (dataList == null || dataList.isEmpty()) { |
53 | 63 | return maxValue; |
54 | 64 | } |
55 | - for (InputData data : dataList) { | |
56 | - if (data.valueY > maxValue) { | |
57 | - maxValue = data.valueY; | |
58 | - } | |
65 | + for (InputData data : dataList) { | |
66 | + if (data.valueY > maxValue) { | |
67 | + maxValue = data.valueY; | |
59 | 68 | } |
69 | + } | |
60 | 70 | |
61 | 71 | return maxValue; |
62 | 72 | } |
63 | 73 | |
64 | - private static boolean isRightValue(long value) { | |
65 | - long valueResidual = value % Chart.CHART_PART_VALUE; | |
74 | + private static boolean isRightValue(float value) { | |
75 | + float valueResidual = value % Chart.CHART_PART_VALUE; | |
66 | 76 | return valueResidual == 0; |
67 | 77 | } |
68 | 78 | |
69 | 79 | @NotificationCompat.NotificationVisibility |
70 | 80 | public static List<DrawData> getDrawData(@Nullable Chart chart) { |
71 | - if (chart == null || chart.getInputDataList().isEmpty()) { | |
81 | + if (chart == null || chart.getInputDataList()==null||chart.getInputDataList().isEmpty()) { | |
72 | 82 | return new ArrayList<>(); |
73 | 83 | } |
74 | 84 | |
... | ... | @@ -78,7 +88,7 @@ public class ValueUtils { |
78 | 88 | } |
79 | 89 | |
80 | 90 | @NotificationCompat.NotificationVisibility |
81 | - public static List<DrawData> getDrawDatas(@Nullable List<InputData> inputDataList,@NonNull Chart chart) { | |
91 | + public static List<DrawData> getDrawDatas(@Nullable List<InputData> inputDataList, @NonNull Chart chart) { | |
82 | 92 | return createDrawDataList(chart, createValueList(inputDataList)); |
83 | 93 | } |
84 | 94 | |
... | ... | @@ -111,13 +121,22 @@ public class ValueUtils { |
111 | 121 | iterator.next(); |
112 | 122 | } |
113 | 123 | } |
114 | - static long topValue=0; | |
124 | + | |
125 | + public static float topValue = 0.00f; | |
126 | + | |
127 | + public static void calMax(List<ChartPath> chartPathList) { | |
128 | + | |
129 | + for (int i = 0; i < chartPathList.size(); i++) { | |
130 | + createValueList(chartPathList.get(i).inputDataList); | |
131 | + } | |
132 | + } | |
133 | + | |
115 | 134 | private static List<Float> createValueList(@NonNull List<InputData> dataList) { |
116 | 135 | List<Float> valueList = new ArrayList<>(); |
117 | - topValue=topValue > ValueUtils.maxOne(dataList)?topValue:ValueUtils.maxOne(dataList);//取最大值 | |
136 | + topValue = topValue > ValueUtils.maxOne(dataList) ? topValue : ValueUtils.maxOne(dataList);//取最大值 | |
118 | 137 | |
119 | 138 | for (InputData data : dataList) { |
120 | - float value = (float) data.valueY / topValue; | |
139 | + float value = data.valueY / topValue; | |
121 | 140 | valueList.add(value); |
122 | 141 | } |
123 | 142 | |
... | ... | @@ -142,8 +161,8 @@ public class ValueUtils { |
142 | 161 | } |
143 | 162 | |
144 | 163 | float value = valueList.get(position); |
145 | - int startX = getCoordinateX(chart, position); | |
146 | - int startY = getCoordinateY(chart, value); | |
164 | + float startX = getCoordinateX(chart, position); | |
165 | + float startY = getCoordinateY(chart, value); | |
147 | 166 | drawData.startX = startX; |
148 | 167 | drawData.startY = startY; |
149 | 168 | // drawData.setStartX(startX); |
... | ... | @@ -151,8 +170,8 @@ public class ValueUtils { |
151 | 170 | int nextPosition = position + 1; |
152 | 171 | if (nextPosition < valueList.size()) { |
153 | 172 | float nextValue = valueList.get(nextPosition); |
154 | - int stopX = getCoordinateX(chart, nextPosition); | |
155 | - int stopY = getCoordinateY(chart, nextValue); | |
173 | + float stopX = getCoordinateX(chart, nextPosition); | |
174 | + float stopY = getCoordinateY(chart, nextValue); | |
156 | 175 | |
157 | 176 | // drawData.setStopX(stopX); |
158 | 177 | // drawData.setStopY(stopY); |
... | ... | @@ -165,13 +184,13 @@ public class ValueUtils { |
165 | 184 | } |
166 | 185 | |
167 | 186 | @SuppressWarnings("UnnecessaryLocalVariable") |
168 | - private static int getCoordinateX(@NonNull Chart chart, int index) { | |
169 | - int width = chart.width; | |
170 | - int titleWidth = chart.titleWidth; | |
187 | + private static float getCoordinateX(@NonNull Chart chart, int index) { | |
188 | + float width = chart.width; | |
189 | + float titleWidth = chart.titleWidth; | |
171 | 190 | |
172 | - int widthCorrected = width - titleWidth; | |
173 | - int partWidth = widthCorrected / (Chart.MAX_ITEMS_COUNT - 1); | |
174 | - int coordinate = titleWidth + (partWidth * index); | |
191 | + float widthCorrected = width - titleWidth; | |
192 | + float partWidth = widthCorrected / (Chart.MAX_ITEMS_COUNT - 1); | |
193 | + float coordinate = titleWidth + (partWidth * index); | |
175 | 194 | |
176 | 195 | if (coordinate < 0) { |
177 | 196 | coordinate = 0; |
... | ... | @@ -184,13 +203,11 @@ public class ValueUtils { |
184 | 203 | } |
185 | 204 | |
186 | 205 | @SuppressWarnings("UnnecessaryLocalVariable") |
187 | - private static int getCoordinateY(@NonNull Chart chart, float value) { | |
188 | - int height = chart.height - chart.padding - chart.textSize; | |
189 | - int heightOffset = chart.heightOffset; | |
190 | - | |
191 | - int heightCorrected = height - heightOffset; | |
192 | - int coordinate = (int) (heightCorrected - (heightCorrected * value)); | |
193 | - | |
206 | + private static float getCoordinateY(@NonNull Chart chart, float value) { | |
207 | + float height = chart.height - chart.padding - chart.textSize; | |
208 | + float heightOffset = chart.heightOffset; | |
209 | + float heightCorrected = height - heightOffset; | |
210 | + float coordinate = (heightCorrected - (heightCorrected * value)); | |
194 | 211 | if (coordinate < 0) { |
195 | 212 | coordinate = 0; |
196 | 213 | |
... | ... | @@ -201,4 +218,5 @@ public class ValueUtils { |
201 | 218 | coordinate += heightOffset; |
202 | 219 | return coordinate; |
203 | 220 | } |
221 | + | |
204 | 222 | } | ... | ... |
mvpsdk/src/main/java/com/share/mvpsdk/view/chartview/ChartView.java
... | ... | @@ -2,13 +2,9 @@ package com.share.mvpsdk.view.chartview; |
2 | 2 | |
3 | 3 | import android.content.Context; |
4 | 4 | import android.graphics.Canvas; |
5 | -import android.graphics.Color; | |
6 | -import android.graphics.DashPathEffect; | |
7 | 5 | import android.graphics.Paint; |
8 | 6 | import android.graphics.Path; |
9 | 7 | import android.graphics.PathDashPathEffect; |
10 | -import android.graphics.RectF; | |
11 | -import android.graphics.Shader; | |
12 | 8 | import android.support.annotation.NonNull; |
13 | 9 | import android.support.annotation.Nullable; |
14 | 10 | import android.util.AttributeSet; |
... | ... | @@ -16,13 +12,13 @@ import android.util.Log; |
16 | 12 | import android.view.View; |
17 | 13 | |
18 | 14 | import com.share.mvpsdk.R; |
19 | -import com.share.mvpsdk.utils.DateUtils; | |
20 | 15 | import com.share.mvpsdk.utils.ValueUtils; |
21 | 16 | import com.share.mvpsdk.view.chartview.data.Chart; |
22 | 17 | import com.share.mvpsdk.view.chartview.data.ChartPath; |
23 | 18 | import com.share.mvpsdk.view.chartview.data.DrawData; |
24 | 19 | import com.share.mvpsdk.view.chartview.data.InputData; |
25 | 20 | |
21 | +import java.text.DecimalFormat; | |
26 | 22 | import java.util.ArrayList; |
27 | 23 | import java.util.List; |
28 | 24 | |
... | ... | @@ -97,7 +93,11 @@ public class ChartView extends View { |
97 | 93 | chart.setInputDataList(inputData); |
98 | 94 | chart.titleWidth = getTitleWidth(); |
99 | 95 | invalidate(); |
96 | + } | |
100 | 97 | |
98 | + public void setDrawData(){ | |
99 | +// chart.setDrawDataList(ValueUtils.getDrawData(chart)); | |
100 | + invalidate(); | |
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
... | ... | @@ -163,11 +163,11 @@ public class ChartView extends View { |
163 | 163 | return; |
164 | 164 | } |
165 | 165 | |
166 | - long maxValue = ValueUtils.max(chartPathList); | |
167 | - long correctedMaxValue = ValueUtils.getCorrectedMaxValue(maxValue); | |
166 | + float maxValue = ValueUtils.max(chartPathList); | |
167 | + float correctedMaxValue = ValueUtils.getCorrectedMaxValue(maxValue); | |
168 | 168 | float value = (float) correctedMaxValue / maxValue; |
169 | 169 | |
170 | - long heightOffset = chart.heightOffset; | |
170 | + float heightOffset = chart.heightOffset; | |
171 | 171 | int padding = chart.padding; |
172 | 172 | int textSize = chart.textSize; |
173 | 173 | int titleWidth = chart.titleWidth; |
... | ... | @@ -177,7 +177,7 @@ public class ChartView extends View { |
177 | 177 | float chartPartHeight = ((height - heightOffset) * value) / Chart.CHART_PARTS; |
178 | 178 | |
179 | 179 | float currHeight = height; |
180 | - int currTitle = 0; | |
180 | + float currTitle = 0.0f; | |
181 | 181 | |
182 | 182 | for (int i = 0; i <= Chart.CHART_PARTS; i++) { |
183 | 183 | float titleY = currHeight; |
... | ... | @@ -192,12 +192,13 @@ public class ChartView extends View { |
192 | 192 | if (i > 0) { |
193 | 193 | // canvas.drawLine(titleWidth, currHeight, width, currHeight, frameInternalPaint); |
194 | 194 | //横向间隔线 |
195 | - canvas.drawLine(titleWidth-5,titleY-textSize/2,width,titleY-textSize/2,textPaint); | |
195 | + textPaint.setColor(0xFFE7E5E7); | |
196 | + canvas.drawLine(titleWidth - 5, titleY - textSize / 2, width, titleY - textSize / 2, textPaint); | |
196 | 197 | } |
197 | - | |
198 | - String title = String.valueOf(currTitle); | |
199 | - canvas.drawText(title, padding, titleY, textPaint); | |
198 | + DecimalFormat decimalFormat = new DecimalFormat("0.0"); | |
199 | + String title = String.valueOf(decimalFormat.format(currTitle)); | |
200 | 200 | textPaint.setColor(getResources().getColor(R.color.gray)); |
201 | + canvas.drawText(title, padding - textSize / 2, titleY, textPaint); | |
201 | 202 | |
202 | 203 | currHeight -= chartPartHeight; |
203 | 204 | currTitle += correctedMaxValue / Chart.CHART_PARTS; |
... | ... | @@ -205,11 +206,15 @@ public class ChartView extends View { |
205 | 206 | } |
206 | 207 | |
207 | 208 | private void drawChartHorizontal(@NonNull Canvas canvas) { |
209 | + if (null!=chartPathList){ | |
210 | + ValueUtils.calMax(chartPathList); | |
208 | 211 | for (int j = 0; j < chartPathList.size(); j++) { |
209 | 212 | chagerColor(j); |
210 | 213 | List<InputData> inputDataList = chart.getInputDataList(); |
211 | 214 | // List<DrawData> drawDataList = chart.getDrawDataList(); |
212 | 215 | List<DrawData> drawDataList = ValueUtils.getDrawDatas(chartPathList.get(j).inputDataList, chart); |
216 | +// Log.e("111111", "chartPathList.get(j).inputDataList----===="+chartPathList.get(j).inputDataList); | |
217 | +// Log.e("111111", "drawDataList----===="+drawDataList); | |
213 | 218 | if (inputDataList == null || inputDataList.isEmpty() || drawDataList == null || drawDataList.isEmpty()) { |
214 | 219 | return; |
215 | 220 | } |
... | ... | @@ -219,7 +224,7 @@ public class ChartView extends View { |
219 | 224 | // String date = DateUtils.format(inputData.valueX); |
220 | 225 | String date = inputData.valueX; |
221 | 226 | int dateWidth = (int) axisPaint.measureText(date); |
222 | - int x; | |
227 | + float x; | |
223 | 228 | if (drawDataList.size() > i) { |
224 | 229 | DrawData drawData = drawDataList.get(i); |
225 | 230 | x = drawData.startX; |
... | ... | @@ -246,7 +251,7 @@ public class ChartView extends View { |
246 | 251 | |
247 | 252 | //画圆点 |
248 | 253 | canvas.drawCircle(startX, startY, 10, valuesPaint); |
249 | - | |
254 | + Log.e("11111", "startX----===="+startX+"startY="+startY); | |
250 | 255 | //点之间的连线 |
251 | 256 | if (i < drawDataList.size() - 1) { |
252 | 257 | canvas.drawLine(startX, startY, drawDataList.get(i + 1).startX - chart.padding - chart.textSize, drawDataList.get(i + 1).startY, valuesPaint); |
... | ... | @@ -257,10 +262,11 @@ public class ChartView extends View { |
257 | 262 | } |
258 | 263 | } |
259 | 264 | } |
265 | + } | |
260 | 266 | } |
261 | 267 | |
262 | 268 | private void chagerColor(int j) { |
263 | - switch (j){ | |
269 | + switch (j) { | |
264 | 270 | case 0: |
265 | 271 | valuesPaint.setColor(getResources().getColor(R.color.theme_day_blue)); |
266 | 272 | break; |
... | ... | @@ -280,7 +286,7 @@ public class ChartView extends View { |
280 | 286 | |
281 | 287 | int height = chart.height - textSize - padding; |
282 | 288 | int width = chart.width - textSize - padding; |
283 | - int titleWidth = chart.titleWidth-5; | |
289 | + int titleWidth = chart.titleWidth - 5; | |
284 | 290 | int heightOffset = chart.heightOffset; |
285 | 291 | |
286 | 292 | canvas.drawLine(titleWidth, heightOffset, titleWidth, height, axisPaint); |
... | ... | @@ -292,7 +298,7 @@ public class ChartView extends View { |
292 | 298 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); |
293 | 299 | |
294 | 300 | int width = MeasureSpec.getSize(widthMeasureSpec); |
295 | - int height = MeasureSpec.getSize(heightMeasureSpec) / 2; | |
301 | + int height = MeasureSpec.getSize(heightMeasureSpec); | |
296 | 302 | chart.width = width; |
297 | 303 | chart.height = height; |
298 | 304 | setMeasuredDimension(width, height); | ... | ... |
mvpsdk/src/main/java/com/share/mvpsdk/view/chartview/data/Chart.java
... | ... | @@ -9,7 +9,7 @@ import java.util.List; |
9 | 9 | |
10 | 10 | public class Chart { |
11 | 11 | |
12 | - public static final int CHART_PARTS = 5; | |
12 | + public static final float CHART_PARTS = 5.0f; | |
13 | 13 | public static final int MAX_ITEMS_COUNT = 7; |
14 | 14 | public static final int CHART_PART_VALUE = 10; |
15 | 15 | public static final int TEXT_SIZE_OFFSET = 10; | ... | ... |
mvpsdk/src/main/java/com/share/mvpsdk/view/chartview/data/DrawData.java
... | ... | @@ -6,11 +6,11 @@ package com.share.mvpsdk.view.chartview.data; |
6 | 6 | |
7 | 7 | public class DrawData { |
8 | 8 | |
9 | - public int startX; | |
10 | - public int startY; | |
9 | + public float startX; | |
10 | + public float startY; | |
11 | 11 | |
12 | - public int stopX; | |
13 | - public int stopY; | |
12 | + public float stopX; | |
13 | + public float stopY; | |
14 | 14 | |
15 | 15 | @Override |
16 | 16 | public String toString() { | ... | ... |
mvpsdk/src/main/java/com/share/mvpsdk/view/chartview/data/InputData.java
... | ... | @@ -9,9 +9,9 @@ public class InputData { |
9 | 9 | |
10 | 10 | public String valueX; |
11 | 11 | |
12 | - public long valueY; | |
12 | + public float valueY; | |
13 | 13 | |
14 | - public InputData(String valueX,long valueY){ | |
14 | + public InputData(String valueX,float valueY){ | |
15 | 15 | this.valueX=valueX; |
16 | 16 | this.valueY=valueY; |
17 | 17 | } | ... | ... |