Recently done a small project need to draw some line chart, Achartengine actually contains a lot of figures, although it is open source, but after all, but not their own writing, and the project is a little bit large, some things change up or take some time, so finally intend to write a, Refer to the reading time curve effect of reading more, look first:
Here's the effect of the strip without the middle "average 3 hours/day"
Already open source, code on GitHub, address is Https://github.com/Steven-Luo/android-bezier-curve-chart
The usage is simple.
Layout files are:
1 < Com.cn.naive.lib.view.BezierCurveChart 2 Android:id = "@+id/bezier_curve_chart" 3 android:layout_width= "Match_parent"4 android:layout_height = "260DP" 5 android:layout_margin= "10DP"/>
Java code
1List<beziercurvechart.point> points=NewArraylist<beziercurvechart.point>();2 for(inti=0;i<10;i++) {3Points.Add (NewPoint (I, (float) (Math.random () *10)));4 }5String TipText = "3 hours/day on average";6 7Beziercurvechart Beziercurvechart =8 (Beziercurvechart) Rootview.findviewbyid (R.id.bezier_curve_chart);9 Beziercurvechart.init (points,Ten NewString[] {"0:00", "6:00pm", "12:00pm", "18:00", "24:00"}, TipText);
The above data points are simulated using random numbers, the most critical is the Beziercurvechart init method, the first parameter is the data point, the second is the bottom of the label, the last parameter is the middle of the cue bar, if not required, the last parameter is set to NULL.