title: MPAndroidChart conditional dataset color
body: <p>Hello folks: I am wondering if there is a better way to conditional coloring bars using MPAndroidChart. My solution is create a conditional array of colors as follows:</p>
  
  <pre><code>private void setDataColored(List&lt;String&gt; labels, List&lt;Float&gt; values) {
  
      final int greenColor = Color.parseColor("#66bb6a");
      final int redColor = Color.parseColor("#ef5350");
      ArrayList&lt;BarEntry&gt; entries = new ArrayList&lt;&gt;();
      List&lt;Integer&gt; colors = new ArrayList&lt;&gt;();
  
      for (int pos = 0; pos &lt; values.size(); pos++) {
          Float value = values.get(pos);
          entries.add(new BarEntry(Math.abs(value), pos));
          colors.add(value &gt;= 0 ? greenColor : redColor);
      }
  
      BarDataSet dataset = new BarDataSet(entries, "Values");
      dataset.setColors(colors);
  
      ArrayList&lt;BarDataSet&gt; dataSets = new ArrayList&lt;BarDataSet&gt;();
      dataSets.add(dataset);
  
      BarData data = new BarData(labels, dataSets);
      data.setDrawValues(true);
  
      mChart.setData(data);
  }
  </code></pre>
  
  <p>I am worry about performance, since I need to create this <code>colors</code> array. Derived problem is Legend: I cant visualize properly specifying red and green color meaning.</p>