Android Open Source Chart library Mpandroidchart document translation (next)

Source: Internet
Author: User

In the Android Open Source Chart library Mpandroidchart document translation (in) describes setting data, setting color, axis formatting, legends, and dynamically modifying data. This article continues to translate the remaining content of the Mpandroidchart document.

17, ChartData class

The intent of this wiki entry is to better introduce the Mpandroidchart data model.
The ChartData class is the base class for all chart data classes, such as Linedata,bardata and so on, providing tabular data through the SetData method of the chart.

public class Linedata extends ChartData {...
the methods mentioned below are implemented in the ChartData class and can therefore be used for all subclasses.

Data StylesSetvaluetextcolor (int color): Sets the data text color
Setvaluetextcolors (list colors): Set data text color List
Setvaluetextsize (float size): Set data text font size
Setvaluetypeface (Typeface TF): Set Data font
Setvalueformatter (valueformatter f): Formatting data
Setdrawvalues (Boolean enabled): Enable drawing of data
Get Property-related methodsgetdatasetbyindex (int index): Gets a fixed-index dataset
Contains (Entry Entry): Determines whether an entry is included. implementation is inefficient.
Contains (T DataSet): Determine if a DataSet is included
Clear Dataclearvalues (): Removes all values from the DataSet object without affecting the value of the x-axis
Highlight Datasethighlightenabled (Boolean enabled): Whether highlighting is allowed
Setdrawverticalhighlightindicator (Boolean enabled): Whether to enable highlighting in the vertical direction
Setdrawhorizontalhighlightindicator (Boolean enabled): Whether to enable highlighting in the horizontal direction

18, ChartData sub-classBarData Class (bar chart data)Setgroupspace (float percent): a percentage of the width of an entry between entries of different datasets, the default value of 80
isgrouped (): Data objects are grouped
Scatterdata Class (Scatter chart data)getgreatestshapesize (): Returns the largest graphic size in all Scatterdataset
Piedata Class (pie chart data)GetDataSet (): The Piedataset object Piedata object that returns the data object cannot contain more than one piedatasets.
Setdataset (Piedataset Set): Set Piedataset
bubbledata (Bubble chart data)sethighlightcirclewidth (float width): Set the bubble width, unit dp
Combineddata Class (composite data)

You can set different types of data, only for Combinedchart

public class Combineddata extends ChartData {    //...    Public Combineddata (list<string> xvals) {...}    Public Combineddata (string[] xvals) {...}    public void SetData (Linedata data) {...}    public void SetData (BarData data) {...}    public void SetData (Scatterdata data) {...}    public void SetData (Candledata data) {...}    // ...}

19. DataSet classThe DataSet class is the base class for all datasets, such as Linedataset,bardataset
The DataSet class represents a group of input types that belong to a table entry.
The method is similar to Chardata, except that he is a collection. The DataSet class also has a corresponding subclass that does not do a detailed translation. SOURCE Details

20. DataSet sub-class

Slightly

21, Viewporthandler class

The Viewporthandler class is responsible for working with chart views. You can control whether the chart view is visible, the current state of the view, the pan and zoom/zoom levels, the drawing area, and the offset. Viewporthandler allows direct access to all of the aforementioned properties and directly modifies them.
Unlike modifying a view through a chart class, use Viewporthandler with caution and improper use can lead to unexpected behavior. Viewporthandler provides a more advanced method of view modification.

Get instance

Viewporthandler handler = Chart.getviewporthandler ();
detailed usage See API documentation
This kind of research is more in-depth before it can be used directly, otherwise it is prone to problems.

22. Custom Fill Positionthe Fillformatter interface allows you to customize the fill line end position of the linedataset. You only need to create a new class and implement the Fillformatter interface.
How to use

public class Mycustomfillformatter implements Fillformatter {    @Override public    float getfilllineposition ( Linedataset DataSet, Linedataprovider dataprovider) {        float mydesiredfillposition = ...;        Put your logic        here ... return mydesiredfillposition;}    }
and set it to the Linedataset object.
Linedataset.setfillformatter (New Mycustomfillformatter ());
The default implementation is Defaultfillformatter

23. Confusion

Need to add in the obfuscation file

-keep class com.github.mikephil.charting.** {*;}
if not added, this can cause problems with animations.

Detailed description of the confusion more information


first, simply translate the document to understand the use. The source code is more, later look at the source codes and then analyze from the layer.



Welcome to scan QR Code, follow public account


Android Open Source Chart library Mpandroidchart document translation (next)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.