mpandroidchart线图标签
I want to achieve an effect similar to this using the MPAndroidChart library
I want my label to be attached to the Chart line or at least be close to it. Is something like this possible using this library? Or is there a walkaround for this? Something that will have a similar result
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种可能的方法是使用标记,Chart.SetMarker(),但是标记仅显示何时在图表上点击何时,如果您希望标记不断显示,则可以调用自定义图表并覆盖像这样的函数绘制标记器,标记在图表的中间绘制:
图片如下所示,黄色标记是标记,它会不断显示,没有用户点击:

7月5日更新
-----在Demo LineChartactivity1 ( https://github.com/philjay/mpandroidchart/blob/master/master/mpchartexample/src/main/main/java/java/java/java/java/xxmassdeveloper/mpcharteveliper/mmpchartexamplivity/linechartexample/linechartacmellive/linechartacmellive1.java ) );设置标记,并通过新的Mymarkerview分配。可以在 https://github.com/philjay/mpandroidchart/blob/master/master/mpchartlib/src/src/main/java/java/java/java/github/github/mikephil/mikephil/charting/charts/linecharts/linechart.java,2.java 定制图表从Linechart延伸
A possible way is to use the marker, chart.setMarker(), but marker only shows when user tap on the chart, if you want the marker to show constantly, an custom chart can be invoked and override the function drawMarkers like this, the marker is drawn in the middle of chart:
Picture as below, the yellow tag is the marker, it is displayed constantly and without a user tap:

----Updated July 5th
In the demo LineChartActivity1(https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/LineChartActivity1.java), line 98, chart.setMarker(mv); sets the Marker, and it allocated by new an MyMarkerView. The drawMarkers can be added at https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartLib/src/main/java/com/github/mikephil/charting/charts/LineChart.java, but it's better to use a customed Chart extends from LineChart