2012-05-26 4 views
5

x와 y 값이 고정 된 차트를 만들 수 있습니까? 내 x 값은 60, 90, 120, 180, 250, 375, 500, 750, 1000과 비슷하지만 androidplot은 값 사이의 동등한 거리를 기준으로 9 개의 다른 값을 만듭니다.안드로이드 플롯 x 고정 각도 값

Number[] timestamps = {60, 90, 120, 180, 250, 375, 500, 750, 1000}; 

나는 (XYStepMode.SUBDIVIDE, 9) mySimpleXYPlot.setDomainStep를 사용하고 있습니다; 그리고 나는이 명령을 해결할 해결책이 있다고 생각하지만, 어떻게해야할지 모르겠다.

enter image description here

전체 코드 :

mySimpleXYPlot = (XYPlot) findViewById(R.id.mySimpleXYPlot); 
     Number[] numSightings = {70, 63, 56, 49, 43, 37, 32, 27, 23}; 

     Number[] timestamps = { 
      60, 90, 120, 180, 250, 375, 500, 750, 1000 

     }; 

     // create our series from our array of nums: 
     XYSeries series2 = new SimpleXYSeries(
       Arrays.asList(timestamps), 
       Arrays.asList(numSightings), 
       "USA"); 


     mySimpleXYPlot.getGraphWidget().getGridBackgroundPaint().setColor(Color.WHITE); 
     mySimpleXYPlot.getGraphWidget().getGridLinePaint().setColor(Color.BLACK); 
     mySimpleXYPlot.getGraphWidget().getGridLinePaint().setPathEffect(new DashPathEffect(new float[]{1,1}, 1)); 
     mySimpleXYPlot.getGraphWidget().getDomainOriginLinePaint().setColor(Color.BLACK); 
     mySimpleXYPlot.getGraphWidget().getRangeOriginLinePaint().setColor(Color.BLACK); 

     mySimpleXYPlot.setBorderStyle(Plot.BorderStyle.SQUARE, null, null); 
     mySimpleXYPlot.getBorderPaint().setStrokeWidth(1); 
     mySimpleXYPlot.getBorderPaint().setAntiAlias(false); 
     mySimpleXYPlot.getBorderPaint().setColor(Color.WHITE); 

     // Create a formatter to use for drawing a series using LineAndPointRenderer: 
     LineAndPointFormatter series1Format = new LineAndPointFormatter(
       Color.rgb(0, 100, 0),     // line color 
       Color.rgb(0, 100, 0),     // point color 
       Color.rgb(100, 200, 0));    // fill color 


     // setup our line fill paint to be a slightly transparent gradient: 
     Paint lineFill = new Paint(); 
     lineFill.setAlpha(200); 
     lineFill.setShader(new LinearGradient(0, 0, 0, 250, Color.WHITE, Color.GREEN, Shader.TileMode.MIRROR)); 

     LineAndPointFormatter formatter = new LineAndPointFormatter(Color.rgb(0, 0,0), Color.BLUE, Color.RED); 
     formatter.setFillPaint(lineFill); 
     mySimpleXYPlot.getGraphWidget().setPaddingRight(2); 
     mySimpleXYPlot.addSeries(series2, formatter); 

     // draw a domain tick for each year: 
     mySimpleXYPlot.setDomainStep(XYStepMode.SUBDIVIDE, 9); 
     mySimpleXYPlot.setRangeBoundaries(-20,100, BoundaryMode.FIXED); 

     // customize our domain/range labels 
     mySimpleXYPlot.setDomainLabel("Frequency (Hz)"); 
     mySimpleXYPlot.setRangeLabel("Loud pressure (dB)"); 
     mySimpleXYPlot.getLegendWidget().setVisible(false); 

     // get rid of decimal points in our range labels: 
     mySimpleXYPlot.setRangeValueFormat(new DecimalFormat("0")); 

     //mySimpleXYPlot.setDomainValueFormat(new MyDateFormat()); 

     // by default, AndroidPlot displays developer guides to aid in laying out your plot. 
     // To get rid of them call disableAllMarkup(): 
     mySimpleXYPlot.disableAllMarkup(); 
+0

에서? 도메인 축의 날짜와 동일한 문제가 있습니다. – blackwolf

답변

5

XYStepType.INCREMENT_BY_VALUE

이 모드는 기원 위와 아래 값의 모든 복수의 눈금을 만듭니다. X 마이너스 domainOrigin의 계수가 0이거나 곳 (X)를 더 간단하게 넣어

mySimpleXYPlot.setDomainStep(XYStepMode.INCREMENT_BY_VAL, 1);

이 모든 눈에 보이는 도메인 값 눈금을 그릴 XYPlot을 알려줍니다 다음의 빠른 시작 예를 수정할 수 있습니다 domainOrigin부터 1 씩 증가하는 틱을 그립니다. 지금, 우리의 플롯은 이제 다음과 같습니다

enter image description here

이 문제를 해결하는 모든 성공 androidplot reference