English 中文(简体)
以 x 角为单位的 Android 地块固定值
原标题:Android plot fixed values on x angle

能否创建一个包含固定 x 和 y 值的图表? 我的 x 值是 60, 90, 120, 180, 250, 375, 500, 750, 1000, 但是, 和roidplot 创建了 9 个不同的值, 以等距值为基础 。

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

我使用我的SprotyXYPlot. setDomainStep( XYStepMode. SUBDIVIDE, 9) ; 我猜解决方案围绕这个命令, 但我不知道怎么做。

""https://i.sstatic.net/uXw94.png" alt="此处输入图像描述"/ >

完整代码 :

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();
问题回答

XYStepType.INCROING_BY_VALUE (代号)

This mode creates a tick for every multiple of value above and below the origin. Let s modify the Quick Start example as follows:

mySprotyXYPlot. setDomainStep( XYStepMode.INCROING_BY_VAL, 1); (XYStepMode.INCRAING_BY_VAL, 1);

这让 XYPlot 为每个可见域值 (x) 绘制一个勾, 如果 x 减去 域域名Origin 的模量为零, 或者更简单地说, 从域名Origin 开始, 每递增 1 时画一个勾。 现在, 我们的图像是这样的 :

"https://i.sstatic.net/Q4rfO.jpg" alt="此处的内置图像描述"/ >

发自和roidplot 参考





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签