1

Similar to MPAndroidChart - First and last bars not rendering correctly, the first and last bubble in my chart isn't rendered fully, and is sliced in half as seen in the image.

enter image description here

The following is the current implementation for the BubbleChart.

private void initializeBubbleChart() {
        mChart = (BubbleChart) findViewById(R.id.bubblechart);

        mChart .setDescription("");

        mChart .setOnChartValueSelectedListener(this);

        mChart .setDrawGridBackground(false);

        mChart .setTouchEnabled(true);
        mChart .setDragEnabled(true);
        mChart .setScaleEnabled(true);

        AxisValueFormatter xAxisFormatter = new DayAxisValueFormatter(mChart);

        XAxis xAxis = mChart .getXAxis();
        xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
        xAxis.setTypeface(typeFace);
        xAxis.setDrawGridLines(false);
        xAxis.setGranularity(1f); // only intervals of 1 day
        xAxis.setValueFormatter(xAxisFormatter);

        AxisValueFormatter yAxis = new YAxisValueFormatter("duration");

        YAxis leftAxis = mChart .getAxisLeft();
        leftAxis.setTypeface(typeFace);
        leftAxis.setSpaceTop(30f);
        leftAxis.setSpaceBottom(30f);
        leftAxis.setDrawGridLines(false);
        leftAxis.setValueFormatter(yAxis);
        leftAxis.setDrawZeroLine(false);

        YAxis rightAxis = mChart .getAxisRight();
        rightAxis.setTypeface(typeFace);
        rightAxis.setSpaceTop(30f);
        rightAxis.setSpaceBottom(30f);
        rightAxis.setDrawGridLines(false);
        rightAxis.setValueFormatter(yAxis);
        rightAxis.setDrawZeroLine(false);

        populateData();
    }

@Philipp Jahoda

Community
  • 1
  • 1
Zhi Kai
  • 1,549
  • 1
  • 13
  • 31

1 Answers1

2

Use setAxisMinValue() and setAxisMaxValue() to customize the axis range:

xAxis.setAxisMinValue(valueBelowActualMinimum);
xAxis.setAxisMaxValue(valueAboveActualMaximum);

and modify the DayAxisValueFormatter to show or suppress labels for the edge values.

Bö macht Blau
  • 12,820
  • 5
  • 40
  • 61