我使用AChartEngine作爲庫來繪製我的折線圖。此折線圖由多個Y軸(3-5軸)組成,並在X軸的時間軸上進行。AChartEngine多個Y軸重疊值
我的問題是,Y軸的值是重疊的(見圖片)
繼承人我的代碼:
//Puls, Geschwindigkeit und Hoehenmeter dem Diagramm hinzufugen
HashMap<Long, Heartrate> heartrateMap = trainingLog.getHeartrateList();
HashMap<Long, GPS> gpsMap = trainingLog.getGpsList();
//Puls, Geschwindigkeit und Hoehenmeter dem Diagramm hinzufugen
XYSeries heartrateSeries = new XYSeries("Puls", 0);
XYSeries altitudeSeries = new XYSeries("Höhenmeter", 1);
XYSeries speedSeries = new XYSeries("Geschwindigkeit", 2);
for(int i=0; i<trainingLog.getDuration(); i++){
Heartrate heartrate = heartrateMap.get(Long.valueOf(i));
if(heartrate != null){
heartrateSeries.add(i, heartrate.getHeartrate());
}
GPS gps = gpsMap.get(Long.valueOf(i));
if(gps != null){
altitudeSeries.add(i, gps.getAltitude());
speedSeries.add(i, gps.getSpeed());
}
}
XYMultipleSeriesDataset dataSet = new XYMultipleSeriesDataset();
dataSet.addSeries(0, heartrateSeries);
dataSet.addSeries(1, altitudeSeries);
dataSet.addSeries(2, speedSeries);
XYMultipleSeriesRenderer multiRenderer = new XYMultipleSeriesRenderer(3);
//Renderer fuer Pulswerte
XYSeriesRenderer rendererHeartrate = new XYSeriesRenderer();
rendererHeartrate.setColor(Color.RED);
multiRenderer.addSeriesRenderer(rendererHeartrate);
//Renderer fuer Hoehenmeter
XYSeriesRenderer rendererAltitude = new XYSeriesRenderer();
rendererAltitude.setColor(Color.BLUE);
multiRenderer.addSeriesRenderer(rendererAltitude);
//Renderer fuer Geschwindigkeit
XYSeriesRenderer rendererSpeed = new XYSeriesRenderer();
rendererSpeed.setColor(Color.DKGRAY);
multiRenderer.addSeriesRenderer(rendererSpeed);
//Hintergrundfarbe weiß setzen
multiRenderer.setApplyBackgroundColor(true);
multiRenderer.setBackgroundColor(Color.WHITE);
multiRenderer.setMarginsColor(Color.argb(0x00, 0x01, 0x01, 0x01));
//Label--Einstellungen
multiRenderer.setYLabelsColor(0, Color.RED);
multiRenderer.setYLabelsColor(1, Color.BLUE);
multiRenderer.setYLabelsColor(2, Color.DKGRAY);
multiRenderer.setLabelsTextSize(25);
int length = multiRenderer.getSeriesRendererCount();
for (int i = 0; i < length; i++) {
XYSeriesRenderer r = (XYSeriesRenderer) multiRenderer.getSeriesRendererAt(i);
r.setLineWidth(2f);
}
//Legenden-Einstellungen
multiRenderer.setLegendTextSize(20);
multiRenderer.setMargins(new int[] {20, 20, 20, 20});
Looper.prepare();
graphicalView = ChartFactory.getLineChartView(getActivity(), dataSet, multiRenderer);
有誰知道如何解決這個問題?最好的辦法是設置y標籤相互平行,但我還沒有找到一種方法來做到這一點。或者是否有將每個y標籤的邊距設置爲y軸的函數?
感謝您的幫助!
謝謝你的回答,但是這種方法我已經試過了。正如你可以看到在下面的圖片重疊仍然存在:http://postimage.org/image/bxywmw8q3/ – iTamp
AChartEngine不提供其他重疊保護比我提到的。 –
你知道另一個圖書館是否可以處理這個問題?我只是嘗試了GrapView,但他們不支持多個y軸。 – iTamp