issue with graphic of achartengine: the label of axis dont appear if the graphic is empty

StackOverflow https://stackoverflow.com//questions/12661580

  •  11-12-2019
  •  | 
  •  

Question

hi mate i have a graphic in my app . i use achartengine lib! when my graph dont have any point ,in my view dont appear the title and label of axis. i configure my rendere in this way:

private static XYMultipleSeriesRenderer createCustomRender(String titleX,String titleY){
        XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer();
         mRenderer.setApplyBackgroundColor(true);
            mRenderer.setBackgroundColor(Color.WHITE);
          mRenderer.setShowGridX(true);
           mRenderer.setShowGridY(true);
            mRenderer.setAxisTitleTextSize(16);
            mRenderer.setAxesColor(Color.RED);
            mRenderer.setGridColor(Color.BLACK);
            mRenderer.setLabelsColor(Color.WHITE);
            mRenderer.setMarginsColor(Color.DKGRAY);
            mRenderer.setXLabelsColor(Color.BLACK);
            mRenderer.setYLabelsColor(0,Color.BLACK);
            mRenderer.setChartTitleTextSize(20);
            mRenderer.setLabelsTextSize(15);
            mRenderer.setLegendTextSize(15);
            mRenderer.setChartTitle("Graphic droid");
            mRenderer.setXTitle(titleX);
            mRenderer.setYTitle(titleY);
            mRenderer.setMargins(new int[] { 20, 30, 15, 0 });
            mRenderer.setZoomButtonsVisible(true);
            mRenderer.setPointSize(5f);
            mRenderer.setShowLabels(true);
            mRenderer.setShowCustomTextGrid(true);
            mRenderer.setShowAxes(true);
        return mRenderer;

    }

when i add the first point, in my graph appear the title and the label. But i want that also if the graphic is empty to show label and title graph

Was it helpful?

Solution

AChartEngine makes the visible area based on the data points that are added to your dataset by default. When there is no point added, there is no visible area, when there is one single point, the minimum and the maximum visible range are equals. This changes only when adding more than one point and now it is able to display labels.

However, you can manually set the visible area and you will probably get visible labels:

renderer.setXAxisMin(minXValue);
renderer.setXAxisMax(maxXValue);
renderer.setYAxisMin(minYValue);
renderer.setYAxisMax(maxYValue);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top