AChartEngine CombinedXYChart错误的第四个参数中 [英] AChartEngine CombinedXYChart wrong 4th parameter found
问题描述
我和我的结合图表有点问题。 3年前我犯了同样的Eclipse和使用的jar库。我复制我的code到Android Studio中,使用依赖,现在它不工作。我无法得到它的工作。
i have a little Problem with my combined chart. 3 years ago i made the same with Eclipse and used a jar library. I copied my code to android Studio, using a dependency and now it's not working. I can't get it work.
我会后我的整个code,然后我将迎来这个问题。
I will post my whole code and then I will mark the problem.
public void createChart()
{
XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
XYMultipleSeriesRenderer multiRenderer = new XYMultipleSeriesRenderer();
final Bundle extras = this.getIntent().getExtras();
couchdurations = extras.getLongArray("couchtimes");
perstdurations = extras.getLongArray("persttimes");
//ToDo Sqlite noch ergänzen
XYSeries couchseries = new XYSeries("CouchBase");
XYSeriesRenderer couchRenderer = new XYSeriesRenderer();
XYSeries perstseries = new XYSeries("PerstDB");
XYSeriesRenderer perstRenderer = new XYSeriesRenderer();
couchRenderer.setColor(Color.RED);
couchRenderer.setPointStyle(PointStyle.X);
couchRenderer.setFillPoints(false);
couchRenderer.setLineWidth(2);
couchRenderer.setDisplayChartValues(false);
perstRenderer.setColor(Color.BLUE);
perstRenderer.setPointStyle(PointStyle.X);
perstRenderer.setFillPoints(false);
perstRenderer.setLineWidth(2);
perstRenderer.setDisplayChartValues(false);
multiRenderer.addSeriesRenderer(couchRenderer);
multiRenderer.addSeriesRenderer(perstRenderer);
multiRenderer.setYAxisMin(0.0);
multiRenderer.setYAxisMax(10000000.0);
multiRenderer.setXAxisMax(60000.0);
multiRenderer.setLabelsTextSize(40);
multiRenderer.setLegendTextSize(40);
for(int i = 0; i < couchdurations.length; i++)
{
couchseries.add(couchdurations[i], datasizes[i]);
perstseries.add(perstdurations[i], datasizes[i]);
}
dataset.addSeries(couchseries);
dataset.addSeries(perstseries);
// Getting a reference to LinearLayout of the MainActivity Layout
LinearLayout chartContainer = (LinearLayout) findViewById(R.id.chart_container);
// Specifying chart types to be drawn in the graph
// Number of data series and number of types should be same
// Order of data series and chart type will be same
String[] types = new String[dataset.getSeriesCount()];
for(int i = 0; i < (dataset.getSeriesCount()); i++)
{
types[i] = LineChart.TYPE;
}
// Creating a combined chart with the chart types specified in types array
mChart = (GraphicalView) ChartFactory.getCombinedXYChartView(getBaseContext(), dataset, multiRenderer, types);
// Adding the Combined Chart to the LinearLayout
chartContainer.addView(mChart);
}
问题是以下行:
mChart = (GraphicalView) ChartFactory.getCombinedXYChartView(getBaseContext(), dataset, multiRenderer, types);
我总是得到错误的第4个参数是错误的。但是我之前在另一个Android应用3年最初使用相同的code。
错误截图1
错误截图2
你可以看到在所附的图片的错误消息。
错误4个参数的类型。发现'java.lang.String中[]',要求:org.achartengine.chart.CombinedXYChart.XYCombinedChartDef []
I always get the error that the 4th parameter is wrong. But I used originally the same code before 3 years inside another android app. Error Screenshot 1 Error Screenshot 2 You can see the Error Message in the attached pictures. Wrong 4th parameter type. Found 'java.lang.String[]', required: 'org.achartengine.chart.CombinedXYChart.XYCombinedChartDef[]'
任何人可以帮助我解决这个问题呢?我不知道如何解决这个问题。
Can anybody help me to solve this problem? I have no idea how to solve it.
推荐答案
我知道了。从
String[] types = new String[dataset.getSeriesCount()];
for(int i = 0; i < (dataset.getSeriesCount()); i++)
{
types[i] = LineChart.TYPE;
}
到
CombinedXYChart.XYCombinedChartDef[] types = new CombinedXYChart.XYCombinedChartDef[]
{
new CombinedXYChart.XYCombinedChartDef(LineChart.TYPE, 0), new CombinedXYChart.XYCombinedChartDef(LineChart.TYPE, 1)
};
这篇关于AChartEngine CombinedXYChart错误的第四个参数中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!