Search code examples
androidteechart

How to set Android TeeChart Border Color


I use Steema TeeChart JAVA for Android to create a Chart. With the following code i tried to change the color of the charts border, but it effects nothing.

public void setBorderColor(Color borderColor){

    tChart.getWalls().getRight().setColor(borderColor);
    tChart.getWalls().getLeft().setColor(borderColor);
    tChart.getWalls().getBottom().setColor(borderColor);
    tChart.getWalls().getBack().setColor(borderColor);
}

Solution

  • Try changing the pen color getPen() instead of changing the wall color. Ie:

    public void setBorderColor(Color borderColor){
    
        tChart.getWalls().getRight().getPen().setColor(borderColor);
        tChart.getWalls().getLeft().getPen().setColor(borderColor);
        tChart.getWalls().getBottom().getPen().setColor(borderColor);
        tChart.getWalls().getBack().getPen().setColor(borderColor);
    }
    

    You may be interested on also changing the axes pen color. Ie:

    public void setBorderColor(Color borderColor){
    
        tChart.getWalls().getRight().getPen().setColor(borderColor);
        tChart.getWalls().getLeft().getPen().setColor(borderColor);
        tChart.getWalls().getBottom().getPen().setColor(borderColor);
        tChart.getWalls().getBack().getPen().setColor(borderColor);
    
        tChart.getAxes().getLeft().getAxisPen().setColor(borderColor);
        tChart.getAxes().getBottom().getAxisPen().setColor(borderColor);
    }