Coreplot Y axis cut off / no numbers? - ios

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.

Related

How To Find Remaining Distance To Move UIView Between 2 Points

SCENARIO
I am working on an application that keeps track of blood glucose levels into a graph. On the graph there are "markings" (ex: -200mg) going in vertical order along the y axis on the right side of the screen and "hours" (ex: -12:00 PM) will be along the x axis on the bottom of the graph. I have to plot out little 'dots' to display what the blood glucose level was throughout the way.
ISSUE
I am trying to calculate how to position the 'dots' in the correct time and mg level and I'm having difficulty calculating the positions. I can access the "markings" and retrieve it's marking.center.x to indicate which 'Time Slot' (x axis) and the marking.center.y to indicate which 'MG Level' the 'dot' needs to go into. Problem is it isn't always exactly 12:00 PM or 200mg where it will need to be placed. In fact that would be very rare.
WHAT I NEED
Based on the following variables:
dot.mgLevel
The dot will already know where it needs to go based on the information retrieved from the medical device. It will know the time and mgLevel to assign itself.
marking.mgLevel
The markings will each have evenly distributed values that such as -100mg, -200mg, -300mg ect...
timemarking.timeslot
Each time marking on the bottom will each have evenly distributed times allocated every 30 min. Such as -12:00PM, -12:30PM, -1:00PM ect...
If the dot has a mg Level of 330mg and the closest marking on the mg Level is 300mg, then I need to be able to calculate how much further up the dot needs to move from 300 going towards the 400mg marker.
SO...
If the distance between the markings are 100pt and the dot's mgLevel is 330mg, then I know that I need to move the dot from the 300mg marking toward the 400mg marking by exactly 30pt. That's because it's simple math because the distance between the markings is 100. But in real life it isn't 100, so I need to be able to calculate this.
MY ULTIMATE QUESTION
Say distance between markings is 241 and each marking represents multiples of a hundred. Say my dot has a mgLevel of 412. How do I calculate how far I need to move the dot so that it will be in the correct place?
I THINK?
I think I need to make 241 equal 100%. But I need help.
Distance between markings is 241pt
Markings are multiples of 100mg
1mg will occupy 2.41pt. So 412mg will occupy (2.41 * 412) pt. To know how much to move for the next dot, take the difference in mg and multiply by 2.41.
In general, if distance between 2 markings in points is d, markings are multiples of m, and desired accuracy is k decimal places, 1mg will occupy g:
let divisor = pow(10.0, Double(k))
let g = round((d/m)*divisor) / divisor

Highcharts column width with variable x axis point spacing

So I have an x axis of type datetime, and a series of type column:
http://jsfiddle.net/drmrbrewer/215tnLna/3/
Now, in reality, the spacing of points on the x axis may not always be uniform as in the above example. For example, let's drop a couple of the points to create a non-uniform spacing:
http://jsfiddle.net/drmrbrewer/215tnLna/4/
What I'd like to happen is for each column to fill the entire span from the relevant point to the previous point, so that the gaps would be entirely filled in the above example.
Is that possible? Hopefully without some horrible hack? From a quick search it seems that there is a suggestion that different series may be required (one for each column width). I'm hoping that isn't the case because (a) it's complicated; and (b) I don't know in advance what spacings I'm going to encounter in the data, so it's even more complicated!
Thanks!
What you are trying to make is a histogram, not a bar chart (even bar/column widths). Perhaps you need to use the histogram chart type? https://www.highcharts.com/docs/chart-and-series-types/histogram-series

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.

Coreplot: Axis Labels Fixed Location

I'm trying to customize a Coreplot graph in many ways I can and the next thing I would like to do is place the X Axis Labels (one that is custom as well) at the bottom of the graph, independent of the X axis' position (whether it's scrolled up or down).
To make it clear, it is similar to giving the labels an offset value of something like 50.0. But offset is not the property I'm looking for since it fixes the labels location relative to the X axis.
Any way this can be done? Or do I have to skip the axisLabels property and place and layer or something manually at the bottom of the graph?
EDIT: Alright, I managed to place an axis on the bottom with CPTConstraints. But it's not on the bottommost. If a plot point is on those levels, the plot line overlaps the labels. I tired padding of the graph but of course, it moves the whole graph, hence the issue persists.
Thanks in advance
Make a second x-axis. Have the first one draw the axis line, tick marks, etc., as normal but no labels. Label the second one and set all of the line style properties to nil so it doesn't draw any of the lines.
Turns out that aside from the graph, the plotAreaFrame property of the CPTGrpah also has paddings. If you give more paddings to plotAreaFrame than that of the graph, the plot will be drawn in a smaller frame and the rest of the graph area will be for you to add what you want (i.e., a second Axis).
Big thanks to #Eric, for trying to answer Every single CorePlot question as soon as possible.
CorePlot does have a lot of customisation than I thought.

Resources