固定GraphView标题X轴的间距

时间:2019-04-03 20:45:00

标签: android android-graphview

只需尝试在X轴标题上添加一些间距,以免混乱。特别是文字“时间”。

您已经看到,我已经尝试过填充设置。

图片在这里:

<com.jjoe64.graphview.GraphView
        android:id="@+id/bar_graph"
        android:layout_width="match_parent"
        android:layout_height="200dip"
        android:layout_below="@+id/toolbar"
        android:layout_marginRight="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="75dp" />
 //set scale
        bar_Graph.getViewport().setMinX(0);
        bar_Graph.getViewport().setMaxX(7);
        bar_Graph.getViewport().setMinY(0);

        bar_Graph.getViewport().setYAxisBoundsManual(true);
        bar_Graph.getViewport().setXAxisBoundsManual(true);

        GridLabelRenderer gridLabel = bar_Graph.getGridLabelRenderer();
        gridLabel.setHorizontalAxisTitle("Time");
        gridLabel.setVerticalAxisTitle("Ticket Redemptions");

        gridLabel.setPadding(50);

        //space bars
        barGraph_Data.setSpacing(20);

        // GraphView 4.x
        StaticLabelsFormatter staticLabelsFormatter = new StaticLabelsFormatter(bar_Graph);
        staticLabelsFormatter.setHorizontalLabels(new String[] {"","11", "11:30","12", "12:30", "1", "1:30",""});
//        staticLabelsFormatter.setVerticalLabels(new String[] {"low", "middle", "high"});
        bar_Graph.getGridLabelRenderer().setLabelFormatter(staticLabelsFormatter);

0 个答案:

没有答案