sqlite是否接受小數點? 我可以從sqlite數據庫中檢索出小數點數據並顯示在圖表中嗎?SQLite數據庫瀏覽器中的小數點
例如:我存儲我的日期爲「6.10」(10月6日) 以及但是當我找回它,它只能顯示6 所以可我知道如果是我的代碼出了問題的地方?
public class Graph extends Activity implements OnTouchListener
{
private XYPlot mySimpleXYPlot;
private SimpleXYSeries mySeries;
private PointF minXY;
private PointF maxXY;
private double minDif;
private TextView txtView;
final private double difPadding = 0.1;
private float absMinX;
private float absMaxX;
private float minNoError;
private float maxNoError;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.graph);
mySimpleXYPlot = (XYPlot) findViewById(R.id.mySimpleXYPlot);
mySimpleXYPlot.setOnTouchListener(this);
databaseHelper baseHelper = new databaseHelper(this);
try {
baseHelper.createDataBase();
baseHelper.openDataBase();
} catch (IOException ioe) {
ioe.printStackTrace();
}
Cursor a = baseHelper.getData();
Number[] yArray = new Number[a.getCount()];
Number[] xArray = new Number[a.getCount()];
if(a.moveToFirst()){
yArray[0]=a.getInt(2);
xArray[0]=a.getInt(1);
}
for (int i=1; i<a.getCount(); i++) {
if(a.moveToNext()) {
yArray[i] = a.getInt(2);
xArray[i] = a.getInt(1);
}
}
mySimpleXYPlot = (XYPlot) findViewById(R.id.mySimpleXYPlot);
try {
baseHelper.openDataBase();
}catch(SQLException sqle){
System.out.println(sqle);
throw sqle;
}
try {
baseHelper.openDataBase();
baseHelper.fetchAllXYDATA();
}catch(SQLException sqle1){
throw sqle1;
}
//create our series from our array of numbers:
mySeries = new SimpleXYSeries(Arrays.asList(xArray),Arrays.asList(yArray), "Water Spilled");
Widget domainLabelWidget = mySimpleXYPlot.getDomainLabelWidget();
mySimpleXYPlot.position(domainLabelWidget, // the widget to position
45, // x position value, in this case 45 pixels (375)
XLayoutStyle.ABSOLUTE_FROM_LEFT, // how the x position value is applied, in this case from the left
-5, // y position value, 0
YLayoutStyle.ABSOLUTE_FROM_BOTTOM, // how the y position is applied, in this case from the bottom
AnchorPosition.LEFT_BOTTOM);
// AREA INSIDE THE XY AXIS
mySimpleXYPlot.getGraphWidget().getGridBackgroundPaint().setColor(Color.TRANSPARENT);
mySimpleXYPlot.getGraphWidget().getGridLinePaint().setColor(Color.TRANSPARENT);
mySimpleXYPlot.getGraphWidget().getGridLinePaint().setPathEffect(new DashPathEffect(new float[] {1,0},1));
// X-AXIS
mySimpleXYPlot.getGraphWidget().getDomainOriginLinePaint().setColor(Color.WHITE);
//Numbers
//mySimpleXYPlot.getGraphWidget().getDomainLabelPaint().setColor(Color.BLUE);
// Y-AXIS
mySimpleXYPlot.getGraphWidget().getRangeOriginLinePaint().setColor(Color.WHITE);
mySimpleXYPlot.setBorderStyle(Plot.BorderStyle.NONE, null, null);
mySimpleXYPlot.getGraphWidget().getBackgroundPaint().setColor(Color.TRANSPARENT);
mySimpleXYPlot.getBorderPaint().setStrokeWidth(5);
mySimpleXYPlot.getBorderPaint().setAntiAlias(false);
//EXTERIOR BORDER
mySimpleXYPlot.getBorderPaint().setColor(Color.TRANSPARENT);
// Create a formatter to use for drawing a series using LineAndPointRenderer:
LineAndPointFormatter series1Format = new LineAndPointFormatter(
Color.rgb(0, 100, 0), // line color
Color.rgb(0, 100, 0), // point color
Color.rgb(100, 200, 0)); //fill color
// setup our line fill paint to be a slightly transparent gradient:
Paint lineFill = new Paint();
lineFill.setAlpha(200);
lineFill.setShader(new LinearGradient(0, 0, 0, 250, Color.TRANSPARENT, Color.TRANSPARENT, Shader.TileMode.MIRROR));
LineAndPointFormatter formatter = new LineAndPointFormatter(Color.rgb(0, 255, 0), Color.GREEN, Color.GREEN);
formatter.setFillPaint(lineFill);
mySimpleXYPlot.getGraphWidget().setPaddingRight(15);
mySimpleXYPlot.addSeries(mySeries, formatter);
// draw a domain tick for each year:
mySimpleXYPlot.setDomainStep(XYStepMode.SUBDIVIDE, xArray.length);
mySimpleXYPlot.setRangeStep(XYStepMode.SUBDIVIDE, yArray.length);
// customize our domain/range labels
mySimpleXYPlot.setDomainLabel("Date (DD)");
mySimpleXYPlot.setRangeLabel("Water Spill (ml)");
mySimpleXYPlot.getGraphWidget().setRangeLabelWidth(25);
// get rid of decimal points in our range labels:
mySimpleXYPlot.setRangeValueFormat(new DecimalFormat("0"));
mySimpleXYPlot.setDomainValueFormat(new DecimalFormat("0"));
// by default, AndroidPlot displays developer guides to aid in laying out your plot.
// To get rid of them call disableAllMarkup():
mySimpleXYPlot.disableAllMarkup();
mySimpleXYPlot.getScrollX();
mySimpleXYPlot.redraw();
}
你能提供你的CREATE語句嗎? –
SQLite的「直接」識別日期和時間字符串記錄在這裏:http://www.sqlite.org/lang_datefunc.html - DD.MM(如6.10)不直接支持 - 而且絕對不會產生直接提取時可用的整數值。我會重新考慮您的域值如何存儲。 – Jens