mpandroidchart

MPAndroidChart is there a way to set different colors for different bars?

ぐ巨炮叔叔 提交于 2020-01-02 07:15:44
问题 I am using MPAndroidChart in my app and i was wondering if there is a way to set a diferent color for the first bar in a dynamically moving bar chart, like this: The bars are added dynamically while the whole stack is being moved to the left as the data keeps coming, is there a way to set the color of the first bar to be a different color? thank you in advance. EDIT and Solution: here is my code for adding a new entry to the chart, it occurs dynamically every 500 millis or so. private void

MPAndroidChart: XAxis values not corresponding to Data values

喜欢而已 提交于 2020-01-02 07:04:47
问题 I've a problem using MPAndroidChart: I have some entry data to display in a Bar Chart, but the xaxis labels aren't displaying on the position I want: I want to show them one per chart value, immediatly under the "bar". This is what is happening right now: And this is my code: ArrayList<BarEntry> entries1 = my entries...; final ArrayList<String> stringList1 = my strings...; XAxis xAxis1 = chartCost.getXAxis(); xAxis1.setPosition(XAxis.XAxisPosition.BOTTOM); xAxis1.setDrawGridLines(false);

How to plot data from right to left in MPAndroidChart?

杀马特。学长 韩版系。学妹 提交于 2020-01-02 06:47:26
问题 I recently update the MPAndroidChart library from 1.7.4 to 2.0.9 and I forgot what I did to customize the linechart to make the data displaying from right to left. Does anyone know? I am wondering if there is a method to call to do that. 回答1: There is no method. But it can still be done because it only depends on how you add the data. Just add values at higher x-indices first. Say you got a chart with x-axis labels from January to December with an x-axis range from 0 - 11 (12 values). Now add

Mp Android Chart Scrolling the data from right to left

非 Y 不嫁゛ 提交于 2020-01-02 05:33:07
问题 I'm Building a barchart using MpAndroid chart library, i've around 50 - 60 bars and wanted to display the 60th initially i.e. display the last element in the ArrayList and the scroll should be from right to Left. Main motive is to display the end of the chart during the initial load of the chart barchart. Thanks in Advance. 回答1: This worked for me. chart.setData(...); // first set data // now modify viewport chart.setVisibleXRangeMaximum(20); // allow 20 values to be displayed at once on the

Pie chart background changes when slice too small in MPAndroidChart

荒凉一梦 提交于 2020-01-01 15:35:25
问题 Please help me out from this problem in pie-chart using MPAndroidChart This is a library bug. When I have a pie slice that is too small, the color for that slice bleeds into the chart background. Like in the pictures below - you can see the yellow color has bled. I'm setting static float data in setData() :- private void setData(int count, float range) { yVals1.add(new Entry(100.9f, 0)); yVals1.add(new Entry(0.01f, 1)); } It means when we enter a huge difference between 2 values then this

MPAndroidChart StackedBarChart showing values but no bars

大城市里の小女人 提交于 2020-01-01 05:42:06
问题 I am starting to use the MPAndroidChart library to build a StackedBarChart showing three y values. Here is the code: public class Plot { final Context context; final BarData data; private int count; public StackedBarPlot(Context context) { this.context = context; data = setData(); } protected BarData setData() { final List<BarEntry> entries = new ArrayList<>(); for (DatabaseEntry entry : entryList) { final float total = (float) entry.getTotal(); final float[] y = {100 * entry.getN1() / total,

How to change chart background with MPAndroidChart library?

人走茶凉 提交于 2019-12-30 17:58:21
问题 I'm using the amazing library MPAndroidChart. It works like a charm, except when I'm trying to change the background color of the BarData. Default color is white, and I want to change it to Transparent. I've tried this : Paint p1 = mChart.getPaint(Chart.PAINT_GRID_BACKGROUND); p1.setColor(Color.RED); and this: <com.github.mikephil.charting.charts.BarChart android:id="@+id/chart1" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color

How to create a BarChart with grouped bars with MPAndroidChart?

帅比萌擦擦* 提交于 2019-12-30 00:54:06
问题 How can i compare two set of data using BarChart of MPAndroidChart. It should look like this image below: I edited a code, I get from a sample project in github. how can I put together 100f and 110f value in one Xaxis label Whole Number Score score1 = new Score(100f, 0, "Whole Number"); mRealm.copyToRealm(score1); Score score2 = new Score(110f, 0, "Whole Number"); mRealm.copyToRealm(score2); 回答1: Yes, that can be done quite easily. What you need is a BarChart with multiple BarDataSets where

MPAndroidChart, Y-Axis Scale gets updated but lines are not

余生颓废 提交于 2019-12-25 09:22:24
问题 I am using MPAndroidChart. I have the following Activity - StockDetail.Java public class StockDetail extends AppCompatActivity{ ArrayList historicalData=null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SharedPreferences prefs=getApplicationContext().getSharedPreferences("arrayList",Context.MODE_PRIVATE); try { historicalData = (ArrayList<HistoricalData>) ObjectSerializer.deserialize(prefs.getString( Utils.ARRAY_LIST, ObjectSerializer

How can MPAndroidChart begin at the last x-value with a large dataset?

北城以北 提交于 2019-12-25 08:22:58
问题 I am using MPAndroidChart library in Android. I'm trying to get the graph to start at the last set of x values. I would like to show every day of the year up until now so 1 - 271 (today is the 271st day of the year) I am using chart.setVisibleXRangeMaximum(10) but the chart begins by showing day 1 - 10 and I want to start by showing day 261 - 271. 回答1: According to MPAndroidChart's wiki, try chart.moveViewToX(yourNumberOfXPoints); or chart.moveViewTo(yourNumberOfXPoints); Why? moveViewToX