MPAndroidChart:BubbleChart 第一个和最后一个气泡呈现一半显示

MPAndroidChart: BubbleChart first and last bubble rendered half shown

类似,我的图表中的第一个和最后一个气泡没有完全呈现,而是被切成两半,如图所示。

以下是气泡图的当前实现。

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

使用setAxisMinValue()setAxisMaxValue()自定义坐标轴范围:

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

并修改 DayAxisValueFormatter 以显示或抑制边缘值的标签。