gpt4 book ai didi

java - Android MPChart 重置scrollingX

转载 作者:行者123 更新时间:2023-12-01 16:42:14 28 4
gpt4 key购买 nike

所以我目前正在使用 PhilJay ( https://github.com/PhilJay/MPAndroidChart ) 的 MPChart 库,但是我在 x 轴上滚动时遇到了一些问题,因为当我尝试滚动两次时它会重置......我不知道如何为了用文字准确地描述它,所以这是我的问题的视频:

https://youtu.be/h04RItDrE34

如您所见,我无法滚动太远,因为当我尝试第二次滚动时,图表会立即从我开始第一次滚动的地方开始,而不是我结束它的地方...

这是我修改折线图的代码(不应滚动):

LineChart graphView;

public ECGView(LineChart graphView){
this.graphView = graphView;

setup(graphView);
}

public LineChart getGraphView(){
return graphView;
}

public void addFloatArrayToSeries(float[] floats, int color){
ArrayList<Entry> entries = new ArrayList<>();

int i = 0;
for(float val : floats){
entries.add(new Entry(i, val));
i++;
}
LineDataSet lineDataSet = new LineDataSet(entries, "ECG");
lineDataSet.setColor(color);

ArrayList<ILineDataSet> lineDataSetif = new ArrayList<>();
lineDataSetif.add(lineDataSet);
LineData lineData = new LineData(lineDataSetif);

graphView.clear();
graphView.setData(lineData);

}

public void setup(LineChart graphView){
graphView.setBackgroundColor(Color.rgb(45,45,45));
graphView.setScaleYEnabled(false);
}

以及来自 Android 的 xml 布局代码:

<androidx.cardview.widget.CardView
android:id="@+id/ecg_box"
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_margin="10dp"
android:shape="ring"
app:cardCornerRadius="20dp"
app:cardElevation="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.13">

<com.github.mikephil.charting.charts.LineChart
android:id="@+id/ecg_viewer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="5dp"/>

</androidx.cardview.widget.CardView>

有人可以帮助我吗?

最佳答案

我自己解决了这个问题,但是我的图表所在的 Cardview 是问题所在......

关于java - Android MPChart 重置scrollingX,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61840154/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com