I'm trying to create a stacked graph using core plot.i have followed this tutorial.I have a UISlider on sliding i'm updating my graph.The issue i'm facing is my top value for y-axis is touching top border(As in the screen shot). As per my requirement in need to round off the highest value to next 10th value so that my graph doesn't touch the borders.On changing my slider value the x and y axis should also get refresh,i'm doing it by regenerating plot but it takes a lot of memory.Any idea how can i achieve these requirement ?
Don't recreate the whole graph every time the values change. Call -reloadData on the graph to refresh the plot data and set the xRange and yRange of the plot space to change the scale of the axes.
Related
I have a data set “mydatainR”
With that I created a barplot and when I download the barplot, part of the y axis is cut off because it’s “off of the paper”
I want to give myself more room to work with, or make my entire bar plot smaller. Thx
Is there a way to toggle drawCircle on individual data points? From the documentation it appears you can only enable this at the dataset level. I'm trying to draw circles for the min/max of a dataset.
If there isn't a way to draw circles on individual data points another workaround I've tried implementing has been to create a second dataset and only plot the corresponding X index and min/max Y value; every other value is set small enough that it is not visible in the viewport. The only problem here is I can't seem to plot both datasets without overwriting the first dataset's background fill.
I'm using coreplot for my project,the problem i'm struggling for past few hours is,i need to update the y axis values every time user enter changes value.To constraint the y axis range i'm using [graph.defaultPlotSpace scaleToFitPlots:[graph allPlots]]but with this i'm facing issue with x axis position,it's changing every time i change the value for y axis.
As you can see,the x axis is moving from down to up.How can i fix this problem?
-scaleToFitPlots: adjusts the plot space to fit the plot data exactly. You can use it as a starting point to fit the data and then expand the resulting range to leave extra space around the edges or to fix the location of one of the ranges. For example, you could adjust the calculated yRange so the location is always at zero (0).
Im currently doing a real time plot where I generate data every second. The problem I'm running into is that after about 15 seconds or so, because of how I have my xRange set, my plot begins to move/scroll automatically, which is an intentional effect, however my y axis seems to be rooted at the origin and quickly falls off screen. How would I either set the position to be rooted at the center of the view constantly, or what property do I need to update in order for the Y axis to also move?
I've looked through them all but I don't see anything obvious, or anything that seems to apply based on the included definitions/help.
I happened to find the answer in an old google groups thread, so I will post it here as a confirmation of it working in Core Plot 1.0, and since this is a bit more organized/searchable place.
When you're initializing the plot, you want to set the axis constraint as follows.
axisSet.yAxis.axisConstraints = [CPTConstraints constraintWithLowerOffset:0.0];
I am using core plot to make a line graph for my iPhone app. So far I successfully made the line graph from my xml data.
Furthermore I added a text layer that shows the value (for example 40) once I select the cell
holding the value 40. For this, I use the function:
(CPTLayer *)dataLabelForPlot:(CPTPlot *)plot recordIndex:(NSUInteger)index
So now I want to have a vertical line on the graph to indicate the selected value (the 40). I tried adding CPTBarplot but somehow the bars show only at the beginning of the graph axis.
Is there a function from core plot like the above that will create a line indicator?
I would appreciate if someone can give me some hint how to solve this problem and thank you very much in advance.
You could use a scatter plot for that. There's a point selection demo in the Mac CPTTestApp that draws a crosshair over the selected point. It would be trivial to modify that to only draw the vertical line.
The -numberOfRecordsForPlot: datasource method returns the number of points in the selection indicator (5 for the crosshairs) or zero (0) if there is no current selection. The -numberForPlot:field:recordIndex: method returns the points in the indicator. The points are drawn in this order:
Left
Right
Center (with plot symbol)
Top
Bottom
The -symbolForScatterPlot:recordIndex: method controls the plot symbol in the center. You can eliminate this method if you don't need any symbols on the indicator plot.