Note that there are some explanatory texts on larger screens.

plurals
  1. POShow bar graph with sqlite table data in android?
    text
    copied!<p>i am very new to Android with graphs in my SQLite table having the data i want display that data in X and Y axies with graph . my database values or is as fallows :</p> <pre><code>productId Qty 2100021 20 2100022 50 </code></pre> <p>i want to plot the graph for these values in Android in X and Y axes.</p> <p>i write the following code</p> <p>public class SalesTrackingByCustomer extends Activity {</p> <pre><code>private DBAdapter db; private Spinner spinner1, spinner2; private String[] prodctnames; private String[] prodctnames1; private double[] product_1; private double[] product_2; public int count; public String custid; public Sample customerdetails; public ChartCollection&lt;String&gt; collection; ChartArea area; ChartArea area1; private SimpleAdapter mSchedule; Vector&lt;String&gt; vec_custid=new Vector&lt;String&gt;(); Vector&lt;String&gt; vec_oldno=new Vector&lt;String&gt;(); Vector&lt;String&gt; vec_productid=new Vector&lt;String&gt;(); Vector&lt;String&gt; vec_qty=new Vector&lt;String&gt;(); private ListView mListView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.bycustomers); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); mListView=(ListView)findViewById(R.id.listView1); prodctnames=new String[10]; product_1=new double[10]; prodctnames1=new String[10]; product_2=new double[10]; db=new DBAdapter(this); final ChartView chartView = (ChartView) findViewById(R.id.chartView); ChartPalette palette = new ChartPalette(0xffffd7e8); chartView.setPalette(palette); final ChartSeries product1 = new ChartSeries("P1", ChartTypes.Column); spinner1 = (Spinner) findViewById(R.id.spinner1); spinner1.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView&lt;?&gt; arg0, View arg1, int arg2, long arg3) { // TODO Auto-generated method stub int position=spinner1.getSelectedItemPosition(); System.out.println("=====ITEM POSITION======"+position); final String selected=arg0.getItemAtPosition(arg2).toString(); System.out.println("=====IN SELECTED======"+selected); db.open(); Cursor customer=db.fetchorderCustomername(selected); custid=customer.getString(0); System.out.println("=====CUSTOMER NAME ID======"+custid); Cursor cursor=db.fetchorderDetails(custid); count=cursor.getCount(); System.out.println("=====COUNT======"+count); int i=0; while (i&lt;count) { String productid=cursor.getString(1); prodctnames[i]=productid; String qty=cursor.getString(2); product_1[i]=Double.parseDouble(qty); System.out.println("=====PROID======"+prodctnames[i]+"=====QUANTITY======"+product_1[i]); cursor.moveToNext(); i++; } for (int j = 0; j &lt; count; j++) { ChartPoint point = product1.getPoints().addXY(j, product_1[j]); point.setAxisLabel(prodctnames[j]); } if(position==0) { chartView.refreshDrawableState(); chartView.getSeries().add(product1); area = chartView.getAreas().get(0); area.getDefaultXAxis().setLabelsMode(ChartAxis.LabelsMode.SeriesLabels); } if(position==1) { chartView.refreshDrawableState(); chartView.getSeries().add(product1); area1 = chartView.getAreas().get(0); area1.getDefaultXAxis().setLabelsMode(ChartAxis.LabelsMode.SeriesLabels); } //area.refresh(); db.close(); } @Override public void onNothingSelected(AdapterView&lt;?&gt; arg0) { // TODO Auto-generated method stub } }); </code></pre> <p>Thanks in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload