MPAndroidChart with custom image - java

I am working on making this layout which is a layout contains a chart with custom image. I assume that this is a bar chart with custom image on it.
Every 10 values equal to one bottle image. I'm planning to use MPAndroidChart but seems that i have to make my own customRenderer. but i dont know how to do it.
this is the design of the layout Chart With Custom Image
Can anyone please show me an example?

Related

Android donut chart fill with multiple colors based on timestamp

I am looking for a chart which will show one circle around that time like 12:00, 01:00 like. Which fills with some colors based on time of activity.
I found this link Create Doughnut Chart Similar to Google Fit but it isn't fit for my requirements.
Please find image below. This is how I am expecting the chart.
Here these colors represent some activity based on timings. I have a set of data with a timestamp and it's activity type.
Can anyone suggest to me how I can draw this chart? Is there any example for this?
Edit
I found this link http://www.androidtrainee.com/draw-android-clock-pie-chart-with-animation/ to draw clock pie view. But stuck at point to set width and fill color like in above image. Right now it's fill different color based on time in full circle. But how do I set width to this clock to fill color and center part blank to show 08:40?
Since these are very specific requirements, it is likely that you will have to create your own custom view on Android. The SO you linked has a few promising libraries linked including fit-chart. The documentation isn't great, but it seems to support adding chart parts with values in 1% steps.
So you would only need to convert your duration data into percent of the circle by using 60 minutes or 12 hours as 100%.
Here is the relevant usage part of fit-chart:
Collection<FitChartValue> values = new ArrayList<>();
values.add(new FitChartValue(30f, 0x2d4302)); // 30f seems to represent 30%
final FitChart fitChart = (FitChart)findViewById(R.id.fitChart);
fitChart.setValues(values);
Another library that looks promising is MPAndroidChart that supports a detailed Pie Chart.
Regarding taking time into account: There are plenty of tutorials on how to draw an analogue clock that should include calculation on how to position the texts around the circle. Here is one SO creating a CustomClock View with multiple tutorials linked.
Regarding setting up your custom view, this 2d-donut-chart tutorial drawing a chart based on Path.arcTo covers all the needed steps.
If you need further help it would be helpful if you add your data structure and what you already tried. But I hope with these libraries and tutorials you can create your desired view.
Regarding updated question: I would suggest that you create your own custom view. My best suggestion is to continue by comparing the ClockPieView.onDraw with the draw methods of the other libraries I mentioned that do draw a doughnut graph with a hole. Research how text can be rendered as part of the onDraw with your specific positioning.
Heres a list of jQuery extensions to do this:
http://www.jquerybyexample.net/2014/02/jquery-html5-library-circular-piechart-graph.html
You can customize the Pie chart of MPAndroidChart library to create this. Here is a similar one created using it.
Here you will find the documentation of the library and this demo application is also helpful.
Here is a sample code you can try out after adding MPAndroid chart library to your project.
List<PieEntry> entries = new ArrayList<>();
//add data entries, 100 will be considered as a full circle
entries.add(new PieEntry(50, ""));
entries.add(new PieEntry(25, ""));
entries.add(new PieEntry(25, ""));
PieDataSet pieDataSet = new PieDataSet(entries, "");
PieChart pieChart1 = (PieChart)rootView.findViewById(R.id.pie_chart1);
pieChart.setMaxAngle(360);
//You can customize the pie chart in many ways to suit your need
pieChart.setCenterTextRadiusPercent(84);
pieChart.setRotationEnabled(false);
pieChart.setRotationAngle(180);
pieChart.setHoleRadius(60f);
pieChart.setDescription(null);
pieChart.setHoleColor(ContextCompat
.getColor(context,R.color.colorTransparent));
pieChart.setBackgroundColor(ContextCompat.getColor(context,
R.color.colorTransparent));
pieChart.setTouchEnabled(false)
pieChart.setDrawCenterText(true);
pieChart.setCenterTextColor(Color.BLACK);
pieChart.setCenterTextSize(16f);
pieChart.setCenterText(status);
//Add animation (optional)
pieChart.animateY(1500);
pieChart.invalidate();

Show stacked bar chart in Application

How can I show chart shown in below image in my App? It is shown in Settings->Apps->Running. I tried Microcharts but it isn't possible using it. I want to show it for storage space. I know how to get the storage space values but don't know how to plot chart like in the image.
You mean a stacked bar diagram. It is possible with NumAndroidCharts Library, in this example they make a horizontal one. Maybe you are able to use it vertical as well:
https://www.numetriclabz.com/android-stacked-bar-chart-using-numandroidcharts-tutorial/
But i don't now if you can hide the X and Y coord description, so it would look like in your picture. Maybe it is easier for you to draw it on your own, the diagram are simple rectangles.
Update
Found the horinzontal one:
https://www.numetriclabz.com/android-horizontal-stacked-bar-using-numandroidcharts-tutotrial/

Custom Vertical ProgressBar in LibGDX

I want to create Custom vertical progress bar with non linear background
In previous implementation I used skin composer , but as I know it works perfect with simple regular shapes (the knob part resize on the all background image so it looks bad in my example ). I also try to hack using several layer behind the progress bar, but for this case the background behind progress bar is transparent.
I suppose this solution can solve my issue but unfortunately I dont understand how can I implemented that solution.
I also try to crop the inside part (that reference), whenever the progress is changed but I dont think that is the best solution (also the increase/decrase animation cannot be simple enabled )
Could you draw the full red progress bar and then load peices of it until it fills up the whole thing?
Here is a way to get pixels from a png image and you could wirrite your own parser:
How do I read pixels from a PNG file?
Or you could search Google for how to get peices of a png or bitmap.

Display grid of images in Android with center of grid layout being empty?

I have a decent amount of images(10 or so) that I need to display in grid form with the center of the layout being empty. Currently I'm adding each image through code but that is becoming time consuming. Every image is using the same onTouchListener class. The center of the layout needs to be empty to accommodate a "container" image view that selected images can be dragged and dropped onto. I thought of using an image adapter but only saw examples that were for a gallery type view in either horizontal or vertical orientation. Is there any way to create a custom class that automatically positions the images in grid form with an empty center that has predetermined dimensions?
If you are using a RecyclerView with GridLayoutManager, then you can get the firstVisisbleItem and lastVisibleItem. This should give you the number of visibleItems with which you can decide the index in the grid where you should not show any item. This would require you to take care of some implementation level details, but the basic logic should be like this only. Hope it helps.

Android progress bar with circular drawable and filling from bottom to top

I am currently working on creating a custom progress bar and have so far managed to get the correct image I want to display, however I am trying to customise it so that it fill the white space within my drawable from bottom to top (bottom being 0 and top 100). I am using xml layouts.
I am not entirely sure if this is possible, the image I am trying to fill is;
Any guidance as to whether this is possible or if there are any libraries I would use that would be much appreciated.

Categories

Resources