我想创建节点和边,所以我使用了带有散点图和折线图的组合图。但是我无法将一个根节点连接到它的子节点..相反,它只是连接所有子节点,只有两个子节点连接到根...任何人都可以告诉我哪里出错了...下面我使用的代码
public GraphicalView combinedChart(){
int[] x = {3};
double[] values = {50};
XYSeries series = new XYSeries("App");
int length = x.length;
for (int k = 0;k < length; k++)
{
series.add(x[k], values[k]);
}
int[] x1 = {1,2,4,5};
double[] values1 = {70,30,30,70};
XYSeries series1 = new XYSeries("Info");
int length1 = x1.length;
for (int k = 0;k < length1; k++)
{
series1.add(x1[k], values1[k]);
}
/*int[] x2 = {1,5};
double[] values2 = {70,70};
XYSeries series2 = new XYSeries("Dest");
int length2 = x2.length;
for (int k = 0;k < length2; k++)
{
series2.add(x2[k], values2[k]);
}*/
int[] x3 = {3,1,3,2,3,4,3,5};
int[] y3 = {50,70,50,30,50,30,50,70};
TimeSeries series3 = new TimeSeries("Line1");
for(int i=0; i<x3.length; i++){
series3.add(x3[i], y3[i]);
}
XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
dataset.addSeries(series);
dataset.addSeries(series1);
//dataset.addSeries(series2);
dataset.addSeries(series3);
XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer();
XYSeriesRenderer renderer = new XYSeriesRenderer();
XYSeriesRenderer renderer1 = new XYSeriesRenderer();
//XYSeriesRenderer renderer2 = new XYSeriesRenderer();
XYSeriesRenderer renderer3 = new XYSeriesRenderer();
renderer.setColor(Color.BLUE);
renderer.setPointStyle(PointStyle.SQUARE);
renderer.setFillPoints(true);
renderer1.setColor(Color.GREEN);
renderer1.setPointStyle(PointStyle.CIRCLE);
renderer1.setFillPoints(true);
/*renderer2.setColor(Color.MAGENTA);
renderer2.setPointStyle(PointStyle.CIRCLE);
renderer2.setFillPoints(true);*/
renderer3.setColor(Color.RED);
mRenderer.addSeriesRenderer(renderer);
mRenderer.addSeriesRenderer(renderer1);
//mRenderer.addSeriesRenderer(renderer2);
mRenderer.addSeriesRenderer(renderer3);
mRenderer.setPointSize(10f);
String[] types = new String[] { ScatterChart.TYPE,ScatterChart.TYPE,LineChart.TYPE};
final GraphicalView lv = ChartFactory.getCombinedXYChartView(this, dataset, mRenderer, types);
// final GraphicalView lv = ChartFactory.getScatterChartView(this, dataset, mRenderer);
return lv;
}