Вопрос

I'm having a problem with this implementation:

       if(blueActive) {
            blueFormat = new LineAndPointFormatter(Color.rgb(0,0,255), null, null);
            blue = new SimpleXYSeries(xArray,yArray, selectedDate);
            Log.e(TAG , "blueActive");
            cvPlot.addSeries(blue, blueFormat);
        }
        if(redActive) {
            redFormat = new LineAndPointFormatter(Color.rgb(255,0,0), null, null);
            red = new SimpleXYSeries(xArray,yArray, selectedDate);
            Log.e(TAG , "redActive");
            cvPlot.addSeries(red, redFormat);
        }
        if(greenActive) {
            greenFormat = new LineAndPointFormatter(Color.rgb(0,255,0), null, null);
            green = new SimpleXYSeries(xArray,yArray, selectedDate);
            Log.e(TAG , "greenActive");
            cvPlot.addSeries(green, greenFormat);
        }

        cvPlot.redraw();

The series are plotted with the correct xArray and yArray, but when the graph redraws, all the plots are the same color. I'm looking for this code to redraw the plot with three different colors. Am I doing something logically wrong here?

Это было полезно?

Решение

Although this question wasn't very descriptive with the other code involved, ultimately the answer was to add this into the onClick that started the process of adding the plots:

xArray.clear(); yArray.clear();

The lines were overlapping, and when the next color was added, since the red plot was selected after blue, the two arrays grew to include the points of the blue and red, making it look like the color wasn't changing. In other words, the red array included the blue array, and since those points were identical to the blue plot, I couldn't see the blue plot since the red plot was on top!

I had set up a Log.d long before this problem but really didn't notice the array doubling since I didn't log the count because I only wanted to see that the x and y values were populating.

Log your array counts and clear your arrays rook dawg!!

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top