1
我正在使用GraphView庫,我想在X軸上顯示一年中的月份。我的問題是標籤在「肖像」模式下重疊。它在「風景」模式下看起來更好,但它們也是重疊的標籤。如何在graphview(Android Studio)中的X軸上設置固定的水平標籤
這是我的圖表外觀上的 「肖像」 模式:
這是我的圖表外觀上的 「風景」 模式(更好):
當我試圖製作較短的標籤(1月,2月,3月,4月等)或更小的字體大小它變得更糟(它看起來像創建更多的垂直線):
那是我的代碼:
GraphView graph_LastYear = (GraphView) findViewById(R.id.graph_yearly);
GraphView graph_Last3Months = (GraphView) findViewById(R.id.graph_last3month);
LineGraphSeries<DataPoint> series = new LineGraphSeries<DataPoint>(new DataPoint[]{
new DataPoint(1, Sallries_WholeYear.get(0).getNetoPayment()),
new DataPoint(2, Sallries_WholeYear.get(1).getNetoPayment()),
new DataPoint(3, Sallries_WholeYear.get(2).getNetoPayment()),
new DataPoint(4, Sallries_WholeYear.get(3).getNetoPayment()),
new DataPoint(5, Sallries_WholeYear.get(4).getNetoPayment()),
new DataPoint(6, Sallries_WholeYear.get(5).getNetoPayment()),
new DataPoint(7, Sallries_WholeYear.get(6).getNetoPayment()),
new DataPoint(8, Sallries_WholeYear.get(7).getNetoPayment()),
new DataPoint(9, Sallries_WholeYear.get(8).getNetoPayment()),
new DataPoint(10, Sallries_WholeYear.get(9).getNetoPayment()),
new DataPoint(11, Sallries_WholeYear.get(10).getNetoPayment()),
new DataPoint(12, Sallries_WholeYear.get(11).getNetoPayment())
}
);
series.setDrawDataPoints(true);
series.setColor(Color.BLACK);
series.setDrawDataPoints(true);
series.setDataPointsRadius(10);
series.setThickness(8);
graph_LastYear.addSeries(series);
graph_LastYear.setTitle("Last Year");
graph_LastYear.setTitleTextSize(60);
graph_LastYear.getViewport().setScalable(true);
graph_LastYear.getViewport().setScrollable(true);
graph_LastYear.getGridLabelRenderer().setTextSize(40);
graph_LastYear.getGridLabelRenderer().setNumHorizontalLabels(12);
graph_LastYear.getGridLabelRenderer().setGridColor(Color.BLUE);
StaticLabelsFormatter staticLabelsFormatter = new StaticLabelsFormatter(graph_LastYear);
staticLabelsFormatter.setHorizontalLabels(new String[]{getString(R.string.Janury_Month), getString(R.string.February_Month), getString(R.string.March_Month), getString(R.string.April_Month), getString(R.string.My_Month), getString(R.string.June_Month), getString(R.string.July_Month), getString(R.string.August_Month),
getString(R.string.September_Month), getString(R.string.October_Month), getString(R.string.November_Month), getString(R.string.December_Month)});
graph_LastYear.getGridLabelRenderer().setLabelFormatter(staticLabelsFormatter);
謝謝您的幫助!