MPAndroidChart with null values

前端 未结 2 505
温柔的废话
温柔的废话 2020-12-19 16:38

I\'m using the MPAndroidChart and am really enjoying it.

A \'little\' need I have is that I can put null values to the \'entrys\'. I\'m monitoring the apache conecti

2条回答
  •  無奈伤痛
    2020-12-19 17:22

    A possible solution for you could be to check weather the object you received is null, or not. If the object is null, you don't even create an Entry object instead of just setting it's value to null.

    Example:

    // array that contains the information you want to display
    ConnectionHolder[] connectionHolders = ...;
    
    ArrayList entries = new ArrayList();
    int cnt = 0;
    
    for(ConnectionHolder ch : connectionHolders) {
    
        if(ch != null) entries.add(new Entry(ch.getNrOfConnections(), cnt));
        else {
            // do nothing
        }
    
        cnt++; // always increment
    }
    

    This would create e.g. a LineChart where no circles are drawn on indices where the ConnectionHolder object was null.

    For a future release of the library, I will try to add the feature so that null values are supported.

提交回复
热议问题