Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/178.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在Graphview(Android)中使用datapoint的datevalue在datapoint的正下方设置日期标签?_Java_Android_Android Graphview - Fatal编程技术网

Java 如何在Graphview(Android)中使用datapoint的datevalue在datapoint的正下方设置日期标签?

Java 如何在Graphview(Android)中使用datapoint的datevalue在datapoint的正下方设置日期标签?,java,android,android-graphview,Java,Android,Android Graphview,我将Graphview与数据库中的数据点[]一起使用。数据点[]具有以下数据点: [1.582381477E12/0.0](日期为2020-02-22 14:24:37) [1.58238148E12/1.0](日期为2020-02-22 14:24:40) [1.582381489E12/2.0](日期为2020-02-22 14:24:49) [1.582381491E12/3.0](日期为2020-02-22 14:24:51) [1.582381497E12/4.0](日期为2020-0

我将Graphview与数据库中的数据点[]一起使用。数据点[]具有以下数据点:

  • [1.582381477E12/0.0](日期为2020-02-22 14:24:37)
  • [1.58238148E12/1.0](日期为2020-02-22 14:24:40)
  • [1.582381489E12/2.0](日期为2020-02-22 14:24:49)
  • [1.582381491E12/3.0](日期为2020-02-22 14:24:51)
  • [1.582381497E12/4.0](日期为2020-02-22 14:24:57)
  • [1.582381511E12/5.0](日期为2020-02-22 14:25:11)
  • 我在图形视图中使用以下代码:

        DataPoint[] dataPoints = getSucccessData(exercise.getExersiseNumber());
        LineGraphSeries<DataPoint> mLGS = new LineGraphSeries<>(dataPoints);
        mLGS.setDrawDataPoints(true);
        graphView = findViewById(R.id.gvGraphView);
    
        simpleDateFormat = new SimpleDateFormat("dd-M-yyyy hh:mm:ss");
    
        graphView.getGridLabelRenderer().setLabelFormatter(new DefaultLabelFormatter(){
            @Override
            public String formatLabel(double value, boolean isValueX) {
    
                if(isValueX){
                    return simpleDateFormat.format(new Date((long)value));
                }
                else {
                    return super.formatLabel(value, isValueX);
                }
            }
        });
            graphView.removeAllSeries();
            graphView.addSeries(mLGS);
            graphView.getViewport().setMinY(0);
            graphView.getViewport().setMaxY(5);
            graphView.getViewport().setYAxisBoundsManual(true);
            graphView.getViewport().setMinX(dataPoints[0].getX());
            graphView.getViewport().setMaxX(dataPoints[dataPoints.length - 1].getX());
            graphView.getGridLabelRenderer().setNumHorizontalLabels(dataPoints.length -1);
            graphView.getViewport().setXAxisBoundsManual(true);
            graphView.getGridLabelRenderer().setHumanRounding(false, true);
            graphView.getGridLabelRenderer().setHorizontalLabelsAngle(90);
            graphView.getViewport().setScrollableY(true);
            graphView.getViewport().setScrollableY(true);
            graphView.getViewport().setScalable(true);
            graphView.getViewport().scrollToEnd();
            graphView.getViewport().setScrollable(true);
    
    DataPoint[]dataPoints=getsuccessdata(exercise.getexercisensenumber());
    LineGraphSeries mLGS=新的LineGraphSeries(数据点);
    mLGS.setDrawDataPoints(真);
    graphView=findViewById(R.id.gvGraphView);
    SimpleDataFormat=新的SimpleDataFormat(“dd-M-yyyy hh:mm:ss”);
    graphView.getGridLabelRenderer().setLabelFormatter(新的DefaultLabelFormatter(){
    @凌驾
    公共字符串formatLabel(双值,布尔值isValueX){
    if(isValueX){
    返回SimpleDataFormat.format(新日期((长)值));
    }
    否则{
    返回super.formatLabel(值,isValueX);
    }
    }
    });
    graphView.removeAllSeries();
    graphView.addSeries(mLGS);
    graphView.getViewport().setMinY(0);
    graphView.getViewport().setMaxY(5);
    graphView.getViewport().setYAxisBoundsManual(true);
    graphView.getViewport().setMinX(数据点[0].getX());
    graphView.getViewport().setMaxX(数据点[dataPoints.length-1].getX());
    graphView.getGridLabelRenderer().setNumHorizontalLabels(dataPoints.length-1);
    graphView.getViewport().setXAxisBoundsManual(true);
    graphView.getGridLabelRenderer().setHumanRounding(false,true);
    graphView.getGridLabelRenderer().setHorizontalLabelsAngle(90);
    graphView.getViewport().setScrollableY(true);
    graphView.getViewport().setScrollableY(true);
    graphView.getViewport().setScalable(true);
    graphView.getViewport().scrollToEnd();
    graphView.getViewport().setScrollable(true);
    
    结果如下所示:

    正如您所看到的,Xaxis标签除了第一个和最后一个之外,不是我的数据点的x值,它们也不是直接针对特定数据点的。它们是数据点的第一个和最后一个x值之间的日期值,它们之间的距离不同。x值之间的时间越长,数据点之间的距离就越大

    我希望数据点的确切x值作为Xaxis标签,没有其他Xaxis标签,并且数据点之间的距离应始终相同,无论日期之间的时间间隔有多长


    我该怎么做?

    您已经解决了这个问题吗?我也在同一条船上。不,我也在YouTube上问过,问过开发者。。。但是到处都没有答案!这个问题你解决了吗?我也在同一条船上。不,我也在YouTube上问过,问过开发者。。。但是到处都没有答案!