title: AndroidPlot: How to render a chart in an AppWidget?
body: <p>I'm trying to use AndroidPlot to draw a chart in a homescreen widget.
  I know that in a normal app, it uses a custom view and from what I've seen (<a href="https://stackoverflow.com/questions/4062559/android-appwidget-with-custom-view-not-working">Android: AppWidget with custom view not working</a>), the workaround is to render this as a bitmap in an <code>imageView</code>.</p>
  
  <p>Now I've taken the quickstart code for AndroidPlot and put it into the provider class but it doesn't seem to render anything when I drop it on the homescreen.</p>
  
  <p>The difference between this code and the original quickstart code is that in the quickstart, it leverages the <code>Activity.findViewById</code> but obviously it can't be used here.  </p>
  
  <p>Can anyone see something here that I'm doing wrong that may be causing the empty rendering?
  Appreciate any help you could provide!</p>
  
  <pre><code>private Bitmap getChartImage(Context context)
  {
  
      // initialize our XYPlot reference:
      mySimpleXYPlot = new XYPlot(context, "My Simple XYPlot");
  
      mySimpleXYPlot.setDrawingCacheEnabled(true);
  
      // add a new series
      mySimpleXYPlot.addSeries(new SimpleXYSeries(), LineAndPointRenderer.class, new LineAndPointFormatter(Color.rgb(0, 200, 0), Color.rgb(200, 0, 0)));
  
      // reduce the number of range labels
      mySimpleXYPlot.getGraphWidget().setRangeTicksPerLabel(4);
  
      // reposition the domain label to look a little cleaner:
      Widget domainLabelWidget = mySimpleXYPlot.getDomainLabelWidget();
  
      mySimpleXYPlot.position(domainLabelWidget,                     // the widget to position
                              45,                                    // x position value, in this case 45 pixels
                              XLayoutStyle.ABSOLUTE_FROM_LEFT,       // how the x position value is applied, in this case from the left
                              0,                                     // y position value
                              YLayoutStyle.ABSOLUTE_FROM_BOTTOM,     // how the y position is applied, in this case from the bottom
                              AnchorPosition.LEFT_BOTTOM);           // point to use as the origin of the widget being positioned
  
      // get rid of the visual aids for positioning:
      mySimpleXYPlot.disableAllMarkup();
  
      //mySimpleXYPlot.measure(150, 150);
      //mySimpleXYPlot.layout(0, 0, 150, 150);
  
  
      Bitmap bmp = mySimpleXYPlot.getDrawingCache();
  
      return bmp;
  }
  </code></pre>