Custom Fill formatter - java

I am trying to have a chart that only fills a certain amount of points using mpandroid chart, I have looked at the wiki but I am directed to a 404 error when I try to look at the default fill formatter. The picture has all of the values filled. Any help will be appreciated, thanks.

Nevermind, I got it, the key here is to make multiple data sets with overlapping x indices and each dataset will have a point that doesn't overlap with the previous data set. Then specify which data set to setdrawfill(true/false).

Related

Data goes behind values on starting points(MPAndroidChart)

I have used MP android chart and made custom y-axis values by using y-axis renderer. My graph shows point data and line data.
My issue is point data goes behind y-axis value on starting point.
I know one way to achieve this is by using custom renderer. But Is there any easy way to show point data in front of y-axis values.

How can I graph values that are incredibly small in Java?

Basically I am attempting to use JFreeChart right now to graph some values. The only problem is that the values are incredibly minuscule, e.g 7.069781E-13. I believe these values are too small for JFreeChart to display. How can I display these small values visually in Java in a line chart format?
It looks like this currently:
And I want to make it look similar to this:
I found a work around.
I simply multiplied all the values by a factor of 100 so the graph now looks similar to the one in the example. I will include a disclaimer in the legend saying the chart has been multiplied by a factor to clearly see the line chart.
Also consider these alternative:
Invoke setRange(), seen here, to expand the y axis in the area of interest.
Add suitable controls, seen here, to control y zoom.
Advise users how to use the mouse for zoom control, as shown here.

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();

How can I give two different styles for the same series of a line chart?

I would like to use JavaFX to assemble a line chart such that when there is no data to plot in a series, the space is empty. Something like that:
Chart
Notice that I would like to keep myself in the same series, just by changing your style in one part. But any help is welcome. Thank you.

How can i assign different colors to each dot in scatter plot using jfreechart in java?

I am a newbie to Java and using JFreechart to display scatter plot.I have a thread which keeps adding points to scatter plot.Color of these points can be different depending upon some property(That is known,not the issue).Currently i am using "XYItemrenderer.setSeriesPaint(0,Color.black);"
to change the color but it changes color of all the points.I tried searching and found this-
JFreeChart different colors in different regions for the same dataSeries
But i am confused about how can i pass that information which decides the color of dot to method?
Any help would be appreciated :)
The fact that points differ depending upon some property is the central issue: the defining property needed to assign color is now an attribute of your data model. You can easily change the color in your view's renderer by overriding getItemPaint(), as shown here. The problem then becomes one of accessing the model from the view. The example cited simply references an attribute of the enclosing class, but you may want to pass a model reference to the view explicitly.

Categories

Resources