如何设置 XAxis 的起始索引? [英] How to set start index for XAxis?

查看:51
本文介绍了如何设置 XAxis 的起始索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示带有与时间相关的值的 LineChart.

I want to display LineChart with values associated with time.

目前条目的 X 索引是一天中以分钟为单位的时间显示(例如值 (11.04,14:30),它的 X 索引是 870).

Currently X index for Entries is it's time presentation in minutes for the day (like for value (11.04,14:30) it's X index is 870).

一个图表中的时间差异可能很小,所以我想设置 XAxis 左侧的起始位置 - 因此对于 14:30 时间的第一次输入,XAxis 的起始位置可能是 14:00(840 索引).

Difference in times in one chart could be small, so i want to set the start position for left side of XAxis - so for first entry with 14:30 time the start position for XAxis could be 14:00 (840 index).

我尝试使用 moveViewToX(840) 来做到这一点,即setVisibleXRangeMaximum(6*30); ,但 XAxis 从 0 开始,因为没有那个调用.

I've tried to do this with moveViewToX(840) accompanied with i.e. setVisibleXRangeMaximum(6*30); , but XAxis starts from 0 as without that call.

我可以修改每个条目的 xvalues(即从它的 x 值中减去当前开始时间"的值),然后使用 XValueFormatter 正确显示索引标签,但我希望有另一种更方便的方法.添加动态数据可能不是那么简单的任务..

I can modify each Entry's xvalues (i.e. subtract from it's x-value the value of current 'start time') and then use XValueFormatter to display index label properly, but i hope there is another, more handy way. With dynamic data adding it could be not so simple task..

推荐答案

我好像没看好 wiki

It seems that i haven't read wiki well

请注意,所有修改视口的方法都需要在设置数据后在Chart上调用.

Please note that all methods modifying the viewport need to be called on the Chart after setting data.

setVisibleXRangeMaximum 在我将条目添加到图表后调用它时开始工作.第一次尝试在仅添加 XValues 后立即调用它.

setVisibleXRangeMaximum begin to work when I call it after adding Entries to the chart. At first try it was called right after adding only XValues.

这篇关于如何设置 XAxis 的起始索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆