mpandroidchart

Updating a chart from an ArrayList over time?

我是研究僧i 提交于 2019-12-02 08:39:11
I have an ArrayList of values, and I would like to iterate through the ArrayList. For every new value, I would like to update the chart with that value, and then wait a set amount of time before doing the same thing to the next value. At the moment, my log says that all of the values are being iterated over. However, on my testing device, the chart does not update until the very end; at that point, all of the values are loaded at once, so there is no desired "slideshow" effect. When I want to start playing back the values in my ArrayList, this method is called: public void playback(){ if(ret !

Setting the pie slice colors in MPAndroidChart

霸气de小男生 提交于 2019-12-01 18:59:26
I need to define specific hex values for each slice in my pie chart. I'm following the wiki but the method doesn't seem to be working for PieDataSet PieDataSet dataSet = new PieDataSet(entries, "Fuel"); dataSet.setColors(new int[] { R.color.green1, R.color.green2, R.color.green3, R.color.green4 }, Context); These errors are shown: Cannot resolve symbol 'green1' Expression expected <-- At the 'Context' Is there an alternate way to set the pie slice color? This seems to work for Line charts but not for pie. Found a work around: final int[] MY_COLORS = {Color.rgb(192,0,0), Color.rgb(255,0,0),

MPAndroidChart LineChart: Using dates instead of Strings for X-axis

微笑、不失礼 提交于 2019-12-01 17:19:39
问题 MPAndroidChart LineChart by default accepts Strings for X-axis. Is there a way to set Date as a datatype for the X-axis? The problem with just converting Date into strings is that graph can be scewed depending on the data points. For example if I have one data entry on January and 10 entries in June, by default the graph is just split into 11 and plot accordingly. I want a "You weight over time" graph, where X-Axis represents time. User weights in at random times, so some dates will have

MPAndroid Group bar chart is not showing [duplicate]

£可爱£侵袭症+ 提交于 2019-12-01 14:54:47
This question already has an answer here: How to check if activity is in foreground or in visible background? 22 answers Here is the code i used for group bar_chart using MPAndroid library version 3. I've tried group bar chart in lower version and it works fine but the BarData constructor is changed in latest version. And this code doesn't works. There is no crashes and error logs, still graph is loading and no data shows in it. Help me to find ma flaws List<BarEntry> entriesGroup1 = new ArrayList<>(); List<BarEntry> entriesGroup2 = new ArrayList<>(); List<BarEntry> entriesGroup3 = new

Show image instead of circle on LineChart

北战南征 提交于 2019-12-01 12:16:36
问题 I have created a LineChart using the library MPAndroidChart and everything works great. Now what I want to do is show a drawable (image) instead of the default circle for every entry on the chart. I have tried so many options from the API but no luck. Can anyone tell me how can I do this? 回答1: And finally after trying so many things, with the help of @David Rawson's suggestion and this post MPAndroidChart LineChart custom highlight drawable I have managed to create a custom renderer, which

MPAndroidChart - is it possible to control z-index of the chart elements?

放肆的年华 提交于 2019-12-01 08:26:30
I would like to have the following order of drawing in my MPAndroidChart (from bottom to top): Data connecting line Limit line Data points Is it possible? I am aware of the method com.github.mikephil.charting.components.AxisBase#setDrawLimitLinesBehindData . It is working as expected except for one case. When the Y value of all data points is the same, the effect is: or this: I would like it to look like: The first 2 pictures are from MPAndroidChart Android library. The 3rd one is from iOS port of the library: Charts I looked at the order or drawing the chart in Android and iOS versions and

Custom position for bar values

十年热恋 提交于 2019-12-01 04:33:52
I'm using the MPAndroidChart library to create bar charts. We can use the following to show the bar values on top of the bar. mChart.setDrawValueAboveBar(false); or we can use this : barDataSet.setDrawValues(true); to show the bar values inside the bar itself. I want to know if we can set a custom position for the values. For example below the y-axis. Solution public class TextBarChartRenderer extends BarChartRenderer { public TextBarChartRenderer(BarDataProvider chart, ChartAnimator animator, ViewPortHandler viewPortHandler) { super(chart, animator, viewPortHandler); } @Override public void

How to show labels on right and values to left side in HorizontalBarChart?

二次信任 提交于 2019-12-01 00:43:22
Drawing a horizontal bar chart using MPAndroidChart 3.0.2. the values are shown on the right of the bars. I could use setValueFormatter and use IAxisValueFormatter interface to display the labels on the right. But the values are not displayed now. { HorizontalBarChart barChart = (HorizontalBarChart) itemView.findViewById(R.id.barChart); BarData data = new BarData(); ArrayList<BarEntry> valueSet1 = new ArrayList<>(); ArrayList<String> labels = new ArrayList<>(); labels.add("January"); labels.add("February"); labels.add("March"); labels.add("April"); labels.add("May"); labels.add("June");

MPAndroidChart how to set label color?

假装没事ソ 提交于 2019-11-30 20:42:11
got the following code: graph = (LineChart) convertView.findViewById(R.id.graph); graph.getPaint(Chart.PAINT_LEGEND_LABEL).setColor(Color.BLUE); graph.getPaint(Chart.PAINT_YLABEL).setColor(Color.BLUE); graph.getPaint(Chart.PAINT_XLABEL).setColor(Color.BLUE); But still the color of X/Y-value-lables and also the lable of the legend stay in black color. Do I miss something? Is there an other way to set the color of these? This line for example works and results in blue value-lables for each data-point: graph.getPaint(Chart.PAINT_VALUES).setColor(Color.BLUE); Thanks in advance! Try this to set the

Getting duplicate values at xAxis MPChart

倖福魔咒の 提交于 2019-11-30 20:23:09
Right Now I am facing this issue. I am getting repeated values in xAxis the first one and the last one.And graph values are not according to the values at respective x-axis values. and the second issue is if I want to display the values not in float but in int Rounded and change the their color to white. ArrayList<String> xlabels = new ArrayList<String>(); xlabels.add("Jan"); xlabels.add("Feb"); xlabels.add("Mar"); xlabels.add("Apr"); xlabels.add("May"); xlabels.add("Jun"); ArrayList<String> values = new ArrayList<String>(); values.add("1"); values.add("20"); values.add("10"); values.add("80")