Вопрос

I am using the GraphView library( Info Source ), and am having trouble with my re-labeling axis. The way my xml file is set up, I have an upper view for the graph then six check boxes below the graph. Each check box represents a different line which is on the graph, and when unchecked, the line will disappear.

enter image description here

The three Net V graphs all have values between -1000 and 1000, while the Diff V graphs have values only between -5 and 5. This looks fine, and the axis is labeled correctly when initially graphed. However, once I uncheck all three Net V checkboxes, the graph resizes to fit the -5 and 5 values. The resizing of the graph works correctly, but the Y axis remains labeled -1000 to 1000. I have noticed that if I swipe my finger on the graph after it resizes then the axis labels fix themselves, but I can not get it to work unless I touch the graph with my finger.

Here is my code for a single check box. The rest of the checkboxes are identical for all intents and purposes

        netV2Check.setOnClickListener( new OnClickListener() {
            public void onClick( View v ) {
                if( hasRead ) {
                    if( ( (CheckBox) v ).isChecked() ) {
                        graphView.addSeries( seriesNetV2 ); 
                        graphView.setScalable(true); 
                        graphView.setViewPort(0, 166);  
                        graphLayout.removeAllViews();
                        graphLayout.addView( graphView );
                    } else {
                        graphView.removeSeries( seriesNetV2 ); 
                        graphView.setScalable(true); 
                        graphView.setViewPort(0, 166);  
                        graphLayout.removeAllViews();
                        graphLayout.addView( graphView );
                    }
                }
            }
        });
Это было полезно?

Решение

It seems that this is a bug in GraphView. I will check this and fix it for the next version.

For a hotfix you could try to call

graphView.redrawAll();

After changing the graph.

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