Android AChartEnginee: Explanation of the source code framework and achartengine source code

Source: Internet
Author: User

Android AChartEnginee: Explanation of the source code framework and achartengine source code

After checking out the android ACHartEnginee source code last week, I have been checking out how this item is used and how it is implemented at the underlying layer. I will first learn about it in the last week, I just want to give myself a summary and hope to help the kids who want to learn this open source project. Next let's start with the question.

What is android AChartEnginee? It is an open-source Chart project of Apache. It is used to facilitate android applications to draw difficult charts, such as pie charts and curves, like the high chart on the web end, after mastering this project, we only need to assemble our data into the format required by achartenginee, and then call the corresponding API to set the corresponding parameters, the chart you want to draw is very powerful. Today, Let's explain the overall architecture of this project.

Let's take a look at the code structure of the source project,

This is the structure of the entire project. The image package contains only three images used in the Program (skipped). The util package mainly contains some algorithm-related tool classes, I can't quite understand it. The tools mainly include the tool class used to control the zoom in and out of the entire chart, and I will not explain it. I will mainly analyze the chart, renderer, model, and ChartFactory, graphicalView.

I. first, analyze the role of the renderer package. First, this word indicates the meaning of rendering, which can be understood from the literal meaning, the classes in this package are mainly used to render the chart style, that is, to control the chart appearance. Let's take a look at the classes in the renderer package:

As you can see, there are several XXXRenderer classes. You can see the source code. DefaultRenderer is the DialRenderer, XYMultipleSeriesRenderer is the parent class, And SimpleSeriesRenderer is the parent class of XYSeriesRenderer. Therefore, we will discuss.

1) DeaultRenderer and its subclass Renderer are used to render the entire chart. That is to say, they are used to set the style of the entire chart. DefaultRenderer defines some common attributes of all charts, for example: mChartTitle, mBackground, etc. For detailed attributes, refer to the source code. DialRenderer inherits from the DefaultRenderer class, except for the common attributes of the parent class, he also has some unique attributes. DialRenderer is mainly used to render the pie chart Renderer. For example, different types of pie charts and column charts can be used for rendering; XYMultipleSeriesRenderer also has the attributes of the parent class. It also has many unique attributes to set. XYMultipleSeriesRenderer is mainly used to render the XY axis chart. It can be seen that when we draw different types of charts, we need to use the corresponding Renderer for rendering to achieve the best effect.

2) SimpleSeriesRenderer is the parent class of XYSeriesRenderer. In my understanding, these two Renderer render different effects for each specific vertex, simpleSeriesRenderer is mainly used to render vertices in pie charts, while XYSeriesRenderer is mainly used to render coordinate axis points.

Ii. analyze the role of the model package. classes in the model package:

This package mainly contains a set of chart points. for different types of charts, we need to use corresponding objects to load different types of points. Among them: CategorySeries is used to load the pie chart's Point Set, MultipleCategorySeries is used to load the pie chart's Point Set, RangeCategorySeries is used to load the bar chart's Point Set, TimeSeries, XYSeries, XYValueSeries is mainly used to load the Coordinate, XYMultipleSeriesDataset is a set of the above three sets (because there may be multiple images in our coordinate axes ).

3. Analyze the functions of the chart package. classes in the chart package:

All the classes in this package are the classes responsible for drawing charts. They all provide different ways to draw different charts, based on the class name, you can know which charts they are used to draw. I don't know how to draw it.

The last thing we want to talk about is the factory class ChartFactory. The function of this factory class is to pass in the corresponding dataset and renderer according to the different factory methods we call, call GraphicalView to generate a specific Chart View for us to display.

The above is my macro understanding of this open-source project, and I don't want to go into the specific implementation steps. It's really hard to understand, as long as we understand the roles of different classes in this project as a whole and can be skillfully applied, we can.

Summary: The entire project structure is very clear. Classes responsible for rendering, classes responsible for assembling data, and classes that are truly responsible for drawing using settings in rendering classes and data classes.

Related Article

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.