I'm currently developing an Android application for a university stage. This application has to draw a plot with data which are coming from some pressure sensor, to draw this plot I'm using Androidplot library.
I'm following this example on Andrloidplot docs to create a dynamic XYPlot and I have imported androidplot-core:1.1.0 in the project dependencies.
In the code editor I'm getting the "Cannot resolve .... method" error everytime I call getGraphWidget(), setRangeValueFormat() and when I try to access XYStepMode fields.
I have searched for this issue on internet and on Androidplot docs but I haven't find anything usefull. I think that this is produced by some import that I have missed, but I'm not figuring out what I've forgotten.
Someone has already dealed with this problem and solved it?
Here's a part of my class where I get the first error occurrence, it is on the last line:
import android.graphics.Color;
import android.graphics.DashPathEffect;
import android.graphics.Paint;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.androidplot.Plot;
import com.androidplot.util.PixelUtils;
import com.androidplot.xy.XYSeries;
import com.androidplot.xy.*;
import java.text.DecimalFormat;
import java.util.Observable;
import java.util.Observer;
/**
 * Created by marco on 07/09/16.
 */
public class GraphicChart extends Fragment {
    private XYPlot dynamicPlot;
    private MyPlotUpdater plotUpdater;
    SampleDynamicXYDatasource data;
    private Thread myThread;
    public GraphicChart(){}
    // redraws a plot whenever an update is received:
    private class MyPlotUpdater implements Observer {
        Plot plot;
        public MyPlotUpdater(Plot plot) {
            this.plot = plot;
        }
        @Override
        public void update(Observable o, Object arg) {
            plot.redraw();
        }
    }
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.graphic_chart_fragment, container, false);
        // get handles to our View defined in layout.xml:
        dynamicPlot = (XYPlot)getActivity().findViewById(R.id.dynamic_plot);
        plotUpdater = new MyPlotUpdater(dynamicPlot);
        // only display whole numbers in domain labels
        dynamicPlot.getGraphWidget().setDomainValueFormat(new DecimalFormat("0"));  //FIRST ERROR ON THIS LINE
                Finally I've resolved it, I've compared sources from the site I've linked and the one on gitHub.
Here changes I've made:
lines
// only display whole numbers in domain labels dynamicPlot.getGraphWidget().setDomainValueFormat(new DecimalFormat("0"));
are now
// only display whole numbers in domain labels
        dynamicPlot.getGraph().getLineLabelStyle(XYGraphWidget.Edge.BOTTOM).
                setFormat(new DecimalFormat("0"));
XYStepMode is now only StepMode
The call to dynamicPlot.setRangeValueFormat(new DecimalFormat("###.#")); is now done in this way
dynamicPlot.getGraph().getLineLabelStyle(                    XYGraphWidget.Edge.LEFT).setFormat(new DecimalFormat("###.#"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With