Article From:



















 You can test yourself.

Past data is now passed



 Then it receives and displays on another interface.















Let’s use it directly first, and then we can study it later.






    That’s when there’s no data.


 Now add data



Let’s add a little more.

Current source code

public class DeviceControl extends AppCompatActivity {
    String DeviceId="";

    private AchartengineMethod mAchartengineMethod;//The class that displays waveform charts
    private GraphicalView mGraphicalView;//Diagram showing waveform
    private ConstraintLayout ConstraintLayout2;//Put the chart in this layout (View)

    protected void onCreate(Bundle savedInstanceState) {

        Intent intent = getIntent();
        DeviceId = intent.getStringExtra("DeviceId");

        Toast.makeText(DeviceControl.this,"Here comes the following:"+DeviceId,Toast.LENGTH_SHORT).show();

        ConstraintLayout2 = findViewById(;

        mAchartengineMethod = new AchartengineMethod(DeviceControl.this);//Get the class of drawings
        mAchartengineMethod.setXYMultipleSeriesRenderer(Color.RED, Color.BLACK, Color.RED, Color.BLACK,
                Color.argb(100, 0, 255, 0), 30, 30, new double[] {0,60,-200,200}, 1, 0, 10, 0, 60);//Configuration interface

        mAchartengineMethod.setXYSeriesRenderer(Color.RED, 10.0f);//Set a line to add the renderer
        mAchartengineMethod.setXYMultipleSeriesDataset("Temperature (c)");//Setting the data set for this curve

        mAchartengineMethod.setXYSeriesRenderer(Color.BLUE, 10.0f);//Set a line to add the renderer
        mAchartengineMethod.setXYMultipleSeriesDataset("Humidity (c)");//Setting the data set for this curve

        mGraphicalView = mAchartengineMethod.getGraphicalView();//Get that chart
        ConstraintLayout2.addView(mGraphicalView);//Add the chart to the layout

        mAchartengineMethod.getXYSeries(0).add(1, 10);
        mAchartengineMethod.getXYSeries(0).add(15, 50);
        mAchartengineMethod.getXYSeries(0).add(29, 20);
        mAchartengineMethod.getXYSeries(0).add(45, 90);

        mAchartengineMethod.getXYSeries(1).add(1, 90);
        mAchartengineMethod.getXYSeries(1).add(5, 40);
        mAchartengineMethod.getXYSeries(1).add(9, 140);
        mAchartengineMethod.getXYSeries(1).add(20, 50);



Now let’s talk about the bottom of the chart, which is the class I encapsulated.

 In fact, there are four main ones.

XYSeriesRenderer  Used to set curve parameters (color, shape, thickness)
XYSeries          Used to set curve data.

After each parameter is finally set
Just put
XYSeriesRenderer Add toXYMultipleSeriesRenderer
Add XYSeries to the XY MultipleSeries Dataset
Look at XY MultipleSeries Renderer, which is almost all the settings of the interface (color, location...). )






That's why

  Curves are added one by one. Index = 0 is to operate the first curve. 1 is to operate the second curve.




Leave a Reply

Your email address will not be published. Required fields are marked *