How to stop scrolling of AChartEngine dynamic line graph along the y-axis?
When I dynamically plot values I wish to display the recent plotted value. How to do that?
I wish to plot y- axis values in range 20 to 200 and want to display only 5 values so I have used mRenderer.setYLabels(5); But, when I do so grid lines are displayed for only those values. And user will not be able to know the exact y axis co-ordinate. How to show grid lines for each value and show labels for only some values?
If I manually scroll graph horizontally towards right or left, x-axis labels change. I set range as 0-10 with setXLables(2); but it changes to 0,5,10… How to control this behavior?
These should be 4 separate questions, not numbered ones. So, I will only answer the first one of them:
You can set the min and max displayed values:
renderer.setXAxisMin(minValue);
renderer.setXAxisMax(maxValue);
If by scrolling you mean panning, then this is the way to do:
renderer.setPanEnabled(false, false);
renderer.setZoomEnabled(false, false);
Related
I have an Android application that is using Achart to create a 2 graphs. Both a line graph and a bar graph.
These graph will be populated with an extra data point each time the application is run. So after 10 runs there will be enough data to cover the visible x-axis.
What I want is for after the 11th+ use, to be able to pan the graph, so that the user can see historical data (back to the first data point).
I have set
renderer.setPanEnabled(true, false);
renderer.setZoomEnabled(false, false);
renderer.setYAxisMin(0);
renderer.setXAxisMin(0.5);
renderer.setXAxisMax(10.5);
renderer.setYAxisMax(100);
Which is all good, but when I pan the data I am able to pan to -ve values on the x axis, and also able to pan way beyond the maximum data point that I already have.
I have tried setting a PanListener, which I think is the way to go, but I am just not sure what I should be setting in this Listener to clamp the panning to valid data points only.
Any ideas?
The user pan will just modify the X axis min and max. In order to avoid this, you will have to indeed add a PanListener and reset these values.
You can also set pan limits.
renderer.setPanLimits(limits);
I'm using AChartEngine's TimeSeries to display four separate series of values. The "values" have vastly varying scales - one of them is a fraction (varies between 0 and 1), the other has a range of 0 to 1000.
Now, I want to display all four of them simultaneously. I have been able to do this, but the problem is the line for the fraction is always hugging the X-axis since the variation between 0 and 1 is indistinguishable when the Y axis is from 0 to 1000.
One solution I though of was that I'd convert all the values to a common scale before adding them to the series. That way, all the four lines are always on the same scale. I can get rid of the Y-axes altogether. Cool.
But this presents another problem: I also allow the user to select individual series to view; and this time, I want to
Display the individual Y-axis
Display the un-scaled values.
But, since I added scaled values, the chart has now lost the original values and will only display the scaled value.
So, my question is: Is there a way to scale the values on the Y-axes when multiple series are being charted, and to revert to the un-scaled values when the single series is shown?
Also, how do I hide only the Y-axes while still displaying the X-axis?
You can use the multiple scale charting in AChartEngine. The chart type is CombinedXYChart. You can see an example here.
Another thread explaining this approach is this.
When I dynamically plot values I wish to display the recent plotted value on line graph (drawn with the help of AChartEngine library). In other words I wish to scroll my line graph along x-axis towards left to show the latest plotted value and hide the oldest plotted value. How to achieve this?
Whenever you add values to the datasets, if you call chartView.repaint(); the chart is updated with the new values.
In order to have the values scroll to the left, you need to change the visible area on the X axis:
renderer.setXAxisMin(theMinimumVisibleValue);
// this may be optional
// renderer.setXAxisMax(theMaximumVisibleValue);
I'm using achartengine to show a temperature graph. on X axis I put dates, to fit them I call setXLabelsAngle(45); this is the result:
As you can see, the labels are placed too high and go over the x-Axis. How could I fix this? I'm already using setMargins(), but labels don't move, only legend does.
This will help:
renderer.setXLabelsAlign(Align.LEFT);
I am able to display the AChartEngine's TimeChartView to user, but when the graph renders, the grid lines (vertical - set by showGridLines(true)) and the line drawn on graph to display corresponding y-axis value (time in secs) against the dates on x-axis don't intersect with each other.
The y-axis value pt shows up either before the x-axis value or after it, but not exactly on it.
Please suggest, if there's any achartengine property which needs to be set to get this done / any other thing that needs to be done for getting this done.
Thanks
Omkar Ghaisas
Sample Image --
As can be seen, the points marked with ovals don't coincide with the vertical grid lines and with x axis values, but start before that. E.g the first y value for 7200 should start at vertical line of 02/03/2012, but instead starts before that. Similarly for all other data points.
This was fixed in the AChartEngine SVN.
Please see this for extra information.