Proportional pinch zoom limit in core plot iOS? - ios

The question is similar to this one
But in my case I have a proportional zoom. For example, if I use x2 zoom on x axis then y axis has the same x2 zoom. In this case all the graph lines store their angles.
The problem is in the following method:
-plotSpace:willChangePlotRangeTo:forCoordinate:
It takes a specific param - xAxis or yAxis (not both) and in my case xAxis has limitations only. So while xAxis zoom is constant (because it has reached its limit) yAxis zoom still may be increased or decreased. It is hard for me to calculate yAxis limitations because xAxis and yAxis mean time and price (have different measurements).
How to solve this issue?

I tried to use plotSpace:willChangePlotRangeTo:forCoordinate: but it is useless for my case. If it returns NO then the label places are persistent.
The second reason I shouldn't use this method is method plotSpace:willChangePlotRangeTo:forCoordinate:. This method is for replacing old labels with new ones but it is called even less often. So I moved all the calculations into it.
Proportional zoom is by default (if there is no code preventing zoom).
And finally I wrote a BOOL variable which equals YES when the limit on X axis is reached and prevents changing of Y axis values in this state.

Related

Coreplot Y axis cut off / no numbers?

I am having issues with my implementation of CorePlot. I have a subview in my UIViewController than contains the chart. Most of the data shows up fine but no increments / values are showing up on the y axis.
This is what I am seeing now:
If I shift the x axis start point by subtracting 10 (to better see the left half of the chart) I see this:
For the record, I do not have any values outside of the (positive x, positive y) quadrant on the chart and have logged out my data to verify this. Any input / advice would be appreciated, thank you!
http://www.raywenderlich.com/13271/how-to-draw-graphs-with-core-plot-part-2
This guy does a great job explaining that about halfway down... search for "You're Getting There!" to find exactly where he talks about the weird lines in the Y axis.
Hope this helps!
Set the leftPadding on the graph.plotAreaFrame to leave room for the axis labels at the left side of the graph.
The smeared y-axis is caused by too many tick marks and labels—they overlap and become illegible and negatively impact drawing performance. You need to adjust the labeling parameters to reduce the number of ticks and labels. By default, the axis draws major tick marks and labels one unit apart. The properties that need to be changed depend on the labeling policy you want to use.

How to set min and max values for an axis?

I have some data that can have values in the range (0..100). Highcharts will sometimes label the axis from -10 to 110, which looks odd.
How can I prevent this? I can set a fixed min and max value for the axis, but if the current values happen to be between e.g. (50..60), I'd rather let Highcharts zoom in on the axis accordingly. Just don't want Highcharts to ever show anything outside of (0..100).
I could of course determine the appropriate min and max values myself every time I load data, but was hoping there would be some kind of minMin and maxMax setting?
So it looks like this isn't possible; opened a feature request.
Nowadays highcharts has floor and ceiling options for this use case.

How to prevent Highchart from severely change declines?

The problem is that, if I try to change the lowest point to somewhere higher, the entire chart will be lowered severely.
How do I adjust each point with no above mentioned issue?
P.S. I use Highchart's Highstock.
It would be helpful if you could show a JsFiddle with the actual working code. Without knowing what exactly is going on with your chart it's difficult to figure out what the issue is and how to fix it.
Have a look at the yAxis - Highstock API Reference, you could potentially make use of min or max to counteract the scaling. Again though, without seeing your code it's tough to know.
If I understand your problem, you are trying to set the 7th point from currently at ~150 to something really high, say 5000? I did not notice any real change in the position of other points if the new value was under 1500 (or something around twice the first point)
Appears that your chart is set to comparison mode, hence, I believe, the default max and min are (100% & -100%) by default, this is w.r.t. to first point of the series. Highcharts would auto adjust these extremes if any of the points were to lie outside this range, you could force an override using yAxis.min & max.
For instance, you can set yAxis.min to -100 and yAxis.max to 100 like this
yAxis: {
min:-100,
max:100
}
Play around with the min and max to get to the values that suits your data the most, do remember these are % comparison to the first point. Any points outside these ranges would not show in the chart.
#jsFiddle

Core Plot: Pinch to change x axis range

So I have a simple line XY Graph with integer values on the Y axis and dates on the X axis. What I would be like to be able to do is do a horizontal two-finger pinch and adjust the range dynamically. Eg, pinching in would give you a bigger range (mental model being that you're setting the start and end date shown to be further apart) and then pinching out would give you smaller time window.
Is there some stuff built in for this already? Reasonably new to CorePlot and the default finger stuff just zooms the graph itself, none of the values.
Would I need to put a gesture recgoniser on it? or does coreplot have stuff build into it for this?
Cheers
This is how the built-in zoom features work. Use a plot space delegate to monitor changes to the plot space while zooming and make changes to the axis appearance as needed based on the changes. See my answer to your other question for more info.

linear Dataseries Say 0 on Y Axis Having Issue

Linear Dataseries Say all y axis is 0, Autoscaling on y axis is not working as desired.
High stock version - 1.3.1
DataSeries to be plotted,
[[1149724800000,0],[1149811200000,0],[1150070400000,0],[1150156800000,0],[1150243200000,0],[1150329600000,0],[1150416000000,0],[1150675200000,0],[1150761600000,0],[1150848000000,0],[1150934400000,0],[1151020800000,0],[1151280000000,0],[1151366400000,0],[1151452800000,0],[1151539200000,0],[1151625600000,0]]
OR
[[1149724800000,20],[1149811200000,20],[1150070400000,20],[1150156800000,20],[1150243200000,20],[1150329600000,20],[1150416000000,20],[1150675200000,20],[1150761600000,20],[1150848000000,20],[1150934400000,20],[1151020800000,20],[1151280000000,20],[1151366400000,20],[1151452800000,20],[1151539200000,20],[1151625600000,20]]
Try Above series with Y min set to 0 and Y Min to Auto.
I had the same issue with 0 values displayed in the center.
The only way I found to get round it was to either use tickPositions and pass range values across to it for the data based of min/max values and ones in between or to use the tickPositioner call back function to return to go through the data and return the tick values based on these.
Still fairly new to highcharts so there is probably another way I don't know of. If anyone knows how to have 0 values displayed at the bottom of the chart while it auto-scales then please post as I would love to know how/if its possible.
Edit: turns out this isn't really possible currently, only way to get around it is to set min/max values and that won't allow auto scaling but at least it stop there from being any middle 0 values.

Resources