画在Android的一个图 [英] Draw a Graph in Android

查看:96
本文介绍了画在Android的一个图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想画在Android的图形使得在X轴我想几个月像一月,二月,三月,四月,五月,六月,八月,九月,十月,十一月,十二月和Y轴的数量多少,你花费在那个特定的月份。

I wanted to draw a graph in Android such that on X axis I want Months like Jan, Feb, March, Apr, May, Jun, Aug, Sep, Oct, Nov, Dec and on Y axis the amount how much you spending in that particular month.

我有一个code表示绘制图形上的机器人: -

I have a code that draw the graph on an android:-

mySimpleXYPlot = (XYPlot) findViewById(R.id.mySimpleXYPlot);
        Number[] series1Numbers = { 1, 8, 5, 2, 7, 4 };
        Number[] series2Numbers = { 4, 6, 3, 8, 2, 10 };
        XYSeries series1 = new SimpleXYSeries(Arrays.asList(series1Numbers),
        SimpleXYSeries.ArrayFormat.Y_VALS_ONLY,"Series1");
        XYSeries series2 = new SimpleXYSeries(Arrays.asList(series2Numbers),
        SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "Series2");

        LineAndPointFormatter series1Format = new LineAndPointFormatter(
                Color.rgb(0, 200, 0), // line color
                Color.rgb(0, 100, 0), // point color
                Color.rgb(150, 190, 150)); // fill color (optional)
                mySimpleXYPlot.addSeries(series1, series1Format);
                mySimpleXYPlot.addSeries(
                series2,
                new LineAndPointFormatter(Color.rgb(0, 0, 200),
                Color.rgb(0, 0, 100), Color.rgb(150, 150, 190)));
                mySimpleXYPlot.setTicksPerRangeLabel(3);
                }

但我想在X轴个月,他们就在这一个月花Y轴特定的金额。这些值是从数据库,一个月中,他们是在reuqired月,他们花和名称中包含他们在这个月花值花钱在周一的表单来的。

But I want on X Axis the Months and on Y axis particular amount they spend in that month. and these values are coming from database, month in which they are spending money in the form of mon the reuqired month they spend and Name contains the value they spend in that month.

try {
        myDB = this.openOrCreateDatabase("Expense_db", MODE_PRIVATE, null);

        Cursor c = myDB.rawQuery("SELECT project_android.Month AS Month_Real, " +
                  "SUM(Total) AS OrderTotal FROM project_android " +
                  "WHERE Year='"+value1+"' " +
                  "GROUP BY project_android.Month " , null);

                     int Column1 = c.getColumnIndex("Month_Real");
                     int Column2 = c.getColumnIndex("OrderTotal");
                     //int current=0;
                  // Check if our result was valid.
                     c.moveToFirst();
                     if (c != null) {
                      // Loop through all Results
                     do {
                       mon = c.getString(Column1);               
                       Name = c.getDouble(Column2);
                       Log.i(TAG, "Testing_value_graph_month: " + Name + " | " + mon + " " );

                     }while(c.moveToNext());
                     c.close();
                     }
                     }
    catch(Exception e) {
        Log.e("Error", "Error", e);
       } finally {
        if (myDB != null)
         myDB.close();
       }

任何帮助将AP preciated ..!

Any help will be appreciated..!

推荐答案

我用这个

点击此处

$ C $下同样的要求希望它会帮助你。

code for same requirement hope it will help you

这篇关于画在Android的一个图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆