2012-05-26 14 views
5

पर निश्चित मान निर्धारित करता है क्या निश्चित x और y मानों वाला चार्ट बनाना संभव है? मेरे एक्स मान 60, 90, 120, 180, 250, 375, 500, 750, 1000 की तरह हैं, लेकिन एंड्रॉइडप्लॉट मूल्यों के बीच समान दूरी के आधार पर 9 अलग-अलग मान बनाता है।एंड्रॉइड प्लॉट x कोण

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

मैं mySimpleXYPlot.setDomainStep उपयोग कर रहा हूँ (XYStepMode.SUBDIVIDE, 9); और मुझे लगता है कि समाधान इस आदेश के आसपास है, लेकिन मुझे नहीं पता कि यह कैसे करना है।

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

इस विधा के ऊपर और नीचे मूल मूल्य के हर एक से अधिक के लिए एक टिक पैदा करता है। के त्वरित आरंभ उदाहरण इस प्रकार संशोधित करते हैं:

mySimpleXYPlot.setDomainStep(XYStepMode.INCREMENT_BY_VAL, 1);

यह XYPlot बताता है कि हर दिखाई डोमेन मूल्य के लिए एक टिक आकर्षित करने के लिए (एक्स) जहां x घटा domainOrigin के मापांक शून्य है, या इसे और अधिक बस डाल करने के लिए , डोमेनऑरिगिन से शुरू होने वाले प्रत्येक की प्रत्येक वृद्धि पर एक टिक खींचें। अब, हमारा साजिश अब इस तरह दिखता है:

enter image description here

से androidplot reference

संबंधित मुद्दे