2

是否有任何现有代码允许从 SQLite 数据库中检索数据并将其显示在图表中?(我希望根据 y(字符串部门)绘制 x(整数人数)图表。以下代码仅允许在类文件中手动输入坐标。

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Vector<SeriesData> sds = new Vector<SeriesData>();
    //line
    SeriesData sd = new SeriesData();       
    sd.setData(new double[][]{{0,0}, {2, 2}, {4, 4}, {8, 8}});
    sds.add(sd);
    //bar
    SeriesData sd2 = new SeriesData();      
    sd2.setData(new double[][]{{0,0}, {2, 2}, {4, 4}, {8, 8}});
    sd2.series.bars.show = true;
    sds.add(sd2);


    FlotDraw fd = new FlotDraw(sds, null, null);

    setContentView(R.layout.main);
    FlotChartContainer tv = (FlotChartContainer)this.findViewById(R.id.flotdraw);
    if(tv != null) {
        tv.setDrawData(fd);
    }

}
4

0 回答 0