我使用AChartEngine Api创建了动态折线图,显示了G-Force值的变化.一切正常,但当图形在X轴向前移动时,我必须在X轴上手动滚动才能进一步查看,如果您没有正确使用我,请查看下面的图像.
如何让它在x轴上自动滚动以避免手动滚动?
以下是我的代码
public class GraphActivity extends Activity implements SensorEventListener{
private LinearLayout lyGforce;
//=== G-force =======
private SensorManager mSensorManager;
private Sensor mAccelerometer;
private float gOffset;
private boolean calibrate;
private static TimeSeries timeSeriesGforce;
private static XYMultipleSeriesDataset datasetGforce;
private static XYMultipleSeriesRenderer rendererGforce;
private static XYSeriesRenderer rendererSeriesGforce;
private static GraphicalView viewGforce;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.mainactivity);
lyGforce = (LinearLayout) findViewById(R.id.lygforce);
//=========== G-force =======
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); …Run Code Online (Sandbox Code Playgroud) 嗨,我正在尝试使用此库绘制图表,但其条目静态如下:
LineGraphSeries<DataPoint> series = new LineGraphSeries<DataPoint>(new DataPoint[] {
new DataPoint(0, 1),
new DataPoint(1, 5),
new DataPoint(2, 3),
new DataPoint(3, 2),
new DataPoint(4, 6)
});
graph.addSeries(series);
Run Code Online (Sandbox Code Playgroud)
我如何解决这个接受前的问题.在运行时创建的列表视图元素?基本上我想要这样的东西:
for (int i = 0; i < list.size(); i++) {
LineGraphSeries<DataPoint> series = new LineGraphSeries<DataPoint>(new DataPoint[] {
new DataPoint(i, list.getElement()),
});
}
Run Code Online (Sandbox Code Playgroud) 我有一个这样的情节设置:
aHistoryPlot = (XYPlot) findViewById(R.id.plot);
aHistoryPlot.setRangeBoundaries(0, 255, BoundaryMode.FIXED);
aHistoryPlot.setDomainBoundaries(0, HISTORY_SIZE, BoundaryMode.FIXED);
aHistoryPlot.addSeries(YHistorySeries, new LineAndPointFormatter(Color.rgb(100, 200, 100), Color.TRANSPARENT, null));
aHistoryPlot.getGraphWidget().setMarginTop(10);
aHistoryPlot.setDomainStepValue(5);
aHistoryPlot.setTicksPerRangeLabel(3);
aHistoryPlot.setDomainLabel(getResources().getString(R.string.string_time));
aHistoryPlot.getDomainLabelWidget().pack();
aHistoryPlot.setRangeLabel(getResources().getString(R.string.string_value));
aHistoryPlot.getRangeLabelWidget().pack();
aHistoryPlot.disableAllMarkup();
Run Code Online (Sandbox Code Playgroud)
如何从图中删除域值?
提前致谢!
我正在使用链接中的一些安卓库.. https://github.com/jjoe64/GraphView-Demos ..我尝试使用实时图形示例,https://github.com/jjoe64/GraphView-Demos/ blob/master/src/com/jjoe64/graphviewdemos/RealtimeGraph.java ...它对我很有用,但我没有问题xy轴刻度设置.在重新运行图表期间加载新数据时,所有xy轴比例值都会根据输入数据值进行更改.
我希望将y轴固定在1到6的范围内,x从1到30固定..每个轴的增量刻度为1 ..这个轴标签值应该总是固定的,图形应该根据输入数据改变.我需要一些固定的实验室.
我发现很难弄清楚如何在 Android 中的图表的 X 轴上实现时间?
这是我的代码:
for (int i = 0; i < listSize; i++)
{
String[] onlyReading = mData.get(i).getReading().split(" ");
readingList[i] = Double.parseDouble(onlyReading[0]);
String date = mData.get(i).getUnFormatedDate();
String[] temp = date.split(" ");
String[] dateTemp = null;
String[] timeTemp = null;
if(temp.length > 0)
{
dateTemp = temp[0].trim().split("-");
timeTemp = temp[1].trim().split(":");
Date dateObj = new Date();
String year = "0";
if(dateTemp != null)
{
dateObj.setDate(Integer.parseInt(dateTemp[0]));
dateObj.setMonth(Integer.parseInt(dateTemp[1]) - 1);
year = dateTemp[2].trim();
if(dateTemp[2].trim().length() == 4)
{
year = dateTemp[2].substring(2, 4);
} …Run Code Online (Sandbox Code Playgroud) 目前,下面的代码显示附加的条形图,其中包含小数位数,从2开始.
我的问题是:有没有办法从0开始y轴标签,并将整数增加到数据的最大值?例如,在这,0,1,2,3,4,5?
barData = this.getIntent().getExtras().getString("GraphData");
GraphViewSeries barGraphSeries = new GraphViewSeries(
new GraphViewData[] {
new GraphViewData(0, Integer.parseInt(barData
.substring(0, barData.indexOf(",")))),
new GraphViewData(1, Integer.parseInt(barData
.substring(barData.indexOf(",") + 1,
barData.length()))) });
GraphView statGraphView = new BarGraphView(this,
"Current Stat Graph");
statGraphView.getGraphViewStyle().setGridColor(Color.BLACK);
statGraphView.getGraphViewStyle().setHorizontalLabelsColor(
Color.BLACK);
statGraphView.getGraphViewStyle().setVerticalLabelsColor(
Color.BLACK);
String[] horLabels = { "Correct", "Incorrect" };
statGraphView.setHorizontalLabels(horLabels);
statGraphView.getGraphViewStyle().setNumHorizontalLabels(2);
statGraphView.getGraphViewStyle().setNumVerticalLabels(10);
statGraphView.addSeries(barGraphSeries);
LinearLayout layout = (LinearLayout) findViewById(R.id.graph1);
layout.addView(statGraphView);
Run Code Online (Sandbox Code Playgroud)

我创建了一个LineGraph,它看起来像这样:

但我想填写grap下方的区域,如下所示:

我该如何实现此功能?你能帮助我吗?
我是android 中MPAndroidChart的新用户.谁能帮我 ?
我正在尝试使用GraphView库绘制图形.我的问题是,x轴没有显示,但y轴可以.此外,x轴标签上的值也没有显示出来.
这是我的xml文件:
<com.jjoe64.graphview.GraphView
android:id="@+id/graph"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:background="#FAFA82" />
Run Code Online (Sandbox Code Playgroud)
和java代码:
double graph1LastXValue = 5d;
GraphView graph = (GraphView) findViewById(R.id.graph);
graph.getGridLabelRenderer().setVerticalAxisTitle("Match Value");
graph.getGridLabelRenderer().setHorizontalAxisTitle("Time/s");
Series2 = new LineGraphSeries<DataPoint>();
mSeries1.setColor(Color.RED);
mSeries1.setThickness(2);
graph.addSeries(mSeries2);
graph.getViewport().setXAxisBoundsManual(true);
graph.getViewport().setMinX(0);
graph.getViewport().setMaxX(100);
graph.getGridLabelRenderer().setGridStyle(GridStyle.BOTH);
plotter(matchValMean);
protected void plotter(Double matchVal) {
matchValue = matchVal;
// TODO Auto-generated method stub
mTimer1 = new Runnable() {
@Override
public void run() {
graph1LastXValue += 1d;
mSeries1.appendData(new DataPoint(graph1LastXValue, matchValue), true, 100);
mHandler.postDelayed(this, 1000);
}
};
mHandler.postDelayed(mTimer1, 1000);
}
Run Code Online (Sandbox Code Playgroud)
我没有显示所有代码,因为它很长.提前致谢 :)
我正在对加速度计传感器进行采样,并使用库(4.0.1)实时呈现图表Graph View。
该应用程序运行良好,只是图表错误:
正如您在图片中看到的,Z 轴(洋红色)的值为 ~9.8,但在图表中显示为 ~15,Y 轴(绿色)的值为 0.2,但在图表中我们在零和相同的想法下与 X 轴。
这是我的代码:
SensorManager sensorManager;
TextView tvX, tvY, tvZ;
GraphView graph;
LineGraphSeries<DataPoint> seriesX, seriesY, seriesZ;
long startTime;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_runtime_graph);
tvX = (TextView) findViewById(R.id.tvAcc_X); // color : blue
tvY = (TextView) findViewById(R.id.tvAcc_Y); // color : green
tvZ = (TextView) findViewById(R.id.tvAcc_Z); // color : magenta
graph = (GraphView) findViewById(R.id.graph);
seriesX = new LineGraphSeries<>();
seriesY = new LineGraphSeries<>();
seriesZ = new LineGraphSeries<>();
seriesX.setColor(Color.BLUE);
seriesY.setColor(Color.GREEN);
seriesZ.setColor(Color.MAGENTA);
graph.addSeries(seriesX); …Run Code Online (Sandbox Code Playgroud)