我在我的android应用程序中使用了下面的代码来生成散点图,但问题是在图中散点圆的半径很小,所以很难看到。
我不知道怎么增大圆的半径…
为Galaxy选项卡创建应用程序
请帮忙
public class page_twenty extends Activity
{
public static final String TYPE = "type";
int[] colors = new int[] { Color.BLUE, Color.GREEN , Color.CYAN};
PointStyle[] styles = new PointStyle[] { PointStyle.CIRCLE, PointStyle.CIRCLE ,PointStyle.CIRCLE };
XYMultipleSeriesRenderer renderer = buildRenderer(colors, styles);
private GraphicalView mChartView;
LinearLayout chart;
String[] titles = new String[] { "", "", ""};
int length;
List<double[]> x = new ArrayList<double[]>();
List<double[]> x1 = new ArrayList<double[]>();
List<double[]> x2 = new ArrayList<double[]>();
List<double[]> values = new ArrayList<double[]>();
List<double[]> values1 = new ArrayList<double[]>();
List<double[]> values2 = new ArrayList<double[]>();
@Override
protected void onRestoreInstanceState(Bundle savedState)
{
super.onRestoreInstanceState(savedState);
renderer = buildRenderer(colors, styles);
}
@Override
protected void onSaveInstanceState(Bundle outState)
{
super.onSaveInstanceState(outState);
}
protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.twenty);
chart = (LinearLayout) findViewById(R.id.chart);
int count = 4;
length = titles.length;
Random r = new Random();
for (int i = 0; i < length; i++)
{
double[] xValues = new double[count];
double[] yValues = new double[count];
double[] xValues1 = new double[count];
double[] yValues1 = new double[count];
double[] xValues2 = new double[count];
double[] yValues2 = new double[count];
for (int k = 0; k < count; k++)
{
//xValues[k] = k + r.nextInt() % 10;
//yValues[k] = k * 2 + r.nextInt() % 10;
xValues[0] = 6;
yValues[0] = 65;
xValues[1] = 19;
yValues[1] = 70;
xValues[2] = 31;
yValues[2] = 80;
xValues[3] = 43;
yValues[3] = 90;
xValues1[0] = 6;
yValues1[0] = 60;
xValues1[1] = 19;
yValues1[1] = 65;
xValues1[2] = 31;
yValues1[2] = 60;
xValues1[3] = 43;
yValues1[3] = 70;
xValues2[0] = 6;
yValues2[0] = 62;
xValues2[1] = 19;
yValues2[1] = 67.5;
xValues2[2] = 31;
yValues2[2] = 70;
xValues2[3] = 43;
yValues2[3] = 85;
}
x.add(xValues);
values.add(yValues);
x1.add(xValues1);
values1.add(yValues1);
x2.add(xValues2);
values2.add(yValues2);
}
setChartSettings(renderer, "", "", "", 0, 50, 60, 92, Color.GRAY,Color.LTGRAY);
renderer.setXLabels(0);
renderer.setYLabels(10);
length = renderer.getSeriesRendererCount();
for (int i = 0; i < length; i++)
{
((XYSeriesRenderer) renderer.getSeriesRendererAt(i)).setFillPoints(true);
}
if (mChartView != null)
{
mChartView.repaint();
}
}
protected void setChartSettings(XYMultipleSeriesRenderer renderer, String title, String xTitle,
String yTitle, double xMin, double xMax, double yMin, double yMax, int axesColor,
int labelsColor)
{
renderer.setChartTitle(title);
renderer.setXTitle(xTitle);
renderer.setYTitle(yTitle);
renderer.setXAxisMin(xMin);
renderer.setXAxisMax(xMax);
renderer.setYAxisMin(yMin);
renderer.setYAxisMax(yMax);
renderer.setAxesColor(axesColor);
renderer.setLabelsColor(labelsColor);
renderer.setShowLegend(false);
renderer.setLabelsTextSize(15);
}
protected XYMultipleSeriesRenderer buildRenderer(int[] colors, PointStyle[] styles)
{
XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();
int length = colors.length;
for (int i = 0; i < length; i++)
{
XYSeriesRenderer r = new XYSeriesRenderer();
r.setColor(colors[i]);
r.setPointStyle(styles[i]);
renderer.addSeriesRenderer(r);
}
return renderer;
}
protected XYMultipleSeriesDataset buildDataset(String[] titles, List<double[]> xValues,List<double[]> yValues,
List<double[]> xValues1,List<double[]> yValues1, List<double[]> xValues2,List<double[]> yValues2)
{
XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
int length = titles.length;
for (int i = 0; i < length; i++)
{
//XYSeries series = new XYSeries(titles[i]);
XYSeries series = new XYSeries(titles[i]);
double[] xV;
double[] yV;
if (i==0)
{
xV = xValues.get(i);
yV = yValues.get(i);
}
else if (i == 1)
{
xV = xValues1.get(i);
yV = yValues1.get(i);
}
else
{
xV = xValues2.get(i);
yV = yValues2.get(i);
}
int seriesLength = xV.length;
for (int k = 0; k < seriesLength; k++)
{
//series.add(xV[k], yV[k]);
series.add(xV[k], yV[k]);
//series.add(xV1[k], yV1[k]);
// series.add(xV2[k], yV2[k]);
}
dataset.addSeries(series);
}
return dataset;
}
@Override
protected void onResume()
{
super.onResume();
if (mChartView == null)
{
mChartView = ChartFactory.getScatterChartView(this, buildDataset(titles, x, values,x1, values1,x2, values2), renderer);
//mChartView = ChartFactory.getRangeBarChartView(this, buildDataset(titles, x, values,x1, values1,x2, values2), renderer,Type.DEFAULT);
chart.addView(mChartView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
}
else
{
mChartView.repaint();
}
}
private void setSeriesEnabled(boolean enabled)
{
}
}
最佳答案
值得一提的是,你正在使用阿卡通发动机绘制图表。
打个电话到某处就行了。
关于android - 如何增加散点图中的圆点半径?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6042771/