如何在折线图中实现多个高亮线滑块 [英] How to implement multiple highlight line sliders in line chart

查看:1692
本文介绍了如何在折线图中实现多个高亮线滑块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在折线图中实现单个和多个高亮线滑块。我只能使用MPAndroidChart获取单个高亮线滑块( https://github.com/PhilJay/MPAndroidChart)库。但我还需要两个高亮线滑块,以允许用户在图表上选择值的范围(最小值和最大值)。请参阅以下图片了解详情:





我们可以使用任何库实现上述要求,还是需要绘制自定义视图?

解决方案

shinobicharts 方面,而十字线可以很容易地定制为像一个滑块,以便有两个滑块,你可能想利用注释功能。



你可以创建带有自定义视图的注释,并将它们添加到任何X,Y点(数据术语)。您还可以通过轴在数据值和像素值之间进行转换。因此,当他们在屏幕上拖动时,可以使注释跟随用户的手指。



最棘手的部分是将圆圈放在LineSeries上的右侧Y-值。正如我上面提到的,你可以将像素值(例如从用户手势)转换为数据值,这样你可以很容易地获得X值,但API将留下相当多的工作,以获得正确的Y值。 / p>

这种功能是经常要求的,我们正在寻找的是未来提供的东西,但现在,虽然可能,它不可用-of-the-box。



免责声明:我适用于 shinobicontrols


I want to implement single and multiple highlight line sliders in line chart. I am able to get only single highlight line slider with MPAndroidChart (https://github.com/PhilJay/MPAndroidChart) library. But I also need two highlight line sliders to allow the user to select range of values(min and max values) on the chart. Please refer the below image for more information:

Can we achieve the above requirement with any library or we need to draw a custom view? Any help or guidance will be well appreciated.

解决方案

In terms of shinobicharts, while the Crosshair could be easily customised to act like one of sliders, in order to have the two sliders you'd probably want to make use of the Annotations feature.

You can create Annotations with custom Views and add them at any X, Y point (in data terms). You can also convert between data values and pixel values via the Axes. It is therefore possible to make the Annotation follow the user's finger as they drag across the screen.

The trickiest part would be placing the circle on the LineSeries at the right Y-value. As I mentioned above you can convert pixel values (e.g. from a user gesture) to data values so you could easily get the X value but the API would leave quite a bit of work up to you in order to get the correct Y value.

This kind of feature is something that is requested quite often and is certainly something we are looking at providing in the future but for now, while possible, it isn't available out-of-the-box.

Disclaimer: I work for shinobicontrols

这篇关于如何在折线图中实现多个高亮线滑块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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