2012-04-12 48 views
2

我試圖改變我的圖的點的大小,但是當我做 mRenderer.setPointSize(size); 它永遠不會改變..achartengine scatter graph point size

這裏是我的圖全碼:

public class ShowGraph extends Activity { 

    private XYMultipleSeriesDataset mDataset = new XYMultipleSeriesDataset(); 
    private XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer(); 
    private XYSeries mCurrentSeries; 
    private XYSeriesRenderer mCurrentRenderer; 
    private GraphicalView mChartView; 
    int x,y; 
    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.graph_layout); 
     LinearLayout layout = (LinearLayout) findViewById(R.id.chart); 

     mRenderer.setPanLimits(new double[] { 00, 600 , 00, 300 });  //xmin,xmax,ymin,ymax bars/grids limit 
     mRenderer.setZoomLimits(new double[]{00, 200, 00, 30});  //xmin,xmax,ymin,ymax zoom limit 
     String seriesTitle = "Series " + (mDataset.getSeriesCount() + 1); 
     XYSeries series = new XYSeries(seriesTitle); 
     ArrayList<String> accuracy = getIntent().getExtras().getStringArrayList("accuracy"); 
     ArrayList<String> time = getIntent().getExtras().getStringArrayList("time"); 
     for (int i = 0; i < time.size(); i++) { 
      series.add(Double.parseDouble(time.get(i)), Double.parseDouble(accuracy.get(i))); 
     } 
     mDataset.addSeries(series); 
     mCurrentSeries = series; 
     mRenderer.setYLabelsAlign(Paint.Align.RIGHT); 
     XYSeriesRenderer renderer = new XYSeriesRenderer(); 
     mRenderer.addSeriesRenderer(renderer); 
     mRenderer.setPointSize(15f); 
     mCurrentRenderer = renderer; 

     if(mChartView== null){ 

      //ADD VALUE OF X,Y HERE to the series 
      mCurrentSeries.add(x,y); 

      if (mChartView != null) { 
       mChartView.repaint(); 
      } 
      mChartView = ChartFactory.getScatterChartView(ShowGraph.this, mDataset, mRenderer); 
      mChartView.addPanListener(new PanListener() { 
       public void panApplied() { 
        System.out.println("New X range=[" + mRenderer.getXAxisMin() + ", " + mRenderer.getXAxisMax() 
         + "], Y range=[" + mRenderer.getYAxisMax() + ", " + mRenderer.getYAxisMax() + "]"); 
       } 
      }); 
      layout.addView(mChartView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT)); 

     } 
     Toast.makeText(this, "" + mRenderer.getPointSize(), 3000).show(); 
    } 
} 

任何想法如何,我可以做出更大的點?它們很小,幾乎看不到它們

回答

8

直到您將XYSeriesRenderer的點樣式設置爲PointStyle.POINT以外的其他值之後,點纔會實際顯示。要獲得球風格點,請執行以下操作:

XYSeriesRenderer renderer = new XYSeriesRenderer(); 
renderer.setPointStyle(PointStyle.CIRCLE); 
renderer.setFillPoints(true); 
mRenderer.addSeriesRenderer(renderer); 
mRenderer.setPointSize(2.0f); 
+1

第3行的代碼應該是renderer.setFillPoints(true); (而不是「setFillPoint」) – baekacaek 2014-09-22 03:15:23

+0

謝謝,我解決了錯字。 – 2014-09-22 06:50:04