mpandroidchart

Passing current time in milliseconds to MPChart breaks it

橙三吉。 提交于 2019-12-11 17:06:49
问题 I have tried figuring this out, but it doesn't add up. The data doesn't appear as it should. First I generate dummy data. This is done async because I need time between the calls to System.currentTimeMillis to get some spacing between them. (Look aside the crappy code here, this is just debug data that will not be in the release. Using Thread.sleep on the main thread is a bad idea considering ANR's) public class AsyncGeneration extends AsyncTask<String, String, String>{ public AsyncGeneration

How to set Viewport Range via values at MpAndroidChart?

不想你离开。 提交于 2019-12-11 16:50:57
问题 I have dataset values at range [0-10000]. And I want to see range [500-600] at chart with automatically calculated scroll and zoom values. How it can be done in MPAndroidChart? Is there any method to setXRange(leftXValue, rightXValue)? 回答1: First set the max visible range. So if you want to display the range of 500-600, set a max visible range of 100 mChart.setVisibleXRangeMaximum(100); than you have to move your view so that the values are visible from the 500th position mChart.moveViewToX

mpandroidchart I want to get 3rd value

江枫思渺然 提交于 2019-12-11 15:32:21
问题 I am using mpandroidchart and i have a problem now I set 3 values into the array likes this (index, values, and another value) ArrayList<Entry> value1 = new ArrayList<>(); for (int i = 0; i < 10; i++) { float y = (float) Math.random(); float h = (float) Math.random(); value1.add(new Entry(i, y, h)); } I want to get h values to use this h but i cant' find the way How can i get h value? Thanks for reading *Edited * enter image description here This is the image i want to make * Edited2 *

MpAndroidChart set background between limit lines

不想你离开。 提交于 2019-12-11 13:13:17
问题 I a using MpAndroidChart library. I need to implement a design where I need to color the area between two limit lines. I have attached an image for reference. I have tried multiple ways but I have failed to achieve it. I am using this library for the first time. Can anyone help me about how this could be achieved. As you can see the green shade behind the line graph. Which is the limit. I need to get that green shade Thanks in advance, Anudeep Reddy. 回答1: I don't think that there is a direct

How to add String Label to MPAndroidCharts

帅比萌擦擦* 提交于 2019-12-11 12:27:19
问题 I am developing a simple Android app which shows a dataset of flot numbers on a linechart. I am using MPAndroidChart and thanks to it I am able to manage my custom linechart and its style. However, I am trying to add a String Label in order to label both the domain (x-axes) and the range (y-axes) of my linechart, as shown in the picture below. Any suggestions to do it using MPAndroidChart? 回答1: Actually, what I need it is not supported by the MPAndroidChart. Hence the only way to do that is

How can I make my HorizontalBarChart scrollable?

﹥>﹥吖頭↗ 提交于 2019-12-11 10:06:17
问题 Currently trying to implement a HorizontalBarChart using MPAndroidChart. However, there are too many bars and they won't all fit on the screen. HorizontalBarChart will scroll only if I zoom in, but will never go past what was already on the screen. Not sure if this is an XML problem (I have the HorizontalBarChart in a Relative Layout, tried ScrollView but didn't work) or if there's already an implementation like chart.enableScroll() (which I have tried, and it doesn't work). 回答1: You can use

Disable OnClickListener while scaling or dragging a View

感情迁移 提交于 2019-12-11 09:42:56
问题 Hi I'm using MPAndroidChart and my added OnClickListener is triggered right after i zoomed into or dragged a chart. How can i disable this behavior? This are my chart properties: chart.setTouchEnabled(true); chart.setScaleEnabled(true); chart.setDragEnabled(true); chart.setPinchZoom(true); chart.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //this only should run if i really click on the chart, not if i zoom or drag it. ... }); Is there an easy way to

MPANDROIDCHART: How to draw X label with .setViewPortOffsets(0,0,0,0)

假如想象 提交于 2019-12-11 09:23:20
问题 I have a problem with draw X label when my chart has been set setViewPortOffsets on 0, 0, 0, 0. I know what setViewPortOffsets do, But I don't know how to set it to make only the margins disappear on left and right side. Can someone help me please? PS: Sorry for my bad English. 回答1: Add following lines to remove axis lines from both sides of chart: chartView.getAxisLeft().setEnabled(false); chartView.getAxisRight().setEnabled(false); 来源: https://stackoverflow.com/questions/47780961

MPAndroidChart: getColors() is now deprecated for 'Legend'. What should I use instead?

元气小坏坏 提交于 2019-12-11 07:55:12
问题 I'm displaying a custom legend for a PieChart in MPAndroidChart however, .getColors() and .getLabels() are now deprecated. I've been using them to get an int array and string array respectively but I can't seem to find a direct alternative. Am I missing something obvious? What should I now use instead? Thanks! Legend legend = mChart.getLegend(); legend.setEnabled(false); if (legend.getColors() != null) { int colorCodes[] = legend.getColors(); String labels[] = legend.getLabels(); ArrayList

MPAndroid BarChart label count and ValueFormatter not working properly

断了今生、忘了曾经 提交于 2019-12-11 05:55:22
问题 I have an issue with the BarChart and labels. The labels count is not correct. Even if I put a value directly: xAxis.setLabelCount(5,true); but what I get is only 4 labels. When I put 6 it becomes 5. It seems there is a bug. Also the last item of the labels ( I am using a simple ValueFormatter) does not appear. If the number of labels equals the number of bars it repeats the first one twice even though I use the xAxis.setGranularity(1f); xAxis.setGranularityEnabled(true); and the x values for