MPAndroidChart - First and last bars not rendering correctly

后端 未结 4 668
南旧
南旧 2021-01-11 13:40
  1. In the bar chart I am creating the first and last rows are consistently being cut in half (even if I add additional bars). This also causes the values above the bar

4条回答
  •  执念已碎
    2021-01-11 14:01

    To answer your questions:

    1. In order to properly show your bars you need to fit the bars, like this (don't ask me why it's not enabled by default):

      chart.setFitBars(true)
      

      You can find more information in the BarChart javadocs:

      setFitBars(boolean enabled): Adds half of the bar width to each side of the x-axis range in order to allow the bars of the barchart to be fully displayed.

      If you have a CombinedChart you could use setSpaceMin() and setSpaceMax() to add additional spacing on both ends of the axis:

      XAxis xAxis = chart.getXAxis();
      xAxis.setSpaceMin(barData.getBarWidth() / 2f);
      xAxis.setSpaceMax(barData.getBarWidth() / 2f);
      
    2. It is currently impossible to infuence the value positions rendered on the axis. Creating a ValueFormatter only changes the displayed text, not the actual position of the label.

提交回复
热议问题