aChartEngine, grid and thickness

570 views Asked by At

I'm trying to conform a graphic similar than this one with aChartengine, but I can't find the method to get different thickness into the vertical grids like in the image, does anyone can help me?

enter image description here

Here it is my code: Is it posible to delete the lines connecting points??

 public Intent execute(Context context) {
        String[] titles = new String[] { "Systolic Pressure", "Diastolic Pressure", "BIS", "ETCO2"};
    List<double[]> x = new ArrayList<double[]>();
    for (int i = 0; i < titles.length; i++) {
    x.add(new double[] { 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60 });
    }
       List<double[]> values = new ArrayList<double[]>();
         values.add(new double[] { 108, 110.5, 110, 115, 114, 118, 116, 119, 120, 125.3, 122.2,
             13.9 });
         values.add(new double[] { 75, 77, 80, 79, 82, 84, 83, 80, 86, 88, 85, 80 });
         values.add(new double[] { 5, 5.3, 8, 12, 17, 22, 24.2, 24, 19, 15, 9, 6 });
         values.add(new double[] { 9, 10, 11, 15, 19, 23, 26, 25, 22, 18, 13, 10 });
         int[] colors = new int[] { Color.BLUE, Color.RED, Color.CYAN, Color.YELLOW };
        PointStyle[] styles = new PointStyle[] { PointStyle.TRIANGLE, PointStyle.TRIANGLE,
             PointStyle.POINT, PointStyle.SQUARE};
         XYMultipleSeriesRenderer renderer = buildRenderer(colors, styles);

         setChartSettings(renderer, "Anesthesia sheet", "Time", " ", 0, 60, 0, 250,
             Color.WHITE, Color.WHITE);
         renderer.setXLabels(12);
         renderer.setYLabels(10);
         renderer.setShowGrid(true);
         renderer.setXLabelsAlign(Align.RIGHT);
         renderer.setYLabelsAlign(Align.RIGHT);
         renderer.setZoomButtonsVisible(true);

         renderer.setPanLimits(new double[] { 0,60, 0, 250 });
         renderer.setZoomLimits(new double[] { 0, 60, 0, 250});

         XYMultipleSeriesDataset dataset = buildDataset(titles, x, values);
         Intent intent = ChartFactory.getLineChartIntent(context, dataset, renderer,
             "Anesthesia");
         return intent;   } 

Here it is the graph in Android: enter image description here

1

There are 1 answers

0
AADProgramming On

I know this question is way too old, but I guess it is very basic requirement to have a grid line width/thickness configurable, specially with Line charts using achartengine.

As discussed in the comments of this question, there is no API that achartengine Library itself provides to modify grid line width/thickness, hence below solution only work if you are willing to change source code of Library itself (with appropriate Legal Permissions of Library License).

File to Modify: XYChart.java
Method in which to modify: drawXTextLabels
Code you need to add to increase grid line width/thickness:

paint.setStrokeWidth(2);//adjust 2 to suitable value as per your requirement.

This above line of code need to be added before
canvas.drawLine(xLabel, bottom, xLabel, top, paint); in drawXTextLabels method.

achartengine Library version: 1.0.0

NOTE: Above code will make ALL Grid lines thicker, and you need to set the thickness/width of Specific Grid Lines as per your Business Logic.