How to set the X range in Androidplot? - android

I'm passing Androidplot a series with x-values ranging from 0 to 100, but I only want to display the range from 90 to 100. How can I accomplish this?
The graph is redrawn with new data every second. My plan is to call some command before redraw() that sets the x-axis range as I want it.

Use setDomainBoundaries:
setDomainBoundaries(90, 100, BoundaryMode.FIXED );

Related

How to make a range according to the selected segment?

It is necessary to make a range according to the selected mode, but scichart draws the wrong interval. For example, I want to set the interval to 1 day. Using SciChart.
settings x axis
val xAxis = sciChartBuilder.newCategoryDateAxis()
.withBarTimeFrame(60.0*60.0*24.0) //seconds in day
.withDrawMinorGridLines(false)
.withGrowBy(0.0, 0.1)
.build()
result
about how it should look
If you want to alter spacing between major axis ticks then you probably need to change MajorDelta value.
As I see you use CategoryDateAxis so you should be aware that this axis type is index based and it operates with indices instead of Dates. This means that if you have data where xData in unevenly spaced (e.g. distance in time between points is different ) then with type of xAxis on chart you'll see the same distance between points.
This also means that you'll need to specify MajorDelta as index interval and you can't specify time interval out of the box. To provide desired output you'll need to calculate how many data points lies within desired time span. For example if your data contains points with interval 15 min then to draw major tick every 4 hours like on screenshot you'll need to set MajorDelta = 16 ( 15min * 16 = 4 hours ) but as I said it depends on data set which you're trying to display.

how to change reference point 0 to 100 in MPandroidchart?

Now i'm using MP android chart to show the kilowatt per hour data, this requirement need set the benchmark to 100 kwh, if the value is bigger than 100, the line will been draw above the benchmark, if the value is smaller than 100, of course it's below the benchmark.
I want to change the benchmark from 0 to 100 on y axis, but i didn't find any useful information from the doc. can someone give any advice on this?
This might help.
YAxis y = chart.getAxisLeft();
y.setAxisMaxValue(100);
y.setAxisMinValue(0);
Reference Documentation: https://github.com/PhilJay/MPAndroidChart/wiki/YAxis
Add Something LIke this
yAxis.setAxisMinValue(0);`
use same 100 as Maximum.Refer MPAndroid Documentation

How to set x-axis label for every y-value in MPAndroidChart?

I want to set a label in the x-axis for every y-value I have in my LineChart. I want to obtain this result:
Can someone help me in finding the correct way of doing this in MPAndroidChart?
You may be looking for granularity - see the wiki page for the axis and the javadoc.
Calling like this:
mChart.getXAxis().setGranularity(0.3f);
mChart.getXAxis().setGranularityEnabled(true);
will ensure that 0.3 is the minimum interval on the axis when you are zoomed in. Apart from that you may have to tweak the the scale of the x-axis by calling:
mChart.getXAxis().setAxisMinValue(10.01f); //experiment with these values
mChart.getXAxis().setAxisMaxValue(10.14f);
mChart.getXAxis().setLabelCount(5);

Displaying only a part of graph using Achartengine

I am using Achartengine to generate TimeChart graph. The data set consists of dates form 1/15/2003 to 12/4/2040 (x-axis) with respective random values for Y-axis. I am displaying the graph dynamically where I keeps reading the values on background thread (AsyncTask) and repaints the graphview. I have 2 questions:
The view starts from Jan, 2, 1970(I dono why) and I have to scroll to 1/15/2003 to see the graph. What should I change to make it start from 1/15/2003 ?
Also I take 2 date values FROM and TO (Eg: FROM:2/17/2004 TO:6/23/2006) and I want to display the graph only in this range. Is there any way to do this?
I could solve the 1st one using mRenderer.setYAxisMin(new Date("1/15/2003 11:16:00 AM").getTime()) Although this is a deprecated method, but it did the work for me. Now when I display the graph its starts from given data not Jan, 2, 1970.
You can dynamically set Y axis min and max with values desired values, just before repainting.
And for the 1. question, maybe better option is to set pan limits, so you can't scroll to empty parts of your chart.
You can do it like this
mRenderer.setPanLimits(new double[]{xMin, xMax, yMin, yMax});
where you calculate limits like this
double xMin = minDate.getTime();
double xMax = maxDate.getTime();

How to set gridlines for every value on the Y-axis in achartengine?

I am using achartengine 1.0 and I am trying to set the gridlines for my LineChart.
The Y-axis has a min value of 1 and a max value of 7. I need the chart to display every step in this interval, so I added a label for 1, 2,3,... with
addYTextLabel();
Now I would like to display a gridline for every value on the Y-axis.
But when I add the grid for this axis, there are only 3 lins, at 2, 4 and 6.
How can I get the grid to show a line for all values?
best regards,
htz
with setYLabels() you can set the number of displayed labels for the Y axis. With a displayed label, there comes a gridline.

Categories

Resources