1
votes

I'm using Androidplot to create my charts.

I want to use the

oneChart.setDomainStep(XYStepMode.INCREMENT_BY_VAL, 1); 

command but everytime I run my app and want to draw a graph the app crashes after blackscreen. how to fix this?

No exception or error is thrown in logcat.

If I use the SUBDIVIDE everything works fine.

More Code:

XYPlot oneChart = (XYPlot) findViewById(R.id.oneChart);
XYSeries[] series = new SimpleXYSeries(
                Arrays.asList(nX), 
                Arrays.asList(nY),
                getTitle);
    oneChart.disableAllMarkup();
            oneChart.getGraphWidget().setMarginTop(10);
            oneChart.getGraphWidget().setMarginRight(30);
            oneChart.getGraphWidget().getGridBackgroundPaint().setColor(Color.LTGRAY);
            oneChart.getGraphWidget().getGridLinePaint().setColor(Color.BLACK);
            oneChart.getGraphWidget().getDomainOriginLinePaint().setColor(Color.BLACK);
            oneChart.getGraphWidget().getRangeOriginLinePaint().setColor(Color.BLACK);
            oneChart.getGraphWidget().getGridLinePaint().setPathEffect(new DashPathEffect(new float[]{1,1}, 1));        
            oneChart.getBorderPaint().setStrokeWidth(1);
            oneChart.getBorderPaint().setAntiAlias(true);
            oneChart.getBorderPaint().setColor(Color.LTGRAY);

        LineAndPointFormatter seriesFormat = new LineAndPointFormatter(
                Color.rgb(0, 0, 200), // line color
                Color.rgb(0, 0, 100), // point color
                Color.rgb(100, 100, 240)); // fill color (optional)
        Paint lineFill = new Paint();
    lineFill.setAlpha(200);        
    lineFill.setShader(new LinearGradient(0, 0, 0, 250, Color.WHITE, Color.BLUE, Shader.TileMode.CLAMP));
        seriesFormat.setFillPaint(lineFill);
    oneChart.addSeries(series, seriesFormat);
1

1 Answers

2
votes

That line seems correct. I've tested it. Provide us some more code.

EDIT: I've tested your code using some random values and including the line oneChart.setDomainStep(XYStepMode.INCREMENT_BY_VAL, 1);.

Everything seems fine. Except the thing that I've changed

XYSeries[] series = new SimpleXYSeries(

to

SimpleXYSeries series = new SimpleXYSeries (

Plot image

Here is the main.xml layout:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:background="#FFFFFF">

<com.androidplot.xy.XYPlot android:id="@+id/oneChart"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:layout_marginTop="0px" android:layout_marginLeft="0px"
    android:layout_marginRight="0px" title="My Plot" />
</LinearLayout>

P.S.Sorry for the late response.