I am having Axis Labelling Policy as Fixed Interval for the X-axis . Now on zooming I want the minor tick labels to be shown.Is there any provision for setting the axis labelling policy on the minor ticks that allows for this or in what way can this be achieved.
Use a plot space delegate to monitor changes and add the minor tick marks when zoomed in far enough. Set the minor tick line style to nil to hide them or to a CPTLineStyle to show them. You shouldn't need to adjust any other properties, unless you want to vary the number of minor tick marks based on the zoom level.
Related
In QChart, how can I set tick with uneven space? In the example chart below, notice the first grid is smaller than others. How is it actually done? Thanks.
You need to set the TickType of your QValueAxis to QValueAxis::TicksDynamic.
Then you can set a tick anchor (i.e. the value where the first tick should be placed, e.g. 80.0 in the example image you provided) and tick intervals (the value between ticks, e.g. 2.5 in the example image)
Please note that dynamic ticks were only introducted in Qt 5.12.
I am using the plot Interaction property set to YES to allow scrolling. Now it allows scrolling on the axes till infinity and also on the negative side of the axes . How can the scrolling be restricted only along the horizontal axis and also not extending upto infinity on the same axis.
You can use the globalYRange to limit the zooming and scrolling along the y-axis. If you need more control, use a plot space delegate to monitor changes to the plot space and respond accordingly. There are several examples in the Plot Gallery example app.
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.
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.
Apart from the issue I am trying to fix atm, I would like to know how I can make the x-axis labels to draw wherever there is a point drawn. As you can see on the screenshot there are three points in time. So instead of the label "1/10/54' (yes that is year 54) floating nowhere, I want three labels, one below each point.
(Note the 3 points are only for illustration, needs to be expandable.)
If the spacing between the labels will be irregular like your sample screenshot, you'll want to change the axis labeling policy to CPTAxisLabelingPolicyNone or CPTAxisLabelingPolicyLocationsProvided. Both policies require you to provide the tick locations. The first policy also requires you to make custom labels that don't have to be at the same locations as the tick marks while the second will automatically make labels at each tick location using the standard label formatter.