Recent projects have to add more complex icons, once some simple graphs, pie chart. Risk indicators, etc., are drawn by themselves. With the difficulty of adding. More and more powerless. Once studied the Achartenginee icon frame, but found that the Achartenginee customization is not flattering, made out of the icon simply can not meet the needs. So again on GitHub search Android chart, found the first row of this icon frame. Presumably, was in line with their own requirements, and then down. Research, indeed, is stronger than other known frameworks. Hereby, summarize the method of use.
Advantages of the Mpchart framework: 1. Easy to use, all icons can be defined as a normal view in our layout files. With the definition of a textview in the layout no matter what the difference, the use is basically the same, through Fandviewbyid () can. You can then add data to the chart.
2. Good event conflict handling. When using Achartenginee, it is found that once the chart is placed in the ScrollView, there is an event conflict that causes the ScrollView to slip less sensitively, and Mpchart is perfect for event handling. Not only does the ScrollView not cause any conflict of events, but the chart can also be exaggerated in Listview,viewpager. Don't be too strong.
3. Strong customization, only if you can see. Can be changed to the style you want, this is my main advantage to choose it.
4. A word on the animated effect can be achieved, but a little bit small bug. But the author is constantly updating.
Based on the above points, we can basically pick up the other chart frame and use the Mpchart, the following first look at the source code demo, as well as my own custom of a graph:
Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqv/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity /center "height=" 474 "width=" 373 ">
Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqv/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity /center "height=" 463 "width=" 413 ">
The effect is simply not talk ah, too strong, must learn to use AH.
Here's my understanding of the structure of the code:
1. The source code charts package defines all the types of icons that can be drawn. Contains a graph. Pie charts, histogram, scatter plots, and mixed graphs.
The chart mainly deals with the interactive events of the charts. Animation, drawing of components, and so on.
2. The source code package defines all the components in the chart, including the x-axis (Xaxis), y-axis (YAxis). Table header (lenged), identification (Markerview).
3. In the source code data package, different types of charts are required for different data types.
4. All event types are defined in the source code listener package.
These bags are what we need to know, through a random example in the chart package, to be able to do whatever customization we need. For example, to customize the data or style of the x-axis.
Xaxis Xaxis = Mchart.getxaxis ();
Xaxis.setposition (); Customize whether the x-axis is above or below the chart.
Xaxis.setlabelstoskip (); Custom x-axis label interval.
Xaxis.setavoidfirstlastclipping (); Custom x-axis start and end labels cannot exceed the screen.
The y-Axis operates similarly.
lenged L = mchart.getlenged ();
L.setenabled (); Whether the custom header is displayed.
L.setform (); Custom header styles. It's circle,square. or line?
And so on, only if you can see the style, can be customized. You can also customize what you don't see. The source code of the first my custom diagram is posted as follows:
Lineview = new Linechart (this); Lineview.setdescription (""); lineview.setscaleenabled (false); Lineview.getaxi Sright (). SetEnabled (True); Lineview.setdrawgridbackground (false); lineview.settouchenabled (false); Sets whether the chart slide is available lineview.getlegend (). setenabled (false); Set header is not available lineview.sethardwareaccelerationenabled (true); arraylist<entry> yrawdata = new arraylist<entry> (); arraylist<string> Xrawdatas = new arraylist<string> (); int index = 0;for (int i = Array.Length ()-1; I >= 0 ; i--) {if (Array.get (i) = null) {Jsonobject jsonobj = (jsonobject) array.get (i); Yrawdata.add (New Entry (Float.parsefloat ( Jsonobj.optstring ("Profitrate")), index), Xrawdatas.add (Dateformathelp.formatdatetoneededformat ( Jsonobj.optstring ("DT"). Concat ("a"), dateformat.date_1); Index++;initmaxmin (Float.parsefloat ( Jsonobj.optstring ("Profitrate")));}} /** * x-axis style settings */xaxis Xaxis = Lineview.getxaxis (); xaxis.setposition (xaxisposition.bottom);// Sets the X-axis to display xaxis.setavoidfirstlastclipping (true) at the bottom; XaxiS.setspacebetweenlabels (0); X-axis spacing Xaxis.settextcolor (Resource.getcolor (R.color.grey_low_txt)); Xaxis.setaxislinecolor (Resource.getColor ( R.COLOR.COLOR_DDDDDD)); Xaxis.setdrawgridlines (true);//sets whether to display the horizontal axis table Xaxis.setgridcolor (Resource.getcolor ( R.COLOR.COLOR_DDDDDD));//Set X-axis table color/** * Y-axis style settings */yaxis Leftaxis = Lineview.getaxisleft (); Leftaxis.setstartatzero ( FALSE); Leftaxis.setlabelcount (Yaxislabelnum, true); Sets the y-axis label number leftaxis.setdrawlimitlinesbehinddata (TRUE); Leftaxis.settextcolor (Resource.getcolor (r.color.grey_low_txt)); Sets the left side y-axis label color Leftaxis.setaxislinecolor (Resource.getcolor (R.COLOR.COLOR_DDDDDD)); Sets the left side y-axis color leftaxis.setdrawgridlines (TRUE); Set the display y-axis table line Leftaxis.setgridcolor (Resource.getcolor (R.COLOR.COLOR_DDDDDD)); Sets the y-axis table line Color Leftaxis.setaxismaxvalue (Yaxismax + yaxisgap); Set y-axis maximum leftaxis.setaxisminvalue (YAXISMIN-YAXISGAP),//Set y-axis minimum value YAxis Rightaxis = Lineview.getaxisright (); Rightaxis.setdrawlabels (FALSE); Sets whether the right side y-axis displays Labelrightaxis.setdrawgridlines (false); Rightaxis.setaxislinecOlor (Resource.getcolor (R.COLOR.COLOR_DDDDDD));/** * Curve style set */linedataset set = new Linedataset (Yrawdata, ""); Set.setdrawcubic (TRUE); Set the curve style to cubieset.setcubicintensity (0.2f);//Curve Smoothness Set.setlinewidth (util.dip2px (this, 1.0f)); Injection Curve Widthset.setcolor (Resource.getcolor (r.color.color_fd4634));//injection curve Color set.setcirclesize (util.dip2px (This, 2.0f);//The Dot size Set.setcirclecolor (Resource.getcolor (r.color.color_fd4634)) on the injection curve, or the dot color on the shot curve Set.setfillcolor ( Resource.getcolor (r.color.color_fd4634));//injection curve Fill color set.setfillalpha (128);//injection curve Fill color transparency set.setdrawfilled (TRUE) ;//Set whether the curve fill is enabled Set.setdrawvalues (false);//sets whether to display the point value linedata data = new Linedata (Xrawdatas, set); Lineview.setdata (data) ;//Bind data to chart lineview.invalidate (); Layoutparams params = new Layoutparams (layoutparams.match_parent, util.dip2px (this,)); Contentlayout.addview ( Lineview, params);
Learn to use this chart frame after. The efficiency can be greatly improved. No need to worry about ordinary charting.
。
Android Mpchart icons using specific explanations