title: How to set up a legend with Graphview in Android Studio
body: <p>I have a screen on my app that display the following graph:</p>
  
  <p><a href="https://i.stack.imgur.com/0PqJz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0PqJz.png" alt="enter image description here"></a></p>
  
  <p>Is there a way to change my legend so that it can say what each color represents? Currently I can get the blue square to show up but it doesn't represent any of the numbers. Here is the code I'm using when creating the graph:</p>
  
  <pre><code>GraphView graph = (GraphView) findViewById(R.id.graph);
  
          BarGraphSeries&lt;DataPoint&gt; series = new BarGraphSeries&lt;DataPoint&gt;(new DataPoint[]{
                  new DataPoint(1, personal),
                  new DataPoint(2, fun),
                  new DataPoint(3, work),
                  new DataPoint(4, food),
                  new DataPoint(5, commute),
                  new DataPoint(6,bills)
          });
  
  
          graph.setTitle("Expenses");
          graph.addSeries(series);
          graph.getLegendRenderer().setVisible(true);
          graph.getLegendRenderer().setAlign(LegendRenderer.LegendAlign.TOP);
          series.setValueDependentColor(new ValueDependentColor&lt;DataPoint&gt;() {
              @Override
              public int get(DataPoint data) {
                  return Color.rgb((int) data.getX() * 255 / 4, (int) Math.abs(data.getY() * 255 / 6), 100);
              }
          });
          series.setSpacing(50);
  
          series.setDrawValuesOnTop(true);
          series.setValuesOnTopColor(Color.RED);
  
          backToMainMenu();
      }
  </code></pre>