我正在尝试使用achart引擎开发一个应用程序,该应用程序绘制了一个包含多个系列的图表。 这是我的代码:
import java.util.ArrayList;
import org.achartengine.ChartFactory;
import org.achartengine.GraphicalView;
import org.achartengine.chart.PointStyle;
import org.achartengine.model.XYMultipleSeriesDataset;
import org.achartengine.model.XYSeries;
import org.achartengine.renderer.XYMultipleSeriesRenderer;
import org.achartengine.renderer.XYSeriesRenderer;
import android.content.Context;
import android.graphics.Color;
public class Graph {
private Context context;
XYMultipleSeriesDataset dataset;
XYMultipleSeriesRenderer renderer;
public static boolean ClickEnabled = true;
public Graph(Context context) {
this.context = context;
}
public void initData(ArrayList<Double> x,ArrayList<Double> y,ArrayList<Double> z){
XYSeries seriesX = new XYSeries("X");
for(int i =0 ; i< x.size();i++){
seriesX.add(x.get(i), i);
}
XYSeries seriesY = new XYSeries("Y");
for(int i =0 ; i< y.size();i++){
seriesY.add(y.get(i), i);
}
XYSeries seriesZ = new XYSeries("Z");
for(int i =0 ; i< z.size();i++){
seriesZ.add(z.get(i), i);
}
dataset = new XYMultipleSeriesDataset();
dataset.addSeries(seriesX);
dataset.addSeries(seriesY);
dataset.addSeries(seriesZ);
renderer = new XYMultipleSeriesRenderer();
}
public void setProperties(){
renderer.setPanEnabled(true, false);
renderer.setClickEnabled(ClickEnabled);
renderer.setBackgroundColor(Color.WHITE);
renderer.setApplyBackgroundColor(true);
renderer.setChartTitle("AccelerometerData");
renderer.setAxesColor(Color.BLACK);
XYSeriesRenderer renderer1 = new XYSeriesRenderer();
renderer1.setColor(Color.RED);
renderer1.setPointStyle(PointStyle.DIAMOND);
renderer.addSeriesRenderer(renderer1);
XYSeriesRenderer renderer2 = new XYSeriesRenderer();
renderer2.setColor(Color.GREEN);
renderer2.setPointStyle(PointStyle.DIAMOND);
renderer.addSeriesRenderer(renderer2);
XYSeriesRenderer renderer3 = new XYSeriesRenderer();
renderer3.setColor(Color.BLUE);
renderer3.setPointStyle(PointStyle.DIAMOND);
renderer.addSeriesRenderer(renderer3);
}
public GraphicalView getGraph(){
return ChartFactory.getLineChartView(context, dataset, renderer);
}
}
我得到的图表如下:
我希望所有三个系列并行,并希望从图表中删除黑色背景;
答案 0 :(得分:2)
如需改变你可以做的黑色
XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();
renderer.setMargins(new int[] { top, left, bottom, right });
renderer.setMarginsColor(Color.RED);
并且对于您的第二个问题,请通过屏幕截图或任何参考图像来更具体。